Call the GetAppliedConfigs API to retrieve the list of Logtail configurations applied to a specific machine group,
Prerequisites
Simple Log Service is activated.
Simple Log Service SDK for Python is initialized.
Parameter description
def get_machine_group_applied_configs(self, project_name, group_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 a project. |
group_name | string | Yes | The name of the machine group. |
Response parameters
For information about the response parameters, see GetAppliedConfigs.
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 = "proj-test-1"
group_name = "group-1"
def main():
# Obtain the Logtail collection configuration list from the attached machine group.
res = client.get_machine_group_applied_configs(project_name, group_name)
res.log_print()
if __name__ == '__main__':
main()
Sample response
GetMachineGroupAppliedConfigResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '31', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Tue, 15 Oct 2024 05:52:34 GMT', 'x-log-time': '1728971554', 'x-log-requestid': '670E03223AC9524A5CDC****'}
count: 1
configs: ['nginx']
Process finished with exit code 0
References
The following APIs are available to manage machine groups:
For more sample code, see Alibaba Cloud Simple Log Service SDK for Python on GitHub.