Query Logtail configurations

Updated at:

Call the ListConfig operation to query all Logtail configurations in a specified project.

Prerequisites

Parameter description

def list_logtail_config(self, project_name, logstore=None, config=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

string

No

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

config

string

No

The name of the Logtail configuration. For more information, see Logtail (legacy)

offset

int

No

The line from which the query starts. Default value: 0.

size

int

No

The number of entries per page. Default value: 100. Maximum: 500.

Response parameters

For response parameter details, see ListConfig.

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', '')

# Specify a Simple Log Service endpoint.
endpoint = "ap-southeast-1.log.aliyuncs.com"

client = LogClient(endpoint, access_key_id, access_key_secret)


project_name = "sls-project-1"


def main():
    # Query all Logtail configurations.
    try:
        res = client.list_logtail_config(project_name)
        res.log_print()
    except Exception as error:
        print(error)


if __name__ == '__main__':
    main()

Sample response

ListLogtailConfigResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '143', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Fri, 22 Nov 2024 08:23:52 GMT', 'x-log-time': '1732263832', 'x-log-requestid': '67403F98D2F425CD04DC****'}
configs_count: 2
configs_total: 2
configs: ['logstore-1-stt1-logtail', 'logstore-1-stt2-logtail']

Process finished with exit code 0

References