アラートルールの詳細の取得
最終更新日: 29 年 2023 月 XNUMX 日LogicMonitor REST API v3 を使用して、アラート ルールの詳細を取得できます。 API リクエストを行う前に、自分自身を認証する必要があります。
アラートルールのリストの取得
You can use the following query parameters to manage the content and format of the response.
注: クエリ パラメータはリソース パスの一部ではないため、LMv1 認証署名の計算中に含めるべきではありません。
URI: 取得 /setting/alert/rules
説明 | ||
fields | 文字列 | 応答はフィルター処理され、各オブジェクトの指定されたフィールドのみが含まれます。 プロパティのリストをカンマで区切って指定できます。 例– /setting/alert/rules?fields=name,id,priority |
size | 整数 | 表示する結果の数。 GET 呼び出しでは最大 1000 件の結果を要求できます。 このパラメータに値が指定されていない場合、デフォルトでは 50 個のアラート ルールのリストが返されます。 例– /setting/alert/rules?size=10 |
offset | 整数 | 表示された結果をオフセットする結果の数。 例– /setting/alert/rules?offset=20 |
filter | 文字列 | 応答はフィルター処理され、指定された値を含む結果のみが含まれます。 フィルタのリストをカンマで区切って指定できます。 例– /setting/alert/rules?filter=levelStr:"All" |
The following Python script gets ID, name, and priority of all alert rules in api.logicmonitor.com.
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass
#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'
#Request Info
httpVerb ='GET'
resourcePath = '/setting/alert/rules'
queryParams ='?fields=id,name,priority'
data = ''
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath +queryParams
#Get current time in milliseconds
epoch = str(int(time.time() * 1000))
#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath
#Construct signature
digest = hmac.new(
AccessKey.encode('utf-8'),
msg=requestVars.encode('utf-8'),
digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8')
# Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}
# Make request
response = requests.get(url, data=data, headers=headers)
# Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
アラートルールの取得
URI: 取得 /setting/alert/rules/{id}
説明 | ||
id | 整数 | (必須の) The ID of the alert rule that you want to get. |
fields | 文字列 | 応答はフィルター処理され、各オブジェクトの指定されたフィールドのみが含まれます。 プロパティのリストをカンマで区切って指定できます。 例– /setting/alert/rules/id?fields=name,id,priority |