Skip to content

Prometheus Exporter for RocksJava. Monitor Java RocksDB by using Prometheus and Grafana.

Notifications You must be signed in to change notification settings

huynhsamha/java-rocksdb-prometheus-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java RocksDB Prometheus Exporter

Prometheus Exporter for RocksJava. Monitor Java RocksDB by using Prometheus and Grafana.

Quick start

Maven

In development

Gradle

In development

Jar Dependencies

In development

Usage

Exposing metrics from Java

This is a simple example how we can expose RocksDB metrics. Your RocksDB metrics will be exposed at http://localhost:9098/rocksdb_stats.

public class Example {

    public static void main(String[] args) {

        // HTTP server port
        int port = 9098;

        // RocksDB instance from your application
        RocksDB db = null; // db instance
        Statistics stats = null; // stats your RocksDB instance
        List<ColumnFamilyHandle> cfHandles = null; // stats your Column Families

        try {
            // wrap RocksDB instance to jRocksDB
            JRocksDB jRocksDB = new JRocksDB(db, stats, cfHandles);

            // init an exporter instance for your RocksDB
            JRocksDBExporter exporter = new JRocksDBExporter(port, jRocksDB);

            // start HTTP server on port for exposing RocksDB metrics
            exporter.start();

            System.out.println("Server is running on port " + port);
            System.out.println(">>> RocksDB metrics is exposed at http://localhost:" + port + "/rocksdb_stats");

        } catch (Exception ex) {
            System.err.println(ex);
        }
    }
}

RocksDB Metrics

There are 2 metric types exported from http://localhost:9098/rocksdb_stats

  • rocksdb_props: stats for Column Families (CF), including default, All_CFs and your custom CFs.
  • rocksdb_stats: stats for RocksDB from TickerType of RocksDB Statistics.

rocksdb_props

  • Format: rocksdb_props{cf = "[CF_NAME]", prop = "[CF_PROPERTIY]"}
  • cf: Column Family name, including default, All_CFs and your custom CFs.
  • prop: Column Family property, from rocksdb/include/rocksdb/db.h

rocksdb_stats

  • Format: rocksdb_stats{ticker = "[TICKER_TYPE_NAME]"}
  • ticker: TickerType of RocksDB Statistics, Java Doc

Prometheus Configure

Add a job rocksdb_stats to your prometheus.yml

scrape_configs:
  - job_name: rocksdb_stats
    scrape_interval: 5s
    scrape_timeout:  5s
    metrics_path: "/rocksdb_stats"
    static_configs:
    - targets: # list your RocksDB instances
      - localhost:9098

Grafana Dashboard

In development

Java Doc

In development

About

Prometheus Exporter for RocksJava. Monitor Java RocksDB by using Prometheus and Grafana.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages