Query the Logtail configuration

Updated at:

Calls the GetConfig API to query a Logtail configuration for a specified project.

Prerequisites

Parameters

def get_logtail_config(self, project_name, config_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.

config_name

String

Yes

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

Response parameters

For information about the response parameters, see GetConfig.

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 = "slsproject-1"
config_name = "logstore-1-stt1-logtail"


def main():
    # Query the Logtail configuration.
    try:
        res = client.get_logtail_config(project, config_name)
        res.log_print()
    except Exception as error:
        print(error)


if __name__ == '__main__':
    main()

Sample response

GetLogtailConfigResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '890', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Fri, 22 Nov 2024 07:14:55 GMT', 'x-log-time': '1732259695', 'x-log-requestid': '67402F6F2E7F474733BB****'}
logtail_config: {'configName': 'logstore-1-stt1-logtail', 'logSample': '', 'createTime': 1732254984, 'inputDetail': {'logPath': '/apsara/xxx', 'filePattern': '*.LOG', 'localStorage': True, 'enableRawLog': False, 'topicFormat': 'none', 'fileEncoding': 'utf8', 'maxDepth': 1000, 'preserve': True, 'preserveDepth': 0, 'filterKey': [], 'filterRegex': [], 'adjustTimezone': False, 'delayAlarmBytes': 0, 'delaySkipBytes': 0, 'discardNonUtf8': False, 'discardUnmatch': True, 'dockerFile': False, 'enableTag': False, 'key': ['content'], 'logBeginRegex': '.*', 'logTimezone': '', 'logType': 'common_reg_log', 'maxSendRate': -1, 'mergeType': 'topic', 'priority': 0, 'regex': '(.*)', 'sendRateExpire': 0, 'sensitive_keys': [], 'tailExisted': False, 'timeFormat': ''}, 'inputType': 'file', 'outputDetail': {'logstoreName': 'logstore-1'}, 'outputType': 'LogService'}

Process finished with exit code 0

References