Query the machine groups to which a Logtail configuration is applied

Updated at:

Call the GetAppliedMachineGroups operation to query the machine groups to which a Logtail configuration is applied.

Prerequisites

Parameters

def get_config_applied_machine_groups(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 Manage Logtail configurations for log collection.

Response parameters

For more information about the response parameters, see GetAppliedMachineGroups.

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

# The Simple Log Service endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"

client = LogClient(endpoint, access_key_id, access_key_secret)

project_name = "proj-test-1"
config_name = "nginx"


def main():
    # Apply a Logtail configuration to machine groups.
    res = client.get_config_applied_machine_groups(project_name, config_name)
    res.log_print()


if __name__ == '__main__':
    main()

Sample response

GetConfigAppliedMachineGroupsResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '39', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Tue, 15 Oct 2024 05:57:59 GMT', 'x-log-time': '1728971879', 'x-log-requestid': '670E04676930C98F8634****'}
count: 1
machine_groups: ['group-1']

Process finished with exit code 0

References