Hey everyone, I have Postman monitors running for a collection for 50 endpoints running every 15 minutes. I also use StatusPage for displaying API uptime for public users. Is there a way I can integrate the two? It seems logical but I wasn’t able to see any resources on this.
Initially, I wanted to send updates to StatusPage using their API but I’m not sure how I can do it. I thought I could use the “pre-request script” and “Tests” at the folder level, but I misunderstood “This script will execute before every request in this folder” to means for all requests and not each request in the folder.
Does anyone have a working implementation or ideas to support this?
I was able to figure out a solution to this. Some key factors:
organize requests under folders where each folder effectively maps to a StatusPage component Id
in the pre-request for each folder, define current_folder_name using the pm.varaibles
in the tests for each folder, define previous_folder_name using the current folder name in pm.variables
Define a utilize pm.variables wherever you run your tests (200 status check) to store an object test_tracker which maps the folder name to another object containing the total_count and the failed_count for you requests. You have to use JSON stringify and parse here. I’m only testing for 200 status.
update test_tracker when the tests run and fail.
In the collections Tests, this is where the real magic happens. Everything so far has been variable setup.
Use the current_folder_name and previous_folder_name to determine change, or precisely when we’ve completed testing all requests for an endpoint.
When a change is detected, we compare values in the test_tracker object against the previous_current_folder to determine what status we want to use.
Determine the status. Fail == count: major outage, fail == 0: operational, fail > 0: partial outage
Execute a pm.sendRequest to the statuspage API and update the component status.
Extra: Store an environmental variable that contains status of our components to avoid additional updates. This might get tricky though.