All Products
Search
Document Center

Simple Log Service:GetContextLogs

Last Updated:Jun 11, 2026

Mengkueri log kontekstual dari log tertentu.

Deskripsi operasi

Usage notes

  • You can specify a log as the start log. The time range of a contextual query is one day before and one day after the generation time of the start log.

  • Host consists of a project name and a Simple Log Service endpoint. You must specify a project in Host.

  • An AccessKey pair is created and obtained. For more information, see AccessKey pair.

The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in Simple Log Service is a high-risk operation. We recommend that you use a Resource Access Management (RAM) user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. Make sure that the RAM user has the management permissions on Simple Log Service resources. For more information, see Create a RAM user and authorize the RAM user to access Simple Log Service.

  • The information that is required to query logs is obtained. The information includes the name of the project to which the logs belong, the region of the project, and the name of the Logstore to which the logs belong. For more information, see Manage a project and Manage a Logstore.

  • Indexes are configured before you query logs. For more information, see Create indexes.

  • The values of the pack_id and pack_meta fields are obtained before you query logs. The fields are internal fields, and you can obtain the values by using the debugging feature of your browser in the Simple Log Service console.

Authentication resources

The following table describes the authorization information that is required for this operation. You can add the information to the Action element of a RAM policy statement to grant a RAM user or a RAM role the permissions to call this operation.

ActionResource
log:GetLogStoreContextLogsacs:log:{#regionId}:{#accountId}:project/{#ProjectName}/logstore/{#LogstoreName}

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tidak ada otorisasi untuk operasi ini. Jika Anda mengalami masalah saat menjalankan operasi ini, hubungi dukungan teknis.

Sintaks permintaan

GET /logstores/{logstore}?type=context_log HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

logstore

string

Yes

Nama penyimpanan log.

test-logstore

Parameter permintaan

Parameter

Type

Required

Description

Example

project

string

Yes

Nama proyek.

ali-test-project

pack_id

string

Yes

Pengidentifikasi unik kelompok log tempat log awal berada.

85C897C740352DC6-808

pack_meta

string

Yes

Pengidentifikasi konteks unik log awal dalam kelompok log.

2|MTY1NTcwNTUzODY5MTY0MDk1Mg==|3|0

back_lines

integer

Yes

Jumlah log yang ingin Anda ambil dan dihasilkan sebelum pengatur waktu pembuatan log awal. Nilai valid: (0,100].

10

forward_lines

integer

Yes

Jumlah log yang ingin Anda ambil dan dihasilkan setelah pengatur waktu pembuatan log awal. Nilai valid: (0,100].

10

Elemen respons

Element

Type

Description

Example

object

Schema of Response

total_lines

integer

The total number of logs that are returned. The logs include the start log that is specified in the request.

201

back_lines

integer

The number of logs that are generated before the generation time of the start log.

100

forward_lines

integer

The number of logs that are generated after the generation time of the start log.

100

progress

string

Indicates whether the query and analysis results are complete. Valid values:

  • Complete: The query is successful, and the complete query and analysis results are returned.

  • Incomplete: The query is successful, but the query and analysis results are incomplete. To obtain the complete results, you must repeat the request.

Complete

logs

array<object>

The logs that are returned.

object

The logs that are returned. The logs are arranged in contextual order. If no contextual logs are found based on the specified start log, this parameter is empty.

{ "__index_number__": "-100", "__tag__:__pack_id__": "895CEA449A52FE-8c8", "__pack_meta__": "0|MTU1OTI4NTExMjg3NTQ2NDU1OA==|4|1"}

Parameter logs berisi konten log dan bidang berikut yang diformat dalam pasangan kunci-nilai.

BidangTipeContohDeskripsi
__index_number__String-100Posisi log dalam konteks. Nilai negatif menunjukkan bahwa log dihasilkan pengatur waktu pembuatan log awal. Nilai 0 menunjukkan bahwa log adalah log awal. Nilai positif menunjukkan bahwa log dihasilkan setelah waktu pembuatan log awal. Misalnya, nilai -100 menunjukkan bahwa log adalah log ke-100 pengatur waktu pembuatan log awal.
__tag__:__pack_id__String895CEA449A52FE-8c8Pengidentifikasi unik kelompok log tempat log berada. Pengidentifikasi ini dapat digunakan sebagai nilai parameter pack_id di permintaan.
__pack_meta__String`0MTU1OTI4NTExMjg3NTQ2NDU1OA==

Contoh

Respons sukses

JSONformat

{
  "total_lines": 201,
  "back_lines": 100,
  "forward_lines": 100,
  "progress": "Complete",
  "logs": [
    {
      "__index_number__": "-100",
      "__tag__:__pack_id__": "895CEA449A52FE-8c8",
      "__pack_meta__": "0|MTU1OTI4NTExMjg3NTQ2NDU1OA==|4|1"
    }
  ]
}

Kode kesalahan

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.