ユーザーとして Opsgenie の利用を開始する
プロフィールの設定、Opsgenie からの通知の取得、オンコール スケジュールの表示に関するすべての方法を説明します。
Marid は廃止予定で、2022 年 11 月 21 日に完全に廃止されます。詳細はコミュニティの投稿をご覧ください。
アトラシアンの拡張性プラットフォームをこれまでご利用になられたことがない場合は「拡張性プラットフォームとしての Opsgenie Edge Connector」をご参照のうえ、Opsgenie アカウントで実行する方法をご確認ください。
Marid をご利用で Opsgenie Edge Connector に移行する場合は「Opsgenie Edge Connector に移行する必要がある理由」をご参照ください。
Marid は、Opsgenie ユーザー アクションをサブスクライブしてユーザー アクションごとにスクリプトを実行できます。この機能の一般的な使用方法は、[Create Action (アクションの作成)] をサブスクライブして、スクリプトを介して新規作成されたアラートにファイルを添付することです。アクションの実行に関する詳細については、Marid インテグレーション サポート ドキュメントをご参照ください。
このドキュメントでは、Amazon S3 からファイルをダウンロードして "Groovy" スクリプトを使用して Marid 経由でアラートに添付する方法について説明します。このサンプル スクリプトは、OpsGenieHttpClient オブジェクトを使用して S3 からファイルを受信し、"opsgenie" スクリプト変数を使用して受信したファイルをアラートに添付します。
スクリプトがまず、"createHttpClient" メソッドを使用して、OpsfenieHttpClient オブジェクトを構築します。その後、OpsfenieHttpClient が、指定された URL を使用して "GET" リクエストを送信します。s3 からファイルを正常に受信した場合は、ファイルをアラートに添付します。
groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import com.ifountain.opsgenie.client.http.OpsGenieHttpClient
import com.ifountain.opsgenie.client.util.ClientConfiguration
//Creates OpsGenieHttpClient.
OpsGenieHttpClient HTTP_CLIENT = createHttpClient()
// S3 url of the file that will be attached to the alert.
def url = "https://s3.amazonaws.com/yourbucket/yourfile.png"
//Sending request to retrieve file
def response = HTTP_CLIENT.get(url, [:])
def code = response.statusCode
if(code == 200){
//attaching the file to the alert when retrieving the file successfully.
logger.warn("File received")
//filename of the attachment file. Change file extension according to your usage.
// If your file is a txt, use trial.txt as fileName
def fileName = "trial.png"
resp = opsgenie.attach([alertId: alert.alertId, stream: new ByteArrayInputStream(response.getContent()), fileName: fileName])
if(resp.success){
logger.warn("Successfully attached details ${fileName}");
}else{
logger.warn("Could not attach details ${fileName}");
}
}else{
logger.warn("Could not get file from url ${url}. ResponseCode:${code} Reason:" + response.getContentAsString())
}
def createHttpClient() {
//if you want to use different timeout value, add "http.timeout" property to Marid's conf file.
def timeout = conf["http.timeout"]
if(timeout == null){
timeout = 30000;
}
else{
timeout = timeout.toInteger();
}
ClientConfiguration clientConfiguration = new ClientConfiguration().setSocketTimeout(timeout)
//To use basic authentication while getting the file that will be attached,
// comment in the line below and add "user" and "password" properties to Marid's conf file
// .setCredentials(new UsernamePasswordCredentials(conf["user"], conf["password"]))
return new OpsGenieHttpClient(clientConfiguration)
}
この内容はお役に立ちましたか?