JSFiddle - React, Tailwind, and code Playground

by eurica

HTML

<script src="https://eurica.github.io/pdjs/js/pdjs.js"></script>
Press Run to trigger an incident.

JavaScript

// Set up the library
PDJS = new PDJSobj()

trigger = function() {
  // Trigger via the rest API
  PDJS.trigger({
    service_key: "777e2001c60448fd8c327c4958bfc460",
    incident_key: "manual_incident_" + Math.random(),
    description: "API Performance regressed on path:api/cart/checkout",
    "client": "Datadog",
    "client_url": "https://app.datadoghq.com/",
    "details": {
      "body": "@acme-API_Performance_Regression Investigate any recent deploys that may have caused this regression. `pct_change(avg(last_4h),last_1d):avg:web_api.duration.median{production,web-app,!action:destroy,!action:create,!action:update,!controller:reports,!api_version:mobile,!api_version:beta,!action:send_test_notification} by {path}.rollup(avg, 900) > 20` Metric value: 15.116",
      "priority": "normal",
      "query": "pct_change(avg(last_4h),last_1d):avg:web_api.duration.median{production,web-app,!action:destroy,!action:create,!action:update,!controller:reports,!api_version:mobile,!api_version:beta,!action:send_test_notification} by {path}.rollup(avg, 900) > 20",
      "event_type": "query_alert_monitor",
      "event_id": "3111246090632961133",
      "org": "Acme, Inc.",
      "tags": "action:create, action:destroy, action:send_test_notification, production, web-app",
      "user": null
    },
    contexts: [{
      type: "image",
      src: "https://euri.ca/files/datadog.png"
    }, {
      type: "link",
      href: "tel:14158057070",
      text: "Conference Call"
    }, {
      type: "link",
      href: "skype:14158057070",
      text: "(Skype) Call"
    }]
  })
}

trigger();