エスカレーションチェーンの追加

最終更新日: 03 年 2024 月 XNUMX 日

LogicMonitor REST API v3 を使用してエスカレーション チェーンを追加できます。 API リクエストを行う前に、自分自身を認証する必要があります。

URI: 投稿 /setting/alert/chains

タイプ説明
throttlingAlerts整数If enableThrottling に設定されています trueをタップし、その後、 throttlingAlerts スロットル期間中に送信できるアラートの最大数を示します。
例– “throttlingAlerts”: 40
enableThrottlingブーリアンこのエスカレーション チェーンに対してスロットル (レート制限) が有効かどうかを示します。フィールドが次のように設定されている場合、 trueをタップし、その後、 throttlingPeriod & throttlingAlerts アラートがどのように抑制されるかを示します。
例– “enableThrottling”: false
destinations(必須の) 宛先は次のもので構成されます。
  • period – この期間の曜日のリスト(weekDays)、この期間のタイムゾーン(timezone)、この期間の開始分と終了分(startMinutes と endMinutes)。
  • stages – で構成されています typemethodcontactaddr。 の説明を参照してください ccDestinations フィールド。
  • type – このチェーン内のステージのタイプを示します。値は次のとおりです。 timebased or simple 
name文字列(必須の) エスカレーション チェーンの名前。
例– “name”: ”MyEscalationChain”
description文字列エスカレーション チェーンの説明。
ccDestinations  ccDestination 受信者の詳細情報で構成されます。
  • type  - (必須の) サポートされている受信者の種類は次のとおりです。 GROUPARBITRARYADMIN。 ここに、 ADMIN ユーザーを示し、 ARBITRARY は任意のメールアドレスを示します。
  • method  - (必須の) サポートされているメソッドは次のとおりです。 EMAILsmsEMAILVOICESMS。 この方法は受信者の種類によって異なります。
    ARBITRARY - 使用する email
    ADMIN - 使用する EMAILsmsEMAILVOICESMS。メソッドが提供されていない場合、デフォルトのメソッド EMAIL 使用されている。
    GROUP – 必要ありません method
  • contact – 受信者の電子メール アドレスまたは電話番号が含まれます。
  • addr – もし type is Admin ユーザー名を入力し、タイプが Arbitrary 受信者の電子メール アドレスを入力します。
throttlingPeriod整数スロットル (レート制限) 期間 (分単位)。 enableThrottling に設定されています true.
例– “throttlingPeriod”: 30

次の Python スクリプトは、エスカレーション チェーン「DBTeam」をアカウント api.logicmonitor.com に追加します。このエスカレーション チェーンには、DB チーム受信者グループ用の 1 つのステージがあります。

#!/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 ='POST'
resourcePath = '/setting/alert/chains'
data='{"name":"DBTeam","destinations":[{"type":"single","stages":[[{"type":"group","addr":"dbTeam"}]]}]}'
 
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath
 
#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.post(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Pythonの3