#metrics-exporter #influx-db #grafana #cloud #sending #tokio

metrics-exporter-influx

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

5 releases

new 0.2.2 Mar 6, 2025
0.2.1 Mar 6, 2025
0.1.3 Oct 24, 2023
0.1.2 Jul 31, 2023

#5 in #grafana

Download history 34/week @ 2024-11-08 72/week @ 2024-11-15 21/week @ 2024-11-22 71/week @ 2024-11-29 45/week @ 2024-12-06 18/week @ 2024-12-13 1/week @ 2025-01-03 27/week @ 2025-01-10 2/week @ 2025-01-17 46/week @ 2025-01-24 76/week @ 2025-01-31 12/week @ 2025-02-07

94 downloads per month

MIT license

56KB
1.5K 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
~258K SLoC