#metrics-exporter

metrics-exporter-influx

A metrics-compatible exporter for sending metrics to Influx/Grafana Cloud

4 releases

0.1.3 Oct 24, 2023
0.1.2 Jul 31, 2023
0.1.1 Jul 7, 2023
0.1.0 Jul 5, 2023

#33 in #metrics-exporter

Download history 36/week @ 2024-06-24 31/week @ 2024-07-01 61/week @ 2024-07-08 6/week @ 2024-07-15 44/week @ 2024-07-22 84/week @ 2024-07-29 155/week @ 2024-08-05 102/week @ 2024-08-12 35/week @ 2024-08-19 26/week @ 2024-08-26 24/week @ 2024-09-02 9/week @ 2024-09-09 31/week @ 2024-09-16 235/week @ 2024-09-23 33/week @ 2024-09-30 46/week @ 2024-10-07

345 downloads per month

MIT license

54KB
1K SLoC

metrics-exporter-influx

build-badge downloads-badge release-badge docs-badge license-badge

Metrics reporter for https://github.com/metrics-rs/metrics that writes to InfluxDB.

Usage

Configuration

Writing to a stderr

use std::time::Duration;

#[tokio::main]
async fn main() {
    InfluxBuilder::new().with_duration(Duration::from_secs(60)).install()?;
}

Writing to a file

use std::fs::File;

#[tokio::main]
async fn main() {
    InfluxBuilder::new()
        .with_writer(File::create("/tmp/out.metrics")?)
        .install()?;
}

Writing to http

Influx

#[tokio::main]
async fn main() {
    InfluxBuilder::new()
        .with_influx_api(
            "http://localhost:8086",
            "db/rp",
            None,
            None,
            None,
            Some("ns".to_string())
        )
        .install()?;
}

Grafana Cloud

Grafana Cloud supports the Influx Line Protocol exported by this exporter.

#[tokio::main]
async fn main() {
    InfluxBuilder::new()
        .with_grafna_cloud_api(
            "https://https://influx-prod-03-prod-us-central-0.grafana.net/api/v1/push/influx/write",
            Some("username".to_string()),
            Some("key")
        )
        .install()?;
}

Dependencies

~8–20MB
~272K SLoC