In the past I used to have an extra screen close to my desk where I was able to show different dashboards with metrics to monitor the health of our services. Depending on the service we can use things like graphite, cloudwatch or google analytics.
These days I'm finding some challenges to keep using that approach so I decided to explore the option of showing those metrics in the menu bar of my Mac.
First thing I needed was an app allowing me to put custom stuff in the menu bar. I explored a couple of options and I ended up using BitBar:
BitBar is a free app that is able to execute almost any script (bash, python, ruby...) and put the output of it in the menu bar with many customizable options for icons, images and format.
Right now I wanted to monitor a couple of services using graphite, another from cloudwatch, show some statistics from google analytics and ideally monitor a heroku app.
- Graphite: It was trivial to write a 1 line bash script curl-ing the graphite endpoint with &format=json and parsing the output with jq.
- CloudWatch: I used a python script and boto3 to be able to get CloudWatch statistics for AWS Firehose but after a couple of try-error iterations the final script was very simple too.
- Google Analytics: This was the most challenging part specially because the authentication part. I ended up using this sample from Google tuned to print the exact information I wanted: https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-py
- Heroku: I was not able to figure out how to access programmatically the requests/sec metrics that are shown in the web dashboard :(
The end result is this one, you can even use emojis (:mushroom) to make the information more colorful: