All Projects → brndnmtthws → metrics-cassandra

brndnmtthws / metrics-cassandra

Licence: WTFPL License
Dropwizard Metrics Cassandra reporter

Programming Languages

java
68154 projects - #9 most used programming language

Dropwizard Metrics reporter for Cassandra 2.1/2.0/1.2

Build Status

This is a Cassandra reporter for the Codahale Dropwizard Metrics library (https://dropwizard.github.io/metrics). It uses the DataStax Java driver (https://github.com/datastax/java-driver) to write metrics to Cassandra.

Grab it from clojars.org

  <repositories>
    <repository>
      <id>clojars.org</id>
      <url>http://clojars.org/repo</url>
    </repository>
  </repositories>
  ...
  <dependencies>
    <dependency>
      <groupId>org.clojars.brenden</groupId>
      <artifactId>metrics-cassandra</artifactId>
      <version>3.1.0</version>
    </dependency>
  </dependencies>

Try it out

final Cassandra cassandra = new Cassandra(
		Arrays.asList("cassandra.example.com"),
		"metrics", /*   keyspace          */
		"data",    /*   table             */
		31536000,  /*   TTL in seconds    */
		9042,      /*   native port       */
		"ONE");    /*   consistency level */

final CassandraReporter reporter = CassandraReporter.forRegistry(registry)
	.prefixedWith("metrics")
	.convertRatesTo(TimeUnit.SECONDS)
	.convertDurationsTo(TimeUnit.MILLISECONDS)
	.filter(MetricFilter.ALL)
	.build(cassandra);

reporter.start(1, TimeUnit.MINUTES);

The code above will create 2 tables in the metrics keyspace: one called data, and one called data_names. The schema for these tables looks like this:

CREATE TABLE IF NOT EXISTS data (
  name VARCHAR,
  timestamp TIMESTAMP,
  value DOUBLE,
  PRIMARY KEY (name, timestamp)
);
CREATE TABLE IF NOT EXISTS data_names (
  name VARCHAR,
  last_updated TIMESTAMP,
  PRIMARY KEY (name)
);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].