EnableAlert APIを呼び出して、アラートルールを有効にします。
前提条件
Simple Log Serviceが有効化されています。 詳細については、「
Simple Log Serviceの有効化Python用のSimple Log Service SDKが初期化されます。 詳細については、「Simple Log Service SDK For Pythonの初期化」をご参照ください。
パラメータ説明
def enable_alert(self, project_name, job_name):パラメーター | 型 | 必須 / 任意 | 説明 | 例 |
project_name | String | 対象 | プロジェクトの名前。 | demo-test-project |
job_name | String | 対象 | アラートルールの ID。 | alert-0123456789-123456 |
詳細については、「EnableAlert」をご参照ください。
サンプルコード
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()
関連ドキュメント
アラートルールに関連するAPIの詳細については、以下のトピックを参照してください。
詳細なサンプルコードについては、GitHubの「Alibaba Cloud Simple Log Service SDK For Python」をご参照ください。