I have tried a lot of different possibilities but still have no answer for this. Initially, it was working and now, nothing.
I have made some modifications to the code included in the stock integration. It's fairly straightforward, when closing a Major Incident ticket in MAX, which has a currently open incident in StatusPage, it will set the incident to Resolved and then it should also update all of the associated components to also be Operational.
The first part works -- the Incident is set to resolved and is cleared from the list of open incidents in StatusPage. However, the components never actually update. I have tried sending the request with both PUT & PATCH verbs in the request, neither makes any difference.
Additionally, I can see, by looking in the activity log that I am infact sending the proper data and it is formatted properly as well. Below is my applicable code along with what is being sent to StatusPage.
var incident_number = content['Incident / Ticket Number'];
var incident_title = content['Incident Title / Summary'];
...
} else if (notification_type == 'CLOSURE') {
var statusPageData = statuspage.updateStatusPageIncident(incident_title, incident_number);
console.log(statusPageData);
}
exports.updateStatusPageIncident = function(incident_title, incidentNumber){
var statusPageData = this.getStatusPageIncident(incident_title);
var component_names = '';
var components = {};
var component_ids = [];
if (statusPageData === null) {
console.log('No StatusPage Incident was found');
return;
}
for(var i = 0; i < statusPageData.components.length; i++) {
var name = statusPageData.components[i].name;
component_names += name;
components[name] = 'operational';
component_ids.push(statusPageData.components[i].id);
if (i == (statusPageData.components.length - 2)) {
component_names += ' and ';
} else if (i < (statusPageData.components.length - 1)) {
component_names += ', ';
}
}
var msg = 'The issues with ' + component_names + " are now resolved.\n\nThank you for your patience.\n\nFURTHER INFO\n• MassMutual Enterprise Services, 800-767-1000 (ext. 44357).";
var incident = {};
incident.name = incident_title;
incident.body = msg;
incident.status = 'resolved';
incident.components = components;
incident.component_ids = component_ids;
var req = http.request({
'endpoint': 'StatusPage',
'method': 'PUT',
'path': '/incidents/' + statusPageData.id + '.json?api_key=' + constants['Status Page Token'],
'headers': {'Content-Type': 'application/json'}
});
var spJson = {}
spJson.incident = incident;
res = req.write(spJson);
}
exports.getStatusPageIncident = function(incident_title){
var req = http.request({
'endpoint': 'StatusPage',
'method': 'Get',
'path': '/incidents.json?api_key=' + constants["Status Page Token"],
'headers': {'Content-Type': 'application/json'}
}).write();
var res = JSON.parse(req.body);
var id = null;
for (var i = 0; i < res.length; i++) {
if (res[i].name == incident_title) {
id = res[i].id;
break;
}
}
if (id === null) {
// Incident not found. Break out of functions
return false;
}
// Grab the incident in question so we can update the status for both
// The incident as a whole as well as the various affected components.
var req = http.request({
'endpoint': 'StatusPage',
'method': 'Get',
'path': '/incidents/' + id + '.json?api_key=' + constants["Status Page Token"],
'headers': {'Content-Type': 'application/json'}
}).write();
var res = JSON.parse(req.body);
return res;
}
Example Payload Sent to StatusPage for UPDATING
{
"incident":{
"name":"INC12345test",
"body":"The issues with EZ-APP and Wealthscape are now resolved.\n\nThank you for your patience.\n\nFURTHER INFO\n���\tMassMutual Enterprise Services, 800-767-1000 (ext. 44357).",
"status":"resolved",
"components":{
"EZ-APP":"operational",
"Wealthscape":"operational"
},
"component_ids":[
"87x3fm03k5s3",
"k3zbmnr7vs1v"
]
}
}
Just to be extra careful and thorough, I ran another request in my browser for all of the components and confirmed that the above list of ID's present in the payload property, component_ids, are in fact valid ID's for the above named components. Is there some simple thing I am missing here, because I don't see it!
Comments
Please sign in to leave a comment.
Hi MassMutual team,
This may be a shot in the dark but doing some hunting on the StatusPage API site it does not look like a call to Incident can update a COMPONENT STATUS. I am thinking those are separate objects and after you make the call to update the incident you should make a separate call to update the component. Just add a function to update component and then call it based on the component ID and include the new status you want to update it to.
I found this that could help:
https://doers.statuspage.io/api/v0/components/
Looks like a PATCH call to just update the component status.
Let us know if this works!