#metrics-exporter #cloud #influx #sending #duration #file #influx-db #cloud-metrics #metrics-compatible

metrics-exporter-influx

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

5 releases

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

#431 in Science

Download history 41/week @ 2025-02-17 50/week @ 2025-02-24 467/week @ 2025-03-03 66/week @ 2025-03-10 61/week @ 2025-03-17 29/week @ 2025-03-24 33/week @ 2025-03-31 48/week @ 2025-04-07 32/week @ 2025-04-14 23/week @ 2025-04-21 46/week @ 2025-04-28 16/week @ 2025-05-05 47/week @ 2025-05-12 7/week @ 2025-05-19 8/week @ 2025-05-26 1/week @ 2025-06-02

64 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–21MB
~269K SLoC