All Products
Search
Document Center

Simple Log Service:Query the logstores that match specific conditions in a project

Last Updated:Jan 02, 2025

Call the ListLogStores API to retrieve the logstores that match specific conditions in a project.

Prerequisites

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: test-1 and test-2, and you set logstore_name_pattern=test, it will return the names of these two logstores. If this field is left empty or filled with an empty string, this indicates that any logstore in the project can be matched.

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