Call the ListLogStores API to retrieve the logstores that match specific conditions in a project.
Prerequisites
Simple Log Service is activated. For more information, see Activate Simple Log Service.
Simple Log Service SDK for Python is initialized. For more information, see Initialize Simple Log Service SDK for Python.
Parameter description
def list_logstore(self, project_name, logstore_name_pattern=None, offset=0, size=100):
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. For more information, see Manage a project. |
logstore_name_pattern | String | No | The fuzzy search term for the logstore name. Find all logstores in the project whose names contain this search term and return them. For example, if there are two logstores under the project: |
offset | String | No | The line from which the query starts. Default value: 0. |
size | String | No | The number of entries per page. Default value: 100. Maximum value: 500. |
Response parameters
For information about the response parameters, see ListLogStores.
Sample code
import os
from aliyun.log import LogClient
# 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', '')
# Specify a Simple Log Service endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"
client = LogClient(endpoint, access_key_id, access_key_secret)
project_name = "slsproject-1"
def main():
res = client.list_logstore(project_name)
res.log_print()
if __name__ == "__main__":
main()
References
For more information about the APIs related to logstore management, see the following topics:
For more sample code, see Alibaba Cloud Simple Log Service SDK for Python on GitHub.