• EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は参考用に提供されます。

英語版と翻訳版に矛盾がある場合は、英語版が優先されます。詳細については、このページ を参照してください。

問題を作成する

NerdGraphチュートリアルNRQLコンディションアラート

NerdGraphAPIを使用してアラート条件を管理できます。

ヒント

NerdGraphおよびNerdGraphエクスプローラーの使用を開始するためのヘルプについては、 NerdGraphの概要を参照してください。

NRQLの条件を作成する手順

以下の手順に従ってください。

  1. 作成する条件タイプを決定します( NRQL 条件しきい値タイプ を参照)。

  2. 次のいずれかを実行して、関連するpolicyIDを見つけます。

  3. NRQL の条件タイプに適したミューテーションと関連する値を提供してください。

ヒント

NerdGraph GraphiQLエクスプローラーは、NerdGraph NRQLConditionsAPIのフィールドごとの詳細に関する最新のドキュメントを見つけるのに最適な場所です。たとえば、「 valueFunctionフィールドは何を受け入れますか?」などの質問です。インラインのNerdGraphドキュメントで最もよく答えられます。

NRQLの静的条件

ここでは、静的な条件を作成する例を紹介します。

mutation {
alertsNrqlConditionStaticCreate(
accountId: YOUR_ACCOUNT_ID
policyId: YOUR_POLICY_ID
condition: {
name: "Low Host Count - Catastrophic"
enabled: true
nrql: {
query: "SELECT uniqueCount(host) FROM Transaction WHERE appName='my-app-name'"
}
signal: {
aggregationWindow: 60
aggregationMethod: EVENT_FLOW
aggregationDelay: 120
}
terms: {
threshold: 2
thresholdOccurrences: AT_LEAST_ONCE
thresholdDuration: 600
operator: BELOW
priority: CRITICAL
}
valueFunction: SINGLE_VALUE
violationTimeLimitSeconds: 86400
}
) {
id
name
}
}

NRQLベースライン条件

ここでは、ベースラインの状態を作成する例を紹介します。

mutation {
alertsNrqlConditionBaselineCreate(
accountId: YOUR_ACCOUNT_ID
policyId: YOUR_POLICY_ID
condition: {
name: "Baseline Condition"
enabled: true
baselineDirection: UPPER_ONLY
nrql: { query: "SELECT average(duration) FROM Transaction" }
signal: {
aggregationWindow: 60
aggregationMethod: EVENT_FLOW
aggregationDelay: 120
}
terms: {
threshold: 13
thresholdDuration: 180
thresholdOccurrences: ALL
operator: ABOVE
priority: CRITICAL
}
violationTimeLimitSeconds: 86400
}
) {
id
name
baselineDirection
}
}

条件の更新

次の項目を完了します。

  1. 次のようにnrqlConditionsSearchクエリのタイプフィールドをリクエストして、既存の条件のタイプを判別します。

    {
    actor {
    account(id: YOUR_ACCOUNT_ID) {
    alerts {
    nrqlConditionsSearch {
    nrqlConditions {
    id
    type
    }
    }
    }
    }
    }
    }

    ヒント

    返されるtypeは、更新ミューテーションに使用するものです。たとえば、返されるタイプがSTATICの場合、 alertsNrqlConditionStaticUpdateを使用します。返されるタイプがBASELINEの場合は、 alertsNrqlConditionBaselineUpdateを使用します。

  2. 条件のidを関連する条件タイプのミューテーションに提供します。更新できるのは、関連するタイプの条件のみであることに注意してください。

更新したいフィールドの更新変異のみを提供します。アップデートに提供していないフィールドはタッチされません。

変異点の更新

アップデートで指定したフィールドのみが変更されます。次の例では、 baselineDirectionは変更されずに返されますが、 nameは更新されます。

mutation {
alertsNrqlConditionBaselineUpdate(
id: YOUR_CONDITION_ID
accountId: YOUR_ACCOUNT_ID
condition: { name: "Your updated name" }
) {
id
name
baselineDirection
}
}

NRQL条件のリストアップとフィルタリング

NRQL条件を一覧表示またはフィルタリングするには、NerdGraphでnrqlConditionsSearchクエリを使用します。

単数形のNRQL条件検索

NRQL条件APIを使用して、単一の条件を照会できます。 alert名前空間でnrqlConditionクエリを実行します。

nrqlConditionSearchクエリのタイプ固有のフィールドと同様に、これらのインラインフラグメントを使用して、NRQL条件タイプに制限されているフィールドをリクエストすることもできます。

{
actor {
account(id: YOUR_ACCOUNT_ID) {
alerts {
nrqlCondition(id: YOUR_CONDITION_ID) {
id
name
... on AlertsNrqlStaticCondition {
valueFunction
}
}
}
}
}
}

説明文の更新

ここでは、NRQLのアラート条件に 説明文 を作成する手順を説明します。

  1. 保険契約の条件をすべて把握する。

    {
    actor {
    account(id: YOUR_ACCOUNT_ID) {
    alerts {
    nrqlConditionsSearch(searchCriteria: { policyId: YOUR_POLICY_ID }) {
    nrqlConditions {
    id
    name
    description
    enabled
    nrql {
    query
    }
    signal {
    aggregationWindow
    aggregationMethod
    aggregationDelay
    aggregationTimer
    }
    policyId
    runbookUrl
    terms {
    operator
    thresholdDuration
    threshold
    priority
    thresholdOccurrences
    }
    type
    violationTimeLimitSeconds
    }
    }
    }
    }
    }
    }
  2. 1つの条件の詳細を取得します。

    {
    actor {
    account(id: YOUR_ACCOUNT_ID) {
    alerts {
    nrqlCondition(id: "YOUR_CONDITION_ID") {
    description
    id
    enabled
    name
    nrql {
    query
    }
    signal {
    aggregationWindow
    aggregationMethod
    aggregationDelay
    aggregationTimer
    }
    policyId
    runbookUrl
    terms {
    operator
    priority
    threshold
    thresholdDuration
    thresholdOccurrences
    }
    type
    violationTimeLimitSeconds
    }
    }
    }
    }
    }
  3. 説明文で変異を作成します。

    ここには空の変異テンプレートがあります。

    mutation {
    alertsNrqlConditionStaticUpdate(
    accountId: YOUR_ACCOUNT_ID
    id: "YOUR_CONDITION_ID"
    condition: { description: "" }
    ) {
    description
    }
    }

    ここでは、記述例を含む変異の例を紹介します。

    mutation {
    alertsNrqlConditionStaticUpdate(
    accountId: 123456
    id: "123456"
    condition: {
    description: "timestamp : {{timestamp}} \n accountId : {{accountId}} \n type : {{type}} \n event : {{event}} \n description : {{description}} \n policyId : {{policyId}} \n policyName: {{policyName}} \n conditionName : {{conditionName}} \n conditionId : {{conditionId}} \n product : {{product}} \n conditionType : {{conditionType}} \n RunbookUrl : {{runbookUrl}} \n nrqlQuery : {{nrqlQuery}} \n nrqlEventType : {{nrqlEventType}} \n targetID : {{targetId}} \n targetName : {{targetName}} \n commandLine : {{tag.commandLine}} \n entityGuid : {{tag.entityGuid}} \n entityName : {{tag.entityName}} \n fullHostname : {{tag.fullHostname}} \n instanceType : {{tag.instanceType}} \n processDisplayName : {{tag.processDisplayName}}"
    }
    ) {
    description
    }
    }

条件の削除

alertsConditionDeleteミューテーションを使用して、任意のタイプの条件を削除できます。削除ミューテーションでのみidフィールドをリクエストできます。例えば:

mutation {
alertsConditionDelete(accountId: YOUR_ACCOUNT_ID, id: YOUR_CONDITION_ID) {
id
}
}
Copyright © 2024 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.