Query a logstore

Updated at:

Call the GetLogStore API to retrieve details of a specified Logstore, including the shard count, data retention period, and Logstore type.

Prerequisites

Parameter description

def get_logstore(self, project_name, logstore_name):

Request parameters

Parameter

Type

Required

Description

project_name

String

Yes

The name of the project. The project in Simple Log Service is used to isolate the resources of different users and control access to specific resources. See Manage projects.

logstore_name

String

Yes

The name of the logstore. The logstore in Simple Log Service is used to collect, store, and query logs. See Manage Logstores.

Response parameters

For more information, see GetLogStore.

Sample code

from aliyun.log import LogClient
import os


# In this example, the AccessKey ID and AccessKey secret are obtained from environment variables.
access_key_id = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
access_key_secret = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')

# The Simple Log Service endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"
# Create a Simple Log Service client.
client = LogClient(endpoint, access_key_id, access_key_secret)


project_name = 'slsproject-1'

logstore_name = "logstore-1"


def main():
    # Query the logstore information.
    res = client.get_logstore(project_name, logstore_name)
    res.log_print()


if __name__ == '__main__':
    main()

Sample response

GetLogStoreResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '311', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Thu, 21 Nov 2024 10:22:20 GMT', 'x-log-time': '1732184540', 'x-log-requestid': '673F09DCC3900F943481****'}
logstore_name: logstore-1
shard_count: 2
ttl: 30
mode: standard

Process finished with exit code 0