Using the Instaclustr Monitoring API with Prometheus

Menu

Note: Instaclustr is currently working on a prometheus compatible API which will make this method obsolete.

Instaclustr’s monitoring API is designed to allow you to integrate the monitoring information from your Instaclustr managed cluster with the monitoring tool used for the entire application. Prometheus (https://prometheus.io/) is an open-source platform for monitoring a range of applications. This help article walks you through how to use the Instaclustr Monitoring API with Prometheus using an exporter.

At a high-level, the process involves using a script, created by one of our customers, to grab metrics from the Instaclustr Monitoring API at regular intervals and convert them into a format that is readable by Prometheus. This may also involve installing some prerequisite software if it is not already installed on the machine. You can find more information on the script we will be using here: https://github.com/fcgravalos/instaclustr_exporter


Prepare Your Environment

Follow these steps to set up your environment:

  1. Set up a Cassandra cluster with Instaclustr (see https://www.instaclustr.com/support/documentation/getting-started/creating-a-cluster/)
  2. Locate your Instaclustr username, monitoring API key and provisioning API key. (From the console, click ‘Account’ and then ‘API Keys’)
  3. Install ‘Go’ on the machine (https://golang.org/doc/install)
  4. Ensure Go is in the system path (check the install link above)
  5. Set the GOPATH environment variable (https://github.com/golang/go/wiki/SettingGOPATH)
  6. Add $GOPATH/bin to the system path (and create the bin folder if it doesn’t exist, this is similar to step 3 above)


Set Up and Run The Script

A customer has created a script that calls the Instaclustr API and passes on the data in a Prometheus friendly format. The script is available on GitHub here: https://github.com/fcgravalos/instaclustr_exporter. You can download the ZIP file or clone the repository.

After downloading the files, make sure they are in a folder named instaclustr_exporter and relocate this folder to $GOPATH/src/github.com/fcgravalos/.

In the folder directory ($GOPATH/src/github.com/fcgravalos/instaclustr_exporter), run make -f Makefile and wait for it to finish. Once that’s done, run the script using the username, monitoring API key and provisioning API key you located earlier: ./instaclustr_exporter -instaclustr.user YOURUSER -instaclustr.monitoring-apikey YOURMONITORINGAPIKEY -instaclustr.provisioning-apikey YOURPROVISIONINGAPIKEY

If this was successful, you will be provided with a port and the script should be running:
eg: INFO[0000] [instaclustr_exporter] started on :9279

You can check that the script is running by visiting the port in a browser with: ‘http://localhost:XXXX’ where XXXX is the port (9279 in this case)


Linking The Script with Prometheus

If you haven’t already, download the pre-compiled Prometheus binaries (https://prometheus.io/download/).

Edit the Prometheus config file prometheus.yml located in the prometheus root folder, the important part is that we create a new job that targets the output location of the instaclustr_exporter script, here’s an example:

Fill in the ‘YOUR X’ sections and save the file.

For more configuration options see: https://prometheus.io/docs/prometheus/latest/configuration/configuration/

Run Prometheus with the following command in the Prometheus root folder:
./prometheus --config.file=prometheus.yml

If all has gone well, you should be able to view Prometheus from a browser by visiting http://localhost:9090, with exported metrics now visible at ‘localhost:9090/graph’ via the ‘insert metric at cursor’ dropdown.


Viewing Metrics on Prometheus

On the Prometheus graphs page (http://localhost:9090/graph) select a metric from the ‘- insert metric at cursor -’ dropdown box.

Once a desired metric has been selected, select Graph (if you want a time series style graph view) or Console (if you want a (key, value) view) and then click ‘Execute’.

The desired metric should now be displaying.

Console Example

Graph Example

When selecting graph, you can also change the duration and time range for the graph (only data points after the start time of the instaclustr_exporter script will be visible)

Site by Swell Design Group