Enable an alert rule

Updated at:

You can call the EnableAlert operation to enable a specified alert rule.

Prerequisites

Parameter description

def enable_alert(self, project_name, job_name):

Parameter

Type

Required

Description

Example

project_name

String

Yes

The name of the project.

demo-test-project

job_name

String

Yes

The ID of the alert rule.

alert-0123456789-123456

For more information, see EnableAlert.

Sample code

from aliyun.log import LogClient
import os


def main():
    # In this example, the AccessKey ID and AccessKey secret are obtained from environment variables.
    accessKeyId = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
    accessKey = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')

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

    project = 'demo-test-project'
    alertId = 'alert-0123456789-123456'

    client = LogClient(endpoint, accessKeyId, accessKey, "")

    res = client.enable_alert(project, alertId)
    res.log_print()


if __name__ == '__main__':
    main()

References