| Crates.io | grafana |
| lib.rs | grafana |
| version | 0.1.3 |
| created_at | 2026-01-02 06:43:33.682224+00 |
| updated_at | 2026-01-02 14:23:33.985185+00 |
| description | Ergonomic Rust SDK for Grafana's HTTP API, with async and blocking clients. |
| homepage | |
| repository | https://github.com/lvillis/grafana-rs |
| max_upload_size | |
| id | 2018092 |
| size | 484,961 |
grafana-rsErgonomic Rust SDK for Grafana's HTTP API, with async and blocking clients.
[dependencies]
grafana = "0.1" # async + rustls (default)
Blocking-only (no Tokio):
[dependencies]
grafana = { version = "0.1", default-features = false, features = ["blocking", "rustls"] }
Native TLS: replace rustls with native-tls (and set default-features = false).
async (default): tokio + reqwest.blocking: reqwest::blocking.rustls (default) / native-tls: pick one TLS backend.tracing: request spans.If you run inside Tokio, call blocking APIs from spawn_blocking or a dedicated thread pool.
use grafana::{Auth, Client};
async fn demo() -> Result<(), grafana::Error> {
let client = Client::builder("https://grafana.example.com")?
.auth(Auth::bearer("TOKEN"))
.build()?;
let health = client.health().get().await?;
println!("{health:?}");
Ok(())
}
use grafana::{Auth, BlockingClient};
fn demo() -> Result<(), grafana::Error> {
let client = BlockingClient::builder("https://grafana.example.com")?
.auth(Auth::bearer("TOKEN"))
.build()?;
let health = client.health().get()?;
println!("{health:?}");
Ok(())
}
Pass the Grafana root URL (optionally with a subpath). The client automatically targets /api.
Examples:
https://grafana.example.comhttps://example.com/grafanaclient.dashboards(), client.folders(), client.user(), ...client.openapi() (method-per-operation, keyed by Grafana operationId).client.raw() for custom requests.Endpoint wrappers follow the latest Grafana OpenAPI spec (grafana/grafana public/openapi3.json).
For full coverage across Grafana versions, use raw() for unwrapped endpoints.
Run the ignored contract tests against a real Grafana:
# Bearer token auth
GRAFANA_BASE_URL="https://grafana.example.com" GRAFANA_TOKEN="..." \
cargo test --test contract -- --ignored
# Basic auth
GRAFANA_BASE_URL="http://localhost:3000" GRAFANA_USERNAME="admin" GRAFANA_PASSWORD="admin" \
cargo test --test contract -- --ignored