当社のREST APIは、New RelicのオリジナルAPIで、New Relicのアラート設定をプログラムで設定します(当社の優先APIであるNerdGraphの詳細をご覧ください )。
REST APIエクスプローラー には、使用可能なAPIコールごとにcurlリクエストフォーマット、使用可能なパラメーター、取りうるレスポンス状態コード、JSONレスポンス構造も含まれます。UI でアラート条件を作成する こともできます。
REST APIを使用する前に REST APIを使用してアラートデータを管理する前に、 NerdGraph APIを使用したアラートの使用の概要 ドキュメントをご確認ください。
インフラストラクチャのアラートについては、 InfrastructureモニタリングアラートのREST API を参照してください。
REST APIで使用可能なデータと機能 REST API functions
Comments
アカウントデータを表示
一般に、どのロール でも、GET > List 関数を使用可能なユーザーキー を使用して、アラートデータをview ことができます。アカウントの所有者と管理者は、自身のAPIキーを使用できます。
リストの出力にはページ番号 が付けられることに注意してください。使用可能な機能:
アカウントデータのメンテナンス
アカウントにOwnerまたはAdminのロールがある場合、and ユーザーキー およびアラート管理の権限が付与されたカスタムロールがある場合、ユーザーキーを使用して、POST > Create 、 PUT > Add 、 PUT > Update 、 DELETE を含むすべてのメンテナンス機能を利用できます。
REST APIから除外される条件 以下の条件には、APIで使用可能なエンドポイントはありません。
APM:ウェブトランザクションパーセンタイル、条件ターゲティングラベル、異常 NRQL:異常 アラートポリシー これらのAPI関数には、ポリシー を簡単に作成、削除、リストすることができるAPIエクスプローラーへのリンクが含まれます。
重要 By default, this endpoint uses the US data center. If your organization hosts data in the EU data center, ensure you're using the proper API endpoints for EU region accounts . For JP data center accounts, ensure you are using the proper JP region API endpoints.
新しいポリシーを作成する 新しいポリシーを追加するには、ユーザーキー を使用して、APIコールに以下の2つの値を含めます。
Required values
Definition
incident_preference
アラートにおけるアラートイベントの作成 方法を決定します。以下のいずれかの方法で行う必要があります。
PER_POLICY (デフォルト):ポリシー 別のロールアップ。PER_CONDITION:条件 別のロールアップ。PER_CONDITION_AND_TARGET:ターゲットと条件 別のロールアップ。ポリシー name
ポリシーnameは必須です。変更しないままにすると、stringというポリシーが作成されます。
API Explorer > Alerts Policies > POST > Create
$ curl -X POST 'https://api.newrelic.com/v2/alerts_policies.json' \
> -H 'Content-Type: application/json' \
$ "incident_preference": "string",
ポリシーを更新する このAPIを使用して、既存のポリシーのnameとincident_preferenceを更新します。ユーザーキー が必要になります。
Required values
Definition
id
ポリシーのIDを確認するには、以下のオプションのいずれかを使用します。
UIから:ポリシーのUIページで、ポリシー名の下にあるIDを検索します。 APIを使用する場合:リストポリシーAPI を使用します。 incident_preference
アラートにおけるアラートイベントの作成 方法を決定します。以下のいずれかの方法で行う必要があります。
PER_POLICY (デフォルト):ポリシー 別のロールアップ。PER_CONDITION:条件 別のロールアップ。PER_CONDITION_AND_TARGET:条件と信号 別のロールアップ。ポリシー name
ポリシーname。nameを変更しない場合は、デフォルトでstringというポリシーに設定されます。
List policies API を使用して、ポリシーの正確な名前を確認します。
API Explorer > Alerts Policies > PUT > Update
$ curl -X PUT 'https://api.newrelic.com/v2/alerts_policies/{id}.json' \
> -H 'Content-Type: application/json' \
$ "incident_preference": "string",
既存のポリシーを削除する 既存のポリシーを削除するには、ユーザーキー を使用して、policy_id(API Explorer > Alerts Policies > GET > List から入手可能)をAPIコールに含めます。
API Explorer > Alerts Policies > DELETE
$ curl -X DELETE 'https://api.newrelic.com/v2/alerts_policies/$POLICY_ID.json' \
既存のポリシーをリストする アカウントの既存ポリシーのリストを表示するには、ユーザーキー を使用して以下のオプションの値をAPIコールに含めます。
APM、ブラウザ、モバイルの条件 このAPI関数には、ポリシーの条件 を簡単に作成、更新、削除、リストできるAPIエクスプローラーへのリンクが含まれます。こうしたコールは、以下のタイプのエンティティ向け条件となります:
APM:アプリとキートランザクション Browser:アプリとキートランザクション Mobile:モバイルアプリ Exception: 次のAPMの条件は、このAPIエンドポイントからはnot available 取得できません。
条件ターゲティングラベル(ダイナミックターゲティング) ウェブトランザクションのパーセンタイル条件 異常条件 重要 The API Explorer provides information about other types of conditions using separate endpoints , including external services (APM and mobile), and synthetic monitoring . Consider all types of alert conditions when searching or updating. By default, this endpoint uses the US data center. If your account hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts .
ポリシーの条件を作成する ポリシーに条件を追加するには、以下の値をAPIコールに含めます:
ご利用のユーザーキー
policy_id(API Explorer > Alerts Policies > GET > List から入手可能)
APIコールで必須とされるcondition値(APIエクスプローラーページとアラート条件のAPI用語集 で説明されています)
API Explorer > Alerts Conditions > POST > Create
$ curl -X POST 'https://api.newrelic.com/v2/alerts_conditions/policies/$POLICY_ID.json' \
> -H 'Content-Type: application/json' \
$ "condition_scope": "string",
$ "violation_close_timer": integer,
$ "runbook_url": "string",
$ "time_function": "string"
$ "value_function": "string"
JSONレスポンスは、条件の更新や削除に必要な条件idを返します。条件idはAPI Explorer > Alerts Conditions > GET > List からも表示できます。
ポリシーの条件を更新する ポリシーの条件を更新するには、以下の値をAPIコールに含めます:
ユーザーキー
条件id(API Explorer > Alerts Conditions > GET > List から入手可能)
APIコールで必須とされるcondition値(APIエクスプローラーページとアラート条件のAPI用語集 で説明されています)
API Explorer > Alerts Conditions > PUT > Update
$ curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/$CONDITION_ID.json' \
> -H 'Content-Type: application/json' \
$ "condition_scope": "string",
$ "violation_close_timer": integer,
$ "runbook_url": "string",
$ "time_function": "string"
$ "value_function": "string"
ポリシーから条件を削除する ポリシーから条件を削除するには、以下の値をAPIコールに含めます:
ポリシーの既存の条件をリストする ご利用のポリシーについて既存条件の一覧を表示するには、ユーザーキー 、およびAPIコールの関連policy_id を使用します。
API Explorer > Alerts Conditions > GET > List
$ curl -X GET 'https://api.newrelic.com/v2/alerts_conditions.json?policy_id=$POLICY_ID' \
NRQLの条件 このAPI関数には、ポリシーのNRQL条件 を簡単に作成、更新、削除、リストできるAPIエクスプローラーへのリンクが含まれます。
Exception: NRQL異常の条件は、このエンドポイントからはnot available 入手できません。
重要 By default, this endpoint uses the US data center. If your organization hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts . For JP data center accounts, ensure you are using the proper JP region API endpoints.
ポリシーのNRQL条件を作成する 推奨事項: NRQL データのストリーミング方法により、 aggregation_methodをEVENT_FLOWに設定し、 aggregation_windowにはデフォルト設定の60を使用し、 aggregation_delayには120を使用します。EVENT_FLOWは、ほとんどの使用例で機能しますが、どの使用例がEVENT_TIMERに適しているかについては、 集計方法の選択 を参照してください。
API Explorer > Alerts NRQL Conditions > POST > Create
ポリシーのNRQL条件を作成する:
$ curl -X POST 'https://api.newrelic.com/v2/alerts_nrql_conditions/policies/$POLICY_ID.json' \
> -H 'Content-Type: application/json' \
$ "runbook_url": "string",
$ "time_function": "string"
$ "value_function": "string",
$ "aggregation_window": "string",
$ "aggregation_method": "string",
$ "aggregation_delay": integer,
$ "aggregation_timer": integer,
$ "fill_option": "string",
$ "expiration_duration": "string",
$ "open_violation_on_expiration": boolean,
$ "close_violations_on_expiration": boolean
typeを除外するかstaticと設定すると、標準的なNRQLアラートにデフォルト設定されます。
ポリシーのNRQL条件を更新する ポリシーのNRQL条件を更新するには、以下の値をAPIコールに含めます:
ユーザーキー
条件のid(APIエクスプローラー Alerts NRQL Conditions > GET > List から入手可能)
APIコールで必須とされるcondition値(APIエクスプローラーページとアラート条件のAPI用語集 で説明されています)
API Explorer > Alerts NRQL Conditions > PUT > Update
$ curl -X PUT 'https://api.newrelic.com/v2/alerts_nrql_conditions/$CONDITION_ID.json' \
> -H 'Content-Type: application/json' \
$ "runbook_url": "string",
$ "time_function": "string"
$ "value_function": "string",
ポリシーのNRQL条件を削除する ポリシーからNRQL条件を削除するには、以下の値をAPIコールに含めます:
外部サービスの条件 このAPI関数には、ポリシーの条件 を簡単に作成、更新、削除、リストできるAPIエクスプローラーへのリンクが含まれます。以下のコールは外部サービスの条件です。APIコールは、APM およびモバイル監視アプリで使用できます。
重要 By default, this endpoint uses the US data center. If your organization hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts . For JP data center accounts, ensure you are using the proper JP region API endpoints.
外部サービス:ポリシーの条件を作成する APMまたはモバイルモニタリングアプリを有するポリシーの外部サービスに条件を追加するには、以下の値をAPIコールに含めます:
ユーザーキー
policy_id(API Explorer > Alerts Policies > GET > List から入手可能)
APIコールで必須とされるexternal_service_condition値(APIエクスプローラーページとアラート条件のAPI用語集 で説明されています)
API Explorer > Alerts External Service Conditions > POST > Create
$ curl -X POST 'https://api.newrelic.com/v2/alerts_external_service_conditions/policies/$POLICY_ID.json' \
> -H 'Content-Type: application/json' \
$ "external_service_condition": {
$ "external_service_url": "string",
$ "runbook_url": "string",
$ "time_function": "string"
JSONレスポンスは、条件の更新や削除に必要な条件idを返します。条件idはAPI Explorer > Alerts External Service Conditions > GET > List からも表示できます。
外部サービス:ポリシーの条件を更新する APMまたはモバイルモニタリングアプリを有するポリシーの外部サービスの条件を更新するには、以下の値をAPIコールに含めます:
ユーザーキー
外部サービス条件のid(API Explorer > Alerts External Service Conditions > GET > List から入手可能)
APIコールで必須とされるexternal_service_condition値(APIエクスプローラーページとアラート条件のAPI用語集 で説明されています)
API Explorer > Alerts External Service Conditions > PUT > Update
$ curl -X PUT 'https://api.newrelic.com/v2/alerts_external_service_conditions/$CONDITION_ID.json' \
> -H 'Content-Type: application/json' \
$ "external_service_condition": {
$ "external_service_url": "string",
$ "runbook_url": "string",
$ "time_function": "string"
外部サービス:条件をポリシーから削除する APMまたはモバイルモニタリングアプリを有するポリシーの外部サービスの条件を削除するには、以下の値をAPIコールに含めます:
外部サービス:ポリシーの既存の条件をリストアップする 外部サービスアプリ(APMまたはモバイル監視)でポリシーの既存条件の一覧を表示するには、ユーザーキー 、およびAPIコールの関連policy_id を使用します。
API Explorer > Alerts External Service Conditions > GET > List
$ curl -X GET 'https://api.newrelic.com/v2/alerts_external_service_conditions.json' \
> -d 'policy_id=$POLICY_ID'
合成モニタリングの条件 以下のAPI関数には、アラートポリシーの条件 を簡単に作成、更新、削除、リストできるAPIエクスプローラーへのリンクが含まれます。APIコールは、合成モニタリングと共に使用できます。
合成モニタリング:ポリシーの条件を作成する 合成モニタリングのポリシーに条件を追加するには、以下の値をAPIコールに含めます:
ユーザーキー
policy_id(API Explorer > Alerts Policies > GET > List から入手可能)
APIコールで必須とされるsynthetics_condition値(APIエクスプローラーページとアラート条件のAPI用語集 で説明されています)
API Explorer > Alerts Synthetics Conditions > POST > Create
$ curl -X POST 'https://api.newrelic.com/v2/alerts_synthetics_conditions/policies/$POLICY_ID.json' \
> -H 'Content-Type: application/json' \
$ "synthetics_condition": {
$ "monitor_id": "string",
$ "runbook_url": "string",
JSONレスポンスは、条件の更新や削除に必要な条件idを返します。条件idはAPI Explorer > Alerts Synthetics Conditions > GET > List からも表示できます。
ポリシーの条件を更新する ポリシーの条件を更新するには、以下の値をAPIコールに含めます:
ユーザーキー
条件id(API Explorer > Alerts Conditions > GET > List から入手可能)
APIコールで必須とされるcondition値(APIエクスプローラーページとアラート条件のAPI用語集 で説明されています)
API Explorer > Alerts Conditions > PUT > Update
$ curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/$CONDITION_ID.json' \
> -H "X-Api-Key: $API_KEY " -i \
> -H 'Content-Type: application/json' \
$ "condition_scope": "string",
$ "violation_close_timer": integer,
$ "runbook_url": "string",
$ "time_function": "string"
$ "value_function": "string"
Syntheticモニタリング:条件をポリシーから削除する 合成モニタリングのポリシーの条件を削除するには、以下の値をAPIコールに含めます:
Syntheticモニタリング:ポリシーの既存の条件をリストする 外形監視の既存のポリシー条件一覧を表示するには、ユーザーキー 、およびAPIコールの関連policy_id を使用します。
API Explorer > Alerts Synthetics Conditions > GET > List
$ curl -X GET 'https://api.newrelic.com/v2/alerts_synthetics_conditions.json' \
> -d 'policy_id=$POLICY_ID'
複数の場所における合成モニタリングの条件 以下のAPI関数には、アラートポリシーの条件 を簡単に作成、更新、削除、リストできるAPIエクスプローラーへのリンクが含まれます。APIコールは、合成モニタリングを使用して複数場所の条件に使用できます。条件を作成または更新する前に、複数場所のアラート条件のルール をお読みください。
複数の場所における合成:ポリシーの条件を作成する 複数の場所における合成モニタリングのポリシーに条件を追加するには、以下の値をAPIコールに含めます:
ユーザーキー
policy_id(API Explorer > Alerts Policies > GET > List から入手可能)
APIコールで必須とされるlocation_failure_condition値(APIエクスプローラーページとアラート条件のAPI用語集 で説明されています)
API Explorer > Alerts Location Failure Conditions > POST > Create
$ curl -X POST 'https://api.newrelic.com/v2/alerts_location_failure_conditions/policies/$POLICY_ID.json' \
> -H 'Content-Type: application/json' \
$ "location_failure_condition": {
$ "runbook_url": "string",
$ "violation_time_limit_seconds": integer
JSONレスポンスは、条件の更新や削除に必要な条件idを返します。条件idはAPI Explorer > Alerts Location Failure Conditions > GET > List からも表示できます。
複数の場所における合成:ポリシーの条件を更新する 複数の場所における合成モニタリングのポリシーの条件を更新するには、以下の値をAPIコールに含めます:
ユーザーキー
条件id(API Explorer > Alerts Location Failure Conditions > GET > List から入手可能)
APIコールで必須とされるlocation_failure_condition値(APIエクスプローラーページとアラート条件のAPI用語集 で説明されています)
API Explorer > Alerts Location Failure Conditions > PUT > Update
$ curl -X PUT 'https://api.newrelic.com/v2/alerts_location_failure_conditions/$CONDITION_ID.json' \
> -H 'Content-Type: application/json' \
$ "location_failure_condition": {
$ "runbook_url": "string",
$ "violation_time_limit_seconds": integer
複数の場所における合成:ポリシーの条件を削除する 複数の場所における合成モニタリングのポリシーの条件を削除するには、以下の値をAPIコールに含めます:
複数の場所における合成:ポリシーの既存の条件をリストアップする 複数の場所における外形監視の既存のポリシー条件一覧を表示するには、ユーザーキー 、およびAPIコールの関連policy_id を使用します。
API Explorer > Alerts Location Failure Conditions > GET > List
$ curl -X GET 'https://api.newrelic.com/v2/alerts_location_failure_conditions/policies/$POLICY_ID.json' \
アラートエンティティ条件 こうしたAPI関数には、アラートポリシーに対する条件のエンティティをリスト、追加、削除できるAPIエクスプローラーへのリンクが含まれます。
重要 By default, this endpoint uses the US data center. If your organization hosts data in the EU data center, ensure you are using the proper API endpoints for EU region accounts . For JP data center accounts, ensure you are using the proper JP region API endpoints.
エンティティ別に条件をリストする APM、ブラウザ、モバイル、キートランザクションにおいて、エンティティ に適用される条件 を表示するには、以下の値をAPIコールに含めます:
ユーザーキー
entity_idは監視対象の特定のエンティティ(アラートターゲット) です。
entity_typeは、次のいずれかである必要があります:
ApplicationBrowserApplicationMobileApplicationKeyTransactionAPI Explorer > Alerts Entity Conditions > GET > list
$ curl -X GET 'https://api.newrelic.com/v2/alerts_entity_conditions/$ENTITY_ID.json' \
> -G -d 'entity_type=$ENTITY_TYPE'
条件にエンティティを追加する 条件にエンティティ を追加するには、以下の値をAPIコールに含めます:
ユーザーキー
entity_idは監視対象のエンティティ(アラートターゲット) です。APMアプリケーション、ブラウザアプリ、キートランザクション、モバイルアプリの数値IDです。
condition_id(API Explorer > Alerts Conditions > GET > List から入手可能)
entity_typeは、次のいずれかである必要があります:
ApplicationBrowserApplicationMobileApplicationKeyTransactionAPI Explorer > Alerts Entity Conditions > PUT > Add
$ curl -X PUT 'https://api.newrelic.com/v2/alerts_entity_conditions/$ENTITY_ID.json' \
> -H 'Content-Type: application/json' \
> -G -d 'entity_type=$ENTITY_TYPE&condition_id=$CONDITION_ID'
エンティティを条件から削除する 監視しているエンティティ を条件から削除するには、以下の値をAPIコールに含めます:
ユーザーキー
entity_idは削除されることになる特定の監視対象エンティティ(アラートターゲット) です。APMアプリケーション、ブラウザアプリ、キートランザクション、モバイルアプリの数値IDです。
condition_id(API Explorer > Alerts Conditions > GET > List から入手可能)
entity_typeは、次のいずれかである必要があります:
ApplicationBrowserApplicationMobileApplicationKeyTransactionAPI Explorer > Alerts Entity Conditions > DELETE > Remove
$ curl -X DELETE 'https://api.newrelic.com/v2/alerts_entity_conditions/$ENTITY_ID.json' \
> -G -d 'entity_type=$ENTITY_ID&condition_id=$CONDITION_ID'