Chilkat Online Tools

Node.js / Squadcast API V3 / Get Incident Events

Back to Collection Items

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}


function chilkatExample() {

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var http = new chilkat.Http();
    var success;

    var queryParams = new chilkat.JsonObject();
    queryParams.UpdateInt("offset",1);
    queryParams.UpdateInt("limit",10);
    queryParams.UpdateString("sort","asc");
    queryParams.UpdateString("deduped","true");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.AuthToken = "<access_token>";

    // resp: HttpResponse
    var resp = http.QuickRequestParams("GET","https://api.squadcast.com/v3/incidents/:incidentID/events",queryParams);
    if (http.LastMethodSuccess == false) {
        console.log(http.LastErrorText);
        return;
    }

    console.log(resp.StatusCode);
    console.log(resp.BodyStr);


}

chilkatExample();

Curl Command

curl -G -d "offset=1"
	-d "limit=10"
	-d "sort=asc"
	-d "deduped=true"
	-H "Authorization: Bearer <access_token>"
https://api.squadcast.com/v3/incidents/:incidentID/events

Postman Collection Item JSON

{
  "name": "Get Incident Events",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{sq_pb_auth_header}}",
          "type": "string"
        }
      ]
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/incidents/:incidentID/events?offset=1&limit=10&sort=asc&deduped=true",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "incidents",
        ":incidentID",
        "events"
      ],
      "query": [
        {
          "key": "offset",
          "value": "1",
          "description": "non zero value"
        },
        {
          "key": "limit",
          "value": "10",
          "description": "non zero value, maximum is 10"
        },
        {
          "key": "sort",
          "value": "asc",
          "description": "sort it by either asc or desc"
        },
        {
          "key": "deduped",
          "value": "true",
          "description": "if set to true, it will return only the deduped events.\n\nif set to false, it will return only the non-deduped event.\n\notherwise it will return all the events"
        }
      ],
      "variable": [
        {
          "key": "incidentID",
          "value": "5d81d9bc60e42f6b99ca4307"
        }
      ]
    },
    "description": "- This endpoint is used to get all the deduped incident events details by either ID or number.\n- Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header.\n\nQuery Params:\n```\noffset - non zero value\nlimit - non zero value, maximum is 10\nsort - sort it by either asc or desc\ndeduped - if set to true, it will return only the deduplicated events. if set to false, it will return only the non-deduplicated event, otherwise it will return all the events\n```"
  },
  "response": [
    {
      "name": "200 OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/incidents/:incidentID/events?offset=1&limit=10&sort=asc&deduped=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "incidents",
            ":incidentID",
            "events"
          ],
          "query": [
            {
              "key": "offset",
              "value": "1"
            },
            {
              "key": "limit",
              "value": "10"
            },
            {
              "key": "sort",
              "value": "asc"
            },
            {
              "key": "deduped",
              "value": "true"
            }
          ],
          "variable": [
            {
              "key": "incidentID",
              "value": "5f6480a22379e9c06df6a32e"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n  \"data\": {\n    \"events\": [\n      {\n        \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n        \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n        \"message\": \"Memory out of set threshold : 70.1%\",\n        \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n        \"time_of_creation\": \"2020-09-18T09:41:02.721Z\",\n        \"tags\": null,\n        \"deduplication_reason\": {\n          \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n          \"evaluated_expression\": \"true\",\n          \"time_window\": 3600\n        },\n        \"payload\": {\n          \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n          \"event_id\": \"6\",\n          \"message\": \"Memory out of set threshold : 70.1%\",\n          \"metric\": {\n            \"absolute\": {\n              \"current_value\": 1.402,\n              \"threshold\": 1.4,\n              \"unit\": \"GB\"\n            },\n            \"pod\": \"platform-d23ixi-ug5ty\",\n            \"relative\": {\n              \"current_value\": 70.1,\n              \"threshold\": 70\n            },\n            \"time\": \"2020-09-18T09:37:13.607Z\"\n          },\n          \"status\": \"trigger\"\n        }\n      },\n      {\n        \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n        \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n        \"message\": \"Memory out of set threshold : 70.1%\",\n        \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n        \"time_of_creation\": \"2020-09-18T09:41:02.401Z\",\n        \"tags\": null,\n        \"deduplication_reason\": {\n          \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n          \"evaluated_expression\": \"true\",\n          \"time_window\": 3600\n        },\n        \"payload\": {\n          \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n          \"event_id\": \"6\",\n          \"message\": \"Memory out of set threshold : 70.1%\",\n          \"metric\": {\n            \"absolute\": {\n              \"current_value\": 1.402,\n              \"threshold\": 1.4,\n              \"unit\": \"GB\"\n            },\n            \"pod\": \"platform-d23ixi-ug5ty\",\n            \"relative\": {\n              \"current_value\": 70.1,\n              \"threshold\": 70\n            },\n            \"time\": \"2020-09-18T09:37:13.607Z\"\n          },\n          \"status\": \"trigger\"\n        }\n      },\n      {\n        \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n        \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n        \"message\": \"Memory out of set threshold : 70.1%\",\n        \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n        \"time_of_creation\": \"2020-09-18T09:41:02.088Z\",\n        \"tags\": null,\n        \"deduplication_reason\": {\n          \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n          \"evaluated_expression\": \"true\",\n          \"time_window\": 3600\n        },\n        \"payload\": {\n          \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n          \"event_id\": \"6\",\n          \"message\": \"Memory out of set threshold : 70.1%\",\n          \"metric\": {\n            \"absolute\": {\n              \"current_value\": 1.402,\n              \"threshold\": 1.4,\n              \"unit\": \"GB\"\n            },\n            \"pod\": \"platform-d23ixi-ug5ty\",\n            \"relative\": {\n              \"current_value\": 70.1,\n              \"threshold\": 70\n            },\n            \"time\": \"2020-09-18T09:37:13.607Z\"\n          },\n          \"status\": \"trigger\"\n        }\n      },\n      {\n        \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n        \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n        \"message\": \"Memory out of set threshold : 70.1%\",\n        \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n        \"time_of_creation\": \"2020-09-18T09:41:01.769Z\",\n        \"tags\": null,\n        \"deduplication_reason\": {\n          \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n          \"evaluated_expression\": \"true\",\n          \"time_window\": 3600\n        },\n        \"payload\": {\n          \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n          \"event_id\": \"6\",\n          \"message\": \"Memory out of set threshold : 70.1%\",\n          \"metric\": {\n            \"absolute\": {\n              \"current_value\": 1.402,\n              \"threshold\": 1.4,\n              \"unit\": \"GB\"\n            },\n            \"pod\": \"platform-d23ixi-ug5ty\",\n            \"relative\": {\n              \"current_value\": 70.1,\n              \"threshold\": 70\n            },\n            \"time\": \"2020-09-18T09:37:13.607Z\"\n          },\n          \"status\": \"trigger\"\n        }\n      },\n      {\n        \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n        \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n        \"message\": \"Memory out of set threshold : 70.1%\",\n        \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n        \"time_of_creation\": \"2020-09-18T09:41:01.454Z\",\n        \"tags\": null,\n        \"deduplication_reason\": {\n          \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n          \"evaluated_expression\": \"true\",\n          \"time_window\": 3600\n        },\n        \"payload\": {\n          \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n          \"event_id\": \"6\",\n          \"message\": \"Memory out of set threshold : 70.1%\",\n          \"metric\": {\n            \"absolute\": {\n              \"current_value\": 1.402,\n              \"threshold\": 1.4,\n              \"unit\": \"GB\"\n            },\n            \"pod\": \"platform-d23ixi-ug5ty\",\n            \"relative\": {\n              \"current_value\": 70.1,\n              \"threshold\": 70\n            },\n            \"time\": \"2020-09-18T09:37:13.607Z\"\n          },\n          \"status\": \"trigger\"\n        }\n      },\n      {\n        \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n        \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n        \"message\": \"Memory out of set threshold : 70.1%\",\n        \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n        \"time_of_creation\": \"2020-09-18T09:41:01.091Z\",\n        \"tags\": null,\n        \"deduplication_reason\": {\n          \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n          \"evaluated_expression\": \"true\",\n          \"time_window\": 3600\n        },\n        \"payload\": {\n          \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n          \"event_id\": \"6\",\n          \"message\": \"Memory out of set threshold : 70.1%\",\n          \"metric\": {\n            \"absolute\": {\n              \"current_value\": 1.402,\n              \"threshold\": 1.4,\n              \"unit\": \"GB\"\n            },\n            \"pod\": \"platform-d23ixi-ug5ty\",\n            \"relative\": {\n              \"current_value\": 70.1,\n              \"threshold\": 70\n            },\n            \"time\": \"2020-09-18T09:37:13.607Z\"\n          },\n          \"status\": \"trigger\"\n        }\n      },\n      {\n        \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n        \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n        \"message\": \"Memory out of set threshold : 70.1%\",\n        \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n        \"time_of_creation\": \"2020-09-18T09:41:00.689Z\",\n        \"tags\": null,\n        \"deduplication_reason\": {\n          \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n          \"evaluated_expression\": \"true\",\n          \"time_window\": 3600\n        },\n        \"payload\": {\n          \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n          \"event_id\": \"6\",\n          \"message\": \"Memory out of set threshold : 70.1%\",\n          \"metric\": {\n            \"absolute\": {\n              \"current_value\": 1.402,\n              \"threshold\": 1.4,\n              \"unit\": \"GB\"\n            },\n            \"pod\": \"platform-d23ixi-ug5ty\",\n            \"relative\": {\n              \"current_value\": 70.1,\n              \"threshold\": 70\n            },\n            \"time\": \"2020-09-18T09:37:13.607Z\"\n          },\n          \"status\": \"trigger\"\n        }\n      },\n      {\n        \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n        \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n        \"message\": \"Memory out of set threshold : 70.1%\",\n        \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n        \"time_of_creation\": \"2020-09-18T09:41:00.24Z\",\n        \"tags\": null,\n        \"deduplication_reason\": {\n          \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n          \"evaluated_expression\": \"true\",\n          \"time_window\": 3600\n        },\n        \"payload\": {\n          \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n          \"event_id\": \"6\",\n          \"message\": \"Memory out of set threshold : 70.1%\",\n          \"metric\": {\n            \"absolute\": {\n              \"current_value\": 1.402,\n              \"threshold\": 1.4,\n              \"unit\": \"GB\"\n            },\n            \"pod\": \"platform-d23ixi-ug5ty\",\n            \"relative\": {\n              \"current_value\": 70.1,\n              \"threshold\": 70\n            },\n            \"time\": \"2020-09-18T09:37:13.607Z\"\n          },\n          \"status\": \"trigger\"\n        }\n      },\n      {\n        \"incident_id\": \"5f6480a22379e9c06df6a32e\",\n        \"alert_source_id\": \"5e868c596b90eec3d4148737\",\n        \"message\": \"Memory out of set threshold : 70.1%\",\n        \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n        \"time_of_creation\": \"2020-09-18T09:40:59.689Z\",\n        \"tags\": null,\n        \"deduplication_reason\": {\n          \"matched_event_id\": \"5f6480a2b1bafb2fcccce904\",\n          \"evaluated_expression\": \"true\",\n          \"time_window\": 3600\n        },\n        \"payload\": {\n          \"description\": \"Memory usage of platform pod is above set threshold of 70%\\n\\nThreshold: 70%\\nCurrent usage: 70.1%\",\n          \"event_id\": \"6\",\n          \"message\": \"Memory out of set threshold : 70.1%\",\n          \"metric\": {\n            \"absolute\": {\n              \"current_value\": 1.402,\n              \"threshold\": 1.4,\n              \"unit\": \"GB\"\n            },\n            \"pod\": \"platform-d23ixi-ug5ty\",\n            \"relative\": {\n              \"current_value\": 70.1,\n              \"threshold\": 70\n            },\n            \"time\": \"2020-09-18T09:37:13.607Z\"\n          },\n          \"status\": \"trigger\"\n        }\n      }\n    ]\n  },\n  \"meta\": {\n    \"total\": 20,\n    \"count\": 10,\n    \"current\": \"https://api.squadcast.com/v3/incidents/5f6480a22379e9c06df6a32e/events?offset=0&limit=10&deduped=true\",\n    \"next\": \"https://api.squadcast.com/v3/incidents/5f6480a22379e9c06df6a32e/events?deduped=true&limit=10&offset=10\"\n  }\n}"
    },
    {
      "name": "401 Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/incidents/:incidentID/events?offset=1&limit=1",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "incidents",
            ":incidentID",
            "events"
          ],
          "query": [
            {
              "key": "offset",
              "value": "1"
            },
            {
              "key": "limit",
              "value": "1"
            }
          ],
          "variable": [
            {
              "key": "incidentID",
              "value": "5d81d9bc60e42f6b99ca4305"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n    \"meta\": {\n        \"status\": 401,\n        \"error_message\": \"<string>\"\n    }\n}"
    }
  ]
}