List LogStores by condition

Updated at:

The ListLogStores operation queries LogStores in a project that match specified conditions such as name pattern, offset, and size. Use this operation to filter LogStores by name and paginate results.

Prerequisites

Parameters

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. See Manage projects.

logstore_name_pattern

String

No

The fuzzy search string for LogStore names. Simple Log Service returns all LogStores in the project whose names contain this string. For example, if a project contains two LogStores named test-1 and test-2, logstore_name_pattern=test returns the names of both LogStores. If you leave this parameter blank or specify an empty string, any LogStore in the project is 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: 500.

Response parameters

For the response parameters, see ListLogStores.

Sample code

import os
from aliyun.log import LogClient

# Obtain the AccessKey ID and AccessKey secret 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 endpoint of Simple Log Service
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()