Site24x7 prometheus exporter k8s charm

Hello,

I’ve been working on a kubernetes charm for the site24x7 prometheus exporter, which lets you unify external end-to-end service monitoring with the rest of your metrics. Here’s how you can use it:

Credentials

You will need to have 2-factor auth enabled for your Zoho account in order to generate the correct credentials:

  1. Set up a Self Client in the web interface (not any of the “Application” ones). This will provide you with the client_id and client_secret configuration settings.

  2. Go to your client’s Generate Code tab and create a temporary code with the Scope of Site24x7.Reports.Read and an expiration of 10 minutes. You can put whatever you like in the comment field, as this is just a temporary springboard to generate the real token.

  3. Use this temporary code and the id and secret from the other tab to fill out a file called curl-secrets (replacing the 0xDEADBEEF hex examples here with your credentials):

grant_type=authorization_code&
client_id=1000.DEADBEEFDEADBEEFDEADBEEFDEADBE&
client_secret=deadbeefdeadbeefdeadbeefdeadbeefdeadbeefde&
code=1000.deadbeefdeadbeefdeadbeefdeadbeef.deadbeefdeadbeefdeadbeefdeadbeef

Then run curl https://accounts.zoho.com/oauth/v2/token -X POST -d @curl-secrets (adjusting for your regional zoho hostname). You will get a field back called refresh_token which you’ll combine with your client id and secret in the final step:

Deploy

$ juju deploy cs:~prometheus-site24x7-exporter-charmers/site24x7-exporter --config client_id='1000.DEADBEEFDEADBEEFDEADBEEFDEADBE' --config client_secret='deadbeefdeadbeefdeadbeefdeadbeefdeadbeefde' --config refresh_token='1000.c0defacec0defacec0defacec0deface.c0defacec0defacec0defacec0deface'

Once the hooks have settled out, you should be able to browse curl http://${UNIT_IP:?}:9803/metrics on the relevant unit IP. You can register it as an endpoint in your prometheus server, and be able to graph those metrics.

Bugs

There is a widely-reported issue whereby some Zoho accounts are able to use the refresh_token to get a temporary auth token, but requests under that token fail with HTTP 401 errors. If you encounter this, please follow up on the issue with information about your setup.

Tests

This charm aims to keep 100% test coverage. To run the test suite, simply run make test.