Here's a quick way to monitor a status page hosted by incident.io with New Relic. Specifically, I'll be using Synthetic monitoring to achieve this with a Scripted API test.
After digging a bit, it looks like data from a typical public status page hosted by incident.io is in this format: https://status.incident.io/proxy/statuspage-name
When you go to this page, you'll get something that looks like this:
Since this is structured JSON data, we can format this and ingest this data as an event in New Relic. Here's the full script
You can also find this here:
https://github.com/pnvnd/nodejs-synthetics/blob/main/scripted_api/incidentio.js
Or check it out here:
const got = require('got');
const statuspage = 'my-statuspage'
const account_id = $secure.ACCOUNT_ID
const ingest_key = $secure.INGEST_KEY
async function getStatusPage() {
const url = `https://status.incident.io/proxy/${statuspage}`;
let resp = await got(url);
if (resp.statusCode == 200) {
let data = JSON.parse(resp.body);
// Create a map for quick lookup of affected components by component_id
let affectedComponentsMap = {};
for (let affected of data.summary.affected_components) {
affectedComponentsMap[affected.component_id] = affected.status;
}
// Update components with status if they are affected
for (let component of data.summary.components) {
component["eventType"] = "IncidentIOSample";
component["statuspage"] = `${statuspage}`;
component["status"] = affectedComponentsMap[component.id] || "operational";
}
got.post(`https://insights-collector.newrelic.com/v1/accounts/${account_id}/events`, {
headers: {
'Api-Key': `${ingest_key}`,
'Content-Type': 'application/json'
},
json: data.summary.components
});
console.log(data.summary.components)
} else {
console.log(resp.body);
}
};
getStatusPage();
Validate the script is working in New Relic then click Save.
Let the synthetic monitor run for a bit and check the data. Using NRQL, you can query your data with something like this:
SELECT * FROM IncidentIOSample
Another way of looking at this data is to view by component name:
SELECT latest(status)
FROM IncidentIOSample
WHERE statuspage='my-statuspage'
FACET name
Now that you have this data in New Relic, you can create alerts and stay on top of incidents hosted by public incident.io status pages.
Top comments (0)