Sam Aybar joined Runscope in 2016, prior to its acquisition by CA Technologies. He was responsible for everything from pre-sales engineering through post-sales customer success as well as support. He is currently a member of the customer-facing engineering team.

Become a JMeter and Continuous Testing Pro

Start Learning
Slack

Test Your Website Performance NOW! |

arrowPlease enter a URL with http(s)
Sep 23 2020

Updating a StatusPage Component with Webhook Listeners

In my previous post, I covered how to get started with building a webhook listener with BlazeMeter API Monitoring. Perhaps in addition to a custom Slack notification, you also want to update your StatusPage when your API goes down. While BlazeMeter API Monitoring has a built in integration with StatusPage for tracking metrics, it doesn’t have one for declaring incidents or modifying components. Because BlazeMeter API Monitoring allows us to string together API requests, we can easily add this functionality to our custom notification test.

 

To do this, we will create a new test to modify StatusPage, using the StatusPage APIs. You will need to retrieve your StatusPage API Key and PageID from StatusPage on the API info tab.

 

 

If you want to update a specific component in StatusPage you will also need the Component ID for that component. This can be found within the URL of the edit page for the component.

 

 

With this information in hand, we can create our new test.

 


 

In the environment for the test, we need to set initial variables with the PageID and (optionally) the Component ID.

 

 

 

We also need to set up an environment header with the API Key.

 

 

Now we can add request steps to our test. The first step will make a POST request to the StatusPage endpoint to create an incident -- https://api.statuspage.io/v1/pages/{{pageId}}/incidents

 

You can review documentation for more details, but the body of the post requests could be something like:

 

{

"incident": {

"name": "{{customText}}",

"status": "investigating",

"body": "We are investigating a degradatation in service. We will provide more information as soon as available."

}

}

 

 

The second step of this step will (optionally) update a specific component, using a PATCH requests to https://api.statuspage.io/v1/pages/{{pageId}}/components/{{componentId}}

 

A sample for this body might look like:

 

{

"component": {

"status": "degraded_performance"

}

}

 

 

We now have a two step test that will create an incident and update a specific component.

 

 

We can return to the original CustomSlackNotifier test and add a Subtest step to call the StatusPage Update test. If we embed it in the Condition step, we can ensure it fires only when the underlying test fails.

 

Be sure to select to use the StatusPage Update test’s environment in the subtest. Also be sure to pass your {{customText}} variable as a parameter to the subtest.


 



 

If you now return to your original test that is monitoring your API and run it, it will trigger this custom notification test upon completion. In case of a failure, it will go on to make your custom Slack notification and post an update to StatusPage.

 

 

As indicated earlier in this article, if you are going to use something like this in production, you might want to set up a more advanced notification profile, such that you only trigger this custom update after several failures. We can do this using Advanced Webhooks on the Connected Services page.

 

 

You will want to create two Advanced webhooks, one corresponding to the Trigger URL for the custom notification test, and another corresponding to the fixed inbound URL in the first step of that test. You should then enable both of those integrations in the environment for any test you want to trigger your custom notification service after consecutive failures.

 

Ready to get started with testing? Sign in to your BlazeMeter account, or put your URL in the box below.

   
arrowPlease enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!