cql-metrics-collector

Abstract

This project is meant as a PoC implementing a Prometheus metrics exporter for Apache Cassandra. Since Cassandra started exposing metrics via virtual tables available via CQL, a Prometheus exporter leveraging that seemed reasonable. Implemented as a sidecar service, cql-metrics-exporter is connecting an Apache Cassandra node via localhost, queries its metrics via regular CQL and exports them in Prometheus’ text format on http://localhost:9500/metrics endpoint.

Installation

Unback any of the bundles or install the Debian package provided in the release.

When installing the Debian package, a system user for the service will also be created and a SystemD service unit is installed, allowing to launch and control the application instance.

Configuration

The project used Typesafe config for configuration. The main configuration file is placed at /etc/application.conf containing commented basic configuration.

If the Cassandra node is requiring user authentication, a tool user might be created in Cassandra. When using Cassandra PasswordAuthenticator and CassandraAuthorizer, follow the example below to set up a tool user”

cassandra@cqlsh> CREATE ROLE monitor WITH PASSWORD = 'secret' AND LOGIN = true AND SUPERUSER = false;
cassandra@cqlsh> GRANT SELECT PERMISSION ON KEYSPACE system_virtual_schema TO monitor;
cassandra@cqlsh> GRANT SELECT PERMISSION ON KEYSPACE system_views TO monitor;

Then follow the example in /etc/application.conf to set up the application authentication:

datastax-java-driver.advanced.auth-provider {
  class = PlainTextAuthProvider
  username = monitor
  password = secret
}

For more detailed configuration parameters refer to reference.conf.

Usage

The service may be started within an unprivileged user context with bin/cql-metrics-collector.

Or on Debian deployments just start the cql-metrics-collector.service unit with systemctl.

Metrics can be collected from HTTP /metrics endpoint available by default on port 9500.

Dashboards

Metrics collected by a TSDB, e.g. VictoriaMetrics can be visualized with e.g. Grafana. While you are free to create metrics based visualizations, a few pre-defined dashboards are available in the dashboards folder. These are part of the release, packaged in dashboards.tar.gz and can be imported to any Grafana instance.

Metrics labels

All exported metrics get a few labels. These sets of labels are merged from a common set of label and a set of individual lables.

The common set of labels contains:

Supported metrics

Currently, only a few metrics are supported. The following virtual tables are accessed and exported as listed: