การจัดการการแจ้งเตือนโดยใช้ API

คุณกำลังดูเอกสารประกอบของ Apigee Edge
ไปที่เอกสารประกอบของ Apigee X
ข้อมูล

ส่วนต่อไปนี้จะอธิบายวิธีจัดการการแจ้งเตือนโดยใช้ API

โปรดดู Alerts API สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ Alerts API

ตั้งค่าการแจ้งเตือนโดยใช้ API

ตั้งค่าการเตือนและการแจ้งเตือนโดยการส่งคำขอ POST ไปยังแหล่งข้อมูลต่อไปนี้ https://apimonitoring.enterprise.apigee.com/alerts

ส่วนต่อไปนี้จะแสดงตัวอย่างการตั้งค่าการแจ้งเตือนโดยใช้ API

ตั้งค่าการแจ้งเตือนรหัสสถานะ 5xx สำหรับพร็อกซี API โดยใช้ API

ตัวอย่างต่อไปนี้แสดงวิธีตั้งค่าการแจ้งเตือนให้แสดงขึ้นเมื่อรหัสสถานะ 5xx เกิดขึ้นในอัตราที่มากกว่า 100 รายการต่อวินาที (TPS) เป็นเวลา 10 นาทีสำหรับพร็อกซี Hotel API ในสภาพแวดล้อมการใช้งานจริงของภูมิภาคใดๆ ระบบจะส่งการแจ้งเตือนไปยังอีเมลที่ระบุไว้เมื่อมีการทริกเกอร์การแจ้งเตือน

curl 'https://apimonitoring.enterprise.apigee.com/alerts' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
     "organization":"myorg",
     "name":"5xx Alert",
     "description":"My 5xx alert",
     "environment":"prod",
     "enabled":true,
     "conditions":[
     {
        "description":"",
        "dimensions":{
            "org":"myorg", 
            "env":"prod", 
            "proxy":"hotels",
            "region":"ANY",
            "statusCode":"5xx"
        },
        "metric":"tps",
        "threshold":100,
        "durationSeconds":600,
        "comparator":">"
     }
     ],
     "notifications":[{ 
         "channel":"email", 
         "destination":"ops@acme.com"
     }],
     "playbook":"http://acme.com/myplaybook.html",
     "throttleIntervalSeconds":3600,
     "reportEnabled":true
    }'

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ตั้งค่าการแจ้งเตือนเวลาในการตอบสนองของเปอร์เซ็นไทล์ที่ 95 สำหรับพร็อกซี API โดยใช้ API

ตัวอย่างต่อไปนี้แสดงวิธีตั้งค่าการแจ้งเตือนที่จะแสดงขึ้นเมื่อเวลาในการตอบสนองของการตอบสนองโดยรวมสำหรับเปอร์เซ็นไทล์ที่ 95 มากกว่า 100 มิลลิวินาทีเป็นเวลา 5 นาทีสำหรับพร็อกซี API ของโรงแรมในสภาพแวดล้อมผลิตภัณฑ์สำหรับทุกภูมิภาค

ระบบจะส่งการแจ้งเตือนไปยังเว็บฮุคที่ระบุในเหตุการณ์ที่มีการเรียกให้แสดงการแจ้งเตือน

curl 'https://apimonitoring.enterprise.apigee.com/alerts' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
     "organization":"myorg",
     "name":"My Alert",
     "description":"My first alert",
     "environment":"prod",
     "enabled":true,
     "conditions":[
     {
        "description":"",
        "dimensions":{
            "org":"myorg", 
            "env":"prod",
            "proxy" : "hotels",
            "region":"ANY",
            "percentile":"95"
        },
        "metric":"totalLatency",
        "threshold":100,
        "durationSeconds":300,
        "comparator":">"
     }
     ],
     "notifications":[{ "channel":"webhook", "destination":"https://apigee.com/test-webhook"}],
     "playbook":"http://acme.com/myplaybook.html",
     "throttleIntervalSeconds":3600,
     "reportEnabled":true
}'

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ตั้งค่าการแจ้งเตือนรหัสสถานะ 404 (Application Not Found) สำหรับพร็อกซี API ทั้งหมดที่ใช้ API

ตัวอย่างต่อไปนี้แสดงวิธีตั้งค่าการแจ้งเตือนที่แสดงขึ้นเมื่อรหัสสถานะ HTTP 404 เกิดขึ้นในอัตราที่มากกว่า 10% เป็นเวลา 5 นาทีสำหรับพร็อกซี API ทั้งหมดในสภาพแวดล้อมผลิตภัณฑ์สำหรับทุกภูมิภาค

ระบบจะส่งการแจ้งเตือนไปยังช่อง Slack ที่ระบุเมื่อมีการทริกเกอร์การแจ้งเตือน

curl 'https://apimonitoring.enterprise.apigee.com/alerts' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
     "organization":"myorg",
     "name":"404 Application Not Found Alert",
     "description":"My 404 alert",
     "environment":"prod",
     "enabled":true,
     "conditions":[
     {
        "description":"",
        "dimensions":{"org":"myorg", 
            "env":"prod", 
            "proxy":"ALL",
            "region":"ANY",
            "statusCode":"404"},
        "metric":"rate",
        "threshold":0.05,
        "durationSeconds":300,
        "comparator":">"
     }],
     "notifications":[{ "channel":"slack", "destination":"https://hooks.slack.com/services/T00000000/B00000000/XXXXX"}],
     "playbook":"http://acme.com/myplaybook.html",
     "throttleIntervalSeconds":3600,
     "reportEnabled":true
}'

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ตั้งค่าการแจ้งเตือนจำนวนพร็อกซี API สำหรับ API โดยใช้ API

ตัวอย่างต่อไปนี้แสดงตัวอย่างวิธีตั้งค่าการแจ้งเตือนที่เรียกให้แสดงเมื่อจำนวนโค้ด 5xx ของ API มีค่าเกิน 200 เป็นเวลา 5 นาทีในทุกภูมิภาค

ในตัวอย่างนี้ API จะอยู่ในคอลเล็กชัน Critical API Proxies (โดยมี UUID aeff4394-86b7-11e8-83d7-42010a840040) หากต้องการรับ UUID สำหรับคอลเล็กชัน โปรดดูที่ดูคอลเล็กชันทั้งหมดที่ใช้ API

curl 'https://apimonitoring.enterprise.apigee.com/alerts' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
     "organization":"myorg",
     "name":"Proxy Count Alert",
     "description":"My proxy count alert",
     "environment":"prod",
     "enabled":true,
     "conditions":[
     {
        "description":"",
        "dimensions":{
            "collection":"aeff4394-86b7-11e8-83d7-42010a840040",
            "org":"myorg", 
            "env":"prod",
            "proxy" : "ANY",
            "region":"ANY",
            "statusCode":"5xx"
        },
        "metric":"count",
        "threshold":200,
        "durationSeconds":300,
        "comparator":">"
     }
     ],
     "notifications":[{ 
         "channel":"email", 
         "destination":"ops@acme.com"
     }],
     "playbook":"http://acme.com/myplaybook.html",
     "throttleIntervalSeconds":3600,
     "reportEnabled":true
    }'

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ตั้งค่าการแจ้งเตือนอัตราข้อผิดพลาดสำหรับบริการเป้าหมายโดยใช้ API

ตัวอย่างต่อไปนี้แสดงตัวอย่างวิธีตั้งค่าการแจ้งเตือนที่เรียกให้แสดงเมื่ออัตราโค้ด 500 สำหรับบริการเป้าหมายเกิน 10% เป็นเวลา 1 ชั่วโมงในทุกภูมิภาค

ในตัวอย่างนี้ บริการเป้าหมายจะได้รับการบันทึกไว้ในคอลเล็กชันเป้าหมายที่สำคัญ (มี UUID aeff4394-86b7-11e8-83d7-42010a840040) หากต้องการรับ UUID สำหรับคอลเล็กชัน โปรดดูที่ดูคอลเล็กชันทั้งหมดที่ใช้ API

curl 'https://apimonitoring.enterprise.apigee.com/alerts' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
     "organization":"myorg",
     "name":"Error rate Alert",
     "description":"My error rate alert",
     "environment":"prod",
     "enabled":true,
     "conditions":[
     {
        "description":"",
        "dimensions":{
            "collection":"aeff4394-86b7-11e8-83d7-42010a840040",
            "org":"myorg", 
            "env":"prod",
            "proxy" : "ANY",
            "region":"ANY",
            "statusCode":"500"
        },
        "metric":"rate",
        "threshold":0.1,
        "durationSeconds":3600,
        "comparator":">"
     }
     ],
     "notifications":[{ 
         "channel":"email", 
         "destination":"ops@acme.com"
     }],
     "playbook":"http://acme.com/myplaybook.html",
     "throttleIntervalSeconds":3600,
     "reportEnabled":true
    }'

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ตั้งค่าการแจ้งเตือนอัตราข้อผิดพลาดสำหรับนโยบายคำขอราคาเสนอบริการโดยใช้ API

ตัวอย่างต่อไปนี้แสดงตัวอย่างวิธีตั้งค่าการแจ้งเตือนที่จะแสดงผลเมื่ออัตราโค้ด 500 สำหรับบริการที่ระบุโดยนโยบาย Service callout เกิน 10% สําหรับ 1 ชั่วโมงสําหรับภูมิภาคใดๆ

curl 'https://apimonitoring.enterprise.apigee.com/alerts' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
     "organization":"myorg",
     "name":"Error rate Alert",
     "description":"My error rate alert",
     "environment":"prod",
     "enabled":true,
     "conditions":[
     {
        "description":"",
        "dimensions":{
            "target": "sc://docstore-api",
            "org":"myorg", 
            "env":"prod",
            "proxy" : "ANY",
            "region":"ANY",
            "statusCode":"500"
        },
        "metric":"rate",
        "threshold":0.1,
        "durationSeconds":3600,
        "comparator":">"
     }
     ],
     "notifications":[{ 
         "channel":"email", 
         "destination":"ops@acme.com"
     }],
     "playbook":"http://acme.com/myplaybook.html",
     "throttleIntervalSeconds":3600,
     "reportEnabled":true
    }'

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ตั้งค่าการแจ้งเตือนรหัสข้อผิดพลาดของนโยบายโดยใช้ API

ตัวอย่างต่อไปนี้แสดงวิธีตั้งค่าการแจ้งเตือนที่จะแสดงขึ้นเมื่อตรงกับเงื่อนไขข้อใดข้อหนึ่งต่อไปนี้

  • จำนวนรหัสข้อผิดพลาดของ SpikeArrestViolation มากกว่า 10 สำหรับ 5 นาทีสำหรับ API ในสภาพแวดล้อมการผลิตสำหรับทุกภูมิภาค
  • จำนวนรหัสข้อผิดพลาดของโปรโตคอล API ทั้งหมดสูงกว่า 3% เป็นเวลา 5 นาทีสำหรับ API ในสภาพแวดล้อมผลิตภัณฑ์สำหรับทุกภูมิภาค

ในตัวอย่างนี้ API จะอยู่ในคอลเล็กชัน Critical API Proxies (โดยมี UUID aeff4394-86b7-11e8-83d7-42010a840040) หากต้องการรับ UUID สำหรับคอลเล็กชัน โปรดดูที่ดูคอลเล็กชันทั้งหมดที่ใช้ API

ระบบจะส่งการแจ้งเตือนไปยังรหัส PagerDuty ที่ระบุเมื่อมีการทริกเกอร์การแจ้งเตือน

curl 'https://apimonitoring.enterprise.apigee.com/alerts' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
     "organization":"myorg",
     "name":"My Fault Code Alert",
     "description":"My fault code alert",
     "environment":"prod",
     "enabled":true,
     "conditions":[
     {
        "description":"",
        "dimensions": { 
            "collection":"aeff4394-86b7-11e8-83d7-42010a840040",
            "org":"myorg",
            "env":"prod",
            "proxy":"ANY",
            "region":"ANY",
            "faultCodeCategory":"Traffic Mgmt Policy",
            "faultCodeSubCategory":"Spike Arrest",
            "faultCodeName":"SpikeArrest Violation"
        },
        "metric":"count,
        "threshold":10,
        "durationSeconds":300,
        "comparator":">"
     },
     {
       "description":"",
       "dimensions": { 
           "collection":"aeff4394-86b7-11e8-83d7-42010a840040",
           "org":"myorg",
           "env":"prod",
           "proxy":"ANY",
           "region":"ANY",
           "faultCodeCategory":"API Protocol",
           "faultCodeSubCategory":"ALL"
       },
       "metric":"rate",
       "threshold":0.03,
       "durationSeconds":300,
       "comparator":">"
     }   
     ],
     "notifications":[{ "channel":"pagerduty", "destination":"abcd1234efgh56789"}],
     "playbook":"http://acme.com/myplaybook.html",
     "throttleIntervalSeconds":3600,
     "reportEnabled":true
}'

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ดูการแจ้งเตือน

ส่วนต่อไปนี้จะแสดงตัวอย่างการดูคำจำกัดความของการแจ้งเตือนและข้อมูลเกี่ยวกับการแจ้งเตือนที่ทริกเกอร์โดยใช้ API

ดูคำจำกัดความการแจ้งเตือนทั้งหมดขององค์กร

ดูคำจำกัดความของการแจ้งเตือนทั้งหมดโดยการส่งคำขอ GET ไปยัง API ต่อไปนี้ https://apimonitoring.enterprise.apigee.com/alerts

คุณต้องส่งชื่อองค์กรโดยใช้พารามิเตอร์การค้นหา org

เช่น

curl 'https://apimonitoring.enterprise.apigee.com/alerts?org=myorg'
    -X GET
    -H 'Accept: application/json, text/plain, */*'
    -H "Authorization: Bearer $ACCESS_TOKEN"    

UUID ของการแจ้งเตือนจะแสดงในช่อง uuid ของการตอบกลับ คุณต้องใช้ UUID นี้เพื่อทำการเรียกเพื่อระบุข้อมูลเฉพาะสำหรับคำจำกัดความของการแจ้งเตือน ตัวอย่างการตอบกลับมีดังนี้

[ 
 {
    "uuid": "4fa49a87-3463023ea7c4",
    "name": "PublicAPI latency alert",
    "enabled": true,
    "description": "Public API Latency alerts, 90th %ile > 6secs for 5 minute window trigger this alert",
    "conditions": [
      {
        "uuid": "4fa49a87-3463023ea7c4",
        "description": "",
        "dimensions": {
          "env": "prod",
          "org": "myorg",
          "percentile": "90",
          "proxy": "PublicAPI",
          "region": "ANY"
        },
        "metric": "totalLatency",
        "threshold": 6000,
        "durationSeconds": 300,
        "comparator": ">",
        "updatedBy": "me@foo.com"
      }
    ],
    "playbook": "PublicAPI Latency alert, setup to go off when 90th %ile is > 4 secs for 5 minute window",
    "throttleIntervalSeconds": 3600,
    "self": "/alerts/4fa49a87-3463023ea7c4",
    "feed": "/o/myorg/events/4fa49a87-3463023ea7c4",
    "organization": "myorg",
    "environment": "prod",
    "notifications": [
      {
        "channel": "email",
        "destination": "me@foo.com"
      }
    ],
    "updatedAt": "2018-07-19T18:19:31.654738Z",
    "updatedBy": "me@foo.com"
  },
  {
    "uuid": "ef1a5249-345ed3023ea7c4",
    "name": "Minty API Latency alert",
    "enabled": true,
    "description": "Minty API Latency alerts, 90th %ile > 6secs for 5 minute window trigger this alert",
    "conditions": [
      {
        "uuid": "ef1a5249-345ed3023ea7c4",
        "description": "",
        "dimensions": {
          "env": "prod",
          "org": "myorg",
          "percentile": "90",
          "proxy": "minty",
          "region": "ANY"
        },
        "metric": "totalLatency",
        "threshold": 6000,
        "durationSeconds": 300,
        "comparator": ">",
        "updatedBy": "me@foo.com"
      }
    ],
    "playbook": "Minty API",
    "throttleIntervalSeconds": 3600,
    "self": "/alerts/ef1a5249-345ed3023ea7c4",
    "feed": "/o/myorg/events/ef1a5249-345ed3023ea7c4",
    "organization": "myorg",
    "environment": "prod",
    "notifications": [
      {
        "channel": "email",
        "destination": "me@foo.com"
      }
    ],
    "updatedAt": "2018-07-19T18:19:33.22479Z",
    "updatedBy": "me@foo.com"
  },
 ...
]

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ดูคำจำกัดความของการแจ้งเตือนที่เจาะจง

ดูคำจำกัดความของการแจ้งเตือนที่เฉพาะเจาะจงโดยการส่งคำขอ GET ไปยังทรัพยากรต่อไปนี้ https://apimonitoring.enterprise.apigee.com/alerts/alert_uuid เมื่อ alert_uuid ระบุ UUID ของคำจำกัดความการแจ้งเตือน รับ UUID เมื่อคุณสร้างการแจ้งเตือนหรือใช้การเรียก API ที่แสดงในส่วนก่อนหน้าเพื่อแสดงการแจ้งเตือนทั้งหมดและ UUID ที่เกี่ยวข้อง

เช่น

curl 'https://apimonitoring.enterprise.apigee.com/alerts/4fa49a87-3463023ea7c4'
    -X GET
    -H 'Accept: application/json, text/plain, */*'
    -H "Authorization: Bearer $ACCESS_TOKEN"    

ตัวอย่างการตอบกลับมีดังนี้

  {
    "uuid": "4fa49a87-3463023ea7c4",
    "name": "PublicAPI latency alert",
    "enabled": true,
    "description": "Public API Latency alerts, 90th %ile > 6secs for 5 minute window trigger this alert",
    "conditions": [
      {
        "uuid": "4fa49a87-3463023ea7c4",
        "description": "",
        "dimensions": {
          "env": "prod",
          "org": "myorg",
          "percentile": "90",
          "proxy": "PublicAPI",
          "region": "ANY"
        },
        "metric": "totalLatency",
        "threshold": 6000,
        "durationSeconds": 300,
        "comparator": ">",
        "updatedBy": "me@foo.com"
      }
    ],
    "playbook": "PublicAPI Latency alert, setup to go off when 90th %ile is > 4 secs for 5 minute window",
    "throttleIntervalSeconds": 3600,
    "self": "/alerts/4fa49a87-3463023ea7c4",
    "feed": "/o/myorg/events/4fa49a87-3463023ea7c4",
    "organization": "myorg",
    "environment": "prod",
    "notifications": [
      {
        "channel": "email",
        "destination": "me@foo.com"
      }
    ],
    "updatedAt": "2018-07-19T18:19:31.654738Z",
    "updatedBy": "me@foo.com"
  }

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ดูประวัติการแจ้งเตือนที่ทริกเกอร์ทั้งหมดสำหรับองค์กร

ดูประวัติการแจ้งเตือนทั้งหมดที่ทริกเกอร์สำหรับองค์กรโดยการส่งคำขอ GET ไปยังทรัพยากรต่อไปนี้ https://apimonitoring.enterprise.apigee.com/metrics/alerthistory

คุณต้องส่งชื่อองค์กรโดยใช้พารามิเตอร์การค้นหา org คุณสามารถระบุระยะเวลาที่ใช้ค้นหาการแจ้งเตือนที่เรียกใช้ได้ ค่าเริ่มต้นคือแสดงการแจ้งเตือนทั้งหมด ที่ทริกเกอร์ในชั่วโมงที่ผ่านมา

เช่น

curl 'https://apimonitoring.enterprise.apigee.com/metrics/alerthistory?org=myorg'
    -X GET
    -H 'Accept: application/json, text/plain, */*'
    -H "Authorization: Bearer $ACCESS_TOKEN"    

การตอบกลับจะประกอบด้วยอาร์เรย์ของการแจ้งเตือนทั้งหมดที่ทริกเกอร์ในระยะเวลาที่ขอ ในเนื้อหาการตอบกลับ ช่อง id จะระบุ UUID ของการแจ้งเตือนที่ทริกเกอร์ และช่อง shared_id จะระบุ UUID ของคำจำกัดความการแจ้งเตือนที่เชื่อมโยงกับการแจ้งเตือนที่ทริกเกอร์

ต่อไปนี้เป็นตัวอย่างคำตอบ

[
  {
    "id": "80cbe560-f6e0-475c6f7ed2d",
    "shared_id": "4fa49a87-3463023ea7c4",
    "organization": "myorg",
    "environment": "prod",
    "name": "PublicAPI latency alert",
    "type": "Alert",
    "source": "null/current",
    "raw_payload": "{\"reportUUID\":\"\",\"reportEnabled\":false,\"organization\":\"myorg\",\"name\":\"emgmt-api 404\",\"self\":\"/alerts/4fa49a87-3463023ea7c4\",\"description\":\"go/apigee-extensions-playbook\",\"conditions\":[
  {\"comparator\":\">\",\"metric\":\"rate\",\"durationSeconds\":300,\"name\":\"PublicAPI latency alert\",\"description\":\"\",\"threshold\":0.05,\"dimensions\":{\"proxy\":\"emgmt-api\",\"org\":\"myorg\",\"env\":\"prod\",\"region\":\"any\",\"statusCode\":\"404\"}}],\"uuid\":\"4fa49a87-3463023ea7c4\",\"playbook\":\"go/apigee-extensions-playbook\"}",
    "time": "2019-03-25T15:30:18Z"
  },
  {
    "id": "8131d740-6680-45b9c72c3",
    "shared_id": "1a64885b-f9-42010a850039",
    "organization": "apigee-pinpoint",
    "environment": "prod",
    "name": "Demo 5xx alert",
    "type": "Alert",
    "source": "null/current",
    "raw_payload": "{\"reportUUID\":\"\",\"reportEnabled\":false,\"organization\":\"myorg\",\"name\":\"Demo 5xx alert\",\"self\":\"/alerts/1a64885b-f9-42010a850039\",\"description\":\"Demo 5xx alert\",\"conditions\":[
  {\"comparator\":\">\",\"metric\":\"rate\",\"durationSeconds\":300,\"name\":\"Demo 5xx alert\",\"description\":\"\",\"threshold\":0.4,\"dimensions\":{\"proxy\":\"ALL\",\"org\":\"myorg\",\"env\":\"prod\",\"region\":\"any\",\"statusCode\":\"5xx\"}}],\"uuid\":\"1a64885b-f9-42010a850039\",\"playbook\":\"Recommended Playbook\"}",
    "time": "2019-03-25T15:57:30Z"
  },
 ...
]

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL

ดูประวัติการแจ้งเตือนที่ต้องการ

ดูประวัติการแจ้งเตือนที่ทริกเกอร์เพื่อดูคำจำกัดความของการแจ้งเตือนที่เฉพาะเจาะจงโดยการส่งคำขอ GET ไปยังทรัพยากรต่อไปนี้ https://apimonitoring.enterprise.apigee.com/metrics/alerthistory

คุณต้องส่งชื่อองค์กรโดยใช้พารามิเตอร์การค้นหา org และ UUID ของคําจํากัดความการแจ้งเตือน คุณสามารถเลือกระบุระยะเวลา ที่ใช้ค้นหาการแจ้งเตือน ค่าเริ่มต้นคือแสดงการแจ้งเตือนทั้งหมดที่ถูกเรียกในชั่วโมงที่ผ่านมา

คุณสามารถดู UUID ของคำนิยามการแจ้งเตือน ได้จากประวัติการแจ้งเตือนที่แสดงในส่วนก่อนหน้า เมื่อสร้างการกำหนดการแจ้งเตือน หรือใช้การเรียก API ที่แสดงในดูคำจำกัดความการแจ้งเตือนทั้งหมด

เช่น

curl 'https://apimonitoring.enterprise.apigee.com/metrics/alerthistory?org=myorg&alertId=4fa49a87-3463023ea7c4'
    -X GET
    -H 'Accept: application/json, text/plain, */*'
    -H "Authorization: Bearer $ACCESS_TOKEN"    

การตอบสนองจะมีอาร์เรย์ของการแจ้งเตือนทั้งหมดที่ทริกเกอร์ในช่วงเวลาที่ขอสำหรับ UUID ของคำนิยามการแจ้งเตือนที่ระบุ ในเนื้อหาการตอบกลับ ช่อง id จะระบุ UUID ของการแจ้งเตือนที่ทริกเกอร์ และช่อง shared_id จะระบุ UUID ของคำจำกัดความการแจ้งเตือนที่เชื่อมโยงกับการแจ้งเตือนที่ทริกเกอร์

ต่อไปนี้เป็นตัวอย่างคำตอบ

[
  {
    "id": "80cbe560-f6e0-475c6f7ed2d",
    "shared_id": "4fa49a87-3463023ea7c4",
    "organization": "myorg",
    "environment": "prod",
    "name": "PublicAPI latency alert",
    "type": "Alert",
    "source": "null/current",
    "raw_payload": "{\"reportUUID\":\"\",\"reportEnabled\":false,\"organization\":\"myorg\",\"name\":\"emgmt-api 404\",\"self\":\"/alerts/4fa49a87-3463023ea7c4\",\"description\":\"go/apigee-extensions-playbook\",\"conditions\":[
  {\"comparator\":\">\",\"metric\":\"rate\",\"durationSeconds\":300,\"name\":\"PublicAPI latency alert\",\"description\":\"\",\"threshold\":0.05,\"dimensions\":{\"proxy\":\"emgmt-api\",\"org\":\"myorg\",\"env\":\"prod\",\"region\":\"any\",\"statusCode\":\"404\"}}],\"uuid\":\"4fa49a87-3463023ea7c4\",\"playbook\":\"go/apigee-extensions-playbook\"}",
    "time": "2019-03-25T15:30:18Z"
  },
  {
    "id": "9fc442d5-d607-40ef118c4e7",
    "shared_id": "4fa49a87-3463023ea7c4",
    "organization": "myorg",
    "environment": "prod",
    "name": "PublicAPI latency alert",
    "type": "Alert",
    "source": "null/current",
    "raw_payload": "{\"reportUUID\":\"\",\"reportEnabled\":false,\"organization\":\"myorg\",\"name\":\"emgmt-api 404\",\"self\":\"/alerts/4fa49a87-3463023ea7c4\",\"description\":\"go/apigee-extensions-playbook\",\"conditions\":[{\"comparator\":\">\",\"metric\":\"rate\",\"durationSeconds\":300,\"name\":\"PublicAPI latency alert\",\"description\":\"\",\"threshold\":0.05,\"dimensions\":{\"proxy\":\"emgmt-api\",\"org\":\"myorg\",\"env\":\"prod\",\"region\":\"any\",\"statusCode\":\"404\"}}],\"uuid\":\"4fa49a87-3463023ea7c4\",\"playbook\":\"go/apigee-extensions-playbook\"}",
    "time": "2019-03-25T15:17:55Z"
  },
 ...
]

ตั้งค่า $ACCESS_TOKEN เป็นโทเค็นเพื่อการเข้าถึง OAuth 2.0 ตามที่อธิบายไว้ในหัวข้อรับโทเค็นเพื่อการเข้าถึง OAuth 2.0

ดูข้อมูลเกี่ยวกับตัวเลือก cURL ที่ใช้ในตัวอย่างนี้ได้ที่ใช้ cURL