Watching Github Status in Grafana

Github has had a number of failures in the last two weeks. It got to the point where I wanted $JOB to have something available to quickly see the health of Github’s services. Since we’re evaluating Grafana Cloud as a central monitoring/alerting/etc. hub for the company, and because I was fairly familiar with Grafana already, I thought it would be fairly easy to create a Github status panel in Grafana…

Step One: GithubStatus API

So first we need to know if we can collect status data from https://githubstatus.com with an API…and we can!

https://www.githubstatus.com/api/v2/summary.json returns the same front page you see as a JSON object. What’s great about this is Grafana has a data source for JSON APIs: https://github.com/marcusolsson/grafana-json-datasource. This will let us simply configure the API endpoint once and add it to as many panels as we need!

Step Two: The panel

The JSON API datasource supports JSONPath queries, so building a panel that simply shows the current state of Github should be easy. We just need the names of the Github components and their current state. Here’s the JSONPath queries we can use for that:

$.components[?(@.name!='Visit www.githubstatus.com for more information')].name
$.components[?(@.name!='Visit www.githubstatus.com for more information')].status

(We exclude a single key pair that is returned in the JSON that will just make the output look weird.)

So the final panel config looks like this:

{
  "id": 10,
  "gridPos": {
    "h": 11,
    "w": 6,
    "x": 18,
    "y": 0
  },
  "type": "table",
  "title": "Github Status",
  "datasource": {
    "uid": "rJeRj5Enz",
    "type": "marcusolsson-json-datasource"
  },
  "pluginVersion": "8.4.4",
  "description": "Data polled from https://www.githubstatus.com",
  "fieldConfig": {
    "defaults": {
      "custom": {
        "align": "center",
        "displayMode": "color-background"
      },
      "mappings": [
        {
          "options": {
            "operational": {
              "color": "green",
              "index": 0
            },
            "partial_outage": {
              "color": "yellow",
              "index": 1
            }
          },
          "type": "value"
        }
      ],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          }
        ]
      },
      "color": {
        "mode": "fixed"
      }
    },
    "overrides": []
  },
  "options": {
    "showHeader": true,
    "footer": {
      "show": false,
      "reducer": [
        "sum"
      ],
      "fields": ""
    },
    "frameIndex": 0,
    "sortBy": [
      {
        "desc": false,
        "displayName": "Component"
      }
    ]
  },
  "targets": [
    {
      "cacheDurationSeconds": 300,
      "datasource": {
        "type": "marcusolsson-json-datasource",
        "uid": "rJeRj5Enz"
      },
      "fields": [
        {
          "jsonPath": "$.components[?(@.name!='Visit www.githubstatus.com for more information')].name",
          "name": "Component"
        },
        {
          "jsonPath": "$.components[?(@.name!='Visit www.githubstatus.com for more information')].status",
          "language": "jsonpath",
          "name": "Status"
        }
      ],
      "method": "GET",
      "queryParams": "",
      "refId": "A",
      "urlPath": ""
    }
  ]
}

And here’s what the final panel looks like: Grafana Github Status