Lightweight HTTP service that exposes data from .rrd (Round Robin Database) files as JSON
1.8K
Lightweight HTTP service written in Go that exposes data from .rrd (Round Robin Database) files as JSON.
It is designed to integrate seamlessly with Grafana (via the Infinity datasource), monitoring stacks, or any system that needs to consume RRD metrics (such as those produced by Munin) over HTTP.
rrdtool fetchThis can be used as docker container:
as standalone service:
docker run -it -p 9090:808080 --rm \
-v $(pwd)/rrd:/app/rrd:ro \
-e LOG_LEVEL=debug \
-e CACHE_TTL_METRICS=60 \
--name rrd-json-exporter nioc/rrd-json-exporter:latest
in a docker-compose.yml file:
services:
rrd-json-exporter:
image: nioc/rrd-json-exporter:latest
container_name: rrd-json-exporter
environment:
LOG_LEVEL: debug
# CACHE_TTL_LIST: 1800
# CACHE_TTL_METRICS: 60
# ROUND_STEP: 60
# PORT: 8080
# AUTH_USER: myuser
# AUTH_PASS: mypassword
volumes:
- ./rrd:/app/rrd:ro
ports:
- 9090:8080
restart: unless-stopped
Environment Variables
| Variable | Default | Description |
|---|---|---|
LOG_LEVEL | info | Logging verbosity (error, info, debug) |
CACHE_TTL_LIST | 1800 | File name cache duration in seconds (/list) |
CACHE_TTL_METRICS | 60 | Metrics cache duration in seconds (/metrics) |
ROUND_STEP | 300 | Rounding from and to timestamps |
PORT | 8080 | Port the exporter listens on in the container |
AUTH_USER | User (basic authentication) | |
AUTH_PASS | Password (basic authentication) |
NB: Basic authentication is only enabled if both the AUTH_USER and AUTH_PASS environment variables are provided.
Request a list of all available RRD metric files or those matching a regular expression (provided in the optionnal query parameter filter)
GET /list?filter=docker
This returns a JSON array containing the available RRD metric files:
[
"server-docker_cpu-proxy-g.rrd",
"server-docker_cpu-nginx-g.rrd",
"server-docker_memory-proxy-g.rrd",
"server-docker_memory-nginx-g.rrd"
]
You can also send a query parameter details to get a description of each RRD file:
GET /list?filter=docker&details
[
{
"nodename": "server",
"plugin": "docker_cpu",
"field": "proxy",
"type": "gauge",
"name": "server-docker_cpu-proxy-g.rrd"
},
{
"nodename": "server",
"plugin": "docker_memory",
"field": "proxy",
"type": "gauge",
"name": "server-docker_memory-proxy-g.rrd"
}
]
Request all available RRD metrics
GET /metrics
This returns a JSON array containing all metrics:
[
{
"n": "server-docker_cpu-proxy-g",
"t": 1769878800,
"v": 1.9536137042
},
{
"n": "server-docker_cpu-proxy-g",
"t": 1769879100,
"v": 2.1562561502
},
{
"n": "server-docker_cpu-proxy-g",
"t": 1769879400,
"v": 1.2935769699
}
]
With the following attributes:
n: the name of the metrict: the Unix timestamp in secondsv: the value of the metric at that timeRequest a specific RRD metric by its filename
GET /metrics?rrd=filename.rrd
Request several specific RRD metrics by their file name
GET /metrics?rrd={filename1.rrd,filename2.rrd}
This returns a JSON object containing the requested metrics.
Request metric(s) for a specific time range between from and to (expressed in ms)
GET /metrics?rrd=filename.rrd&from=1770146257895&to=1770167857895
In case of an error, the message has the following structure with proper HTTP status codes:
{
"status": "error",
"message": "RRD file not found",
"details": "server-docker_cpu.rrd"
}
Use the Infinity Datasource plugin.
Infinity typehttp://rrd-json-exporter:8080/ (according to the name of your container)You can import the sample dashboard.
Add a variable: Settings > Variables > New variable
QueryrrdfileJSONJQURLGETlistAdd a visualization with:
JSONJSONataURLTime SeriesGETmetrics?rrd=${rrdfile}&from=${__from}&to=${__to}t, format as Time (UNIX s)v, format as Numbern, format as StringPartition by values transformation with n fieldRename fields by regex transformationSee also the list of contributors to this project.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details
Content type
Image
Digest
sha256:12cb33ee0…
Size
13.8 MB
Last updated
8 months ago
docker pull nioc/rrd-json-exporter