grafana
Ergonomic Rust SDK for Grafana's HTTP API, with async and blocking clients.
This crate provides:
- A production-hardened
Client/BlockingClient(base URL validation, auth injection, timeouts, retries, redaction). - Typed wrappers for common endpoint groups (and
raw()for full API coverage).
Install
[]
= { = ".", = true }
Default features: async + rustls.
Feature flags
async(default): Async client built ontokio+reqwest.blocking: Synchronous client built onreqwest::blocking(no Tokio required).rustls(default):reqwestTLS viarustls(ring provider installed automatically).native-tls:reqwestTLS via the platform/native TLS stack.tracing: Adds request spans viatracing.
Only enable one of rustls / native-tls in production.
If you are running inside Tokio, call blocking APIs from spawn_blocking or a dedicated thread pool.
Quick start (async)
use ;
# async
Quick start (blocking)
use ;
Base URL behavior
Pass the Grafana root URL (optionally with a subpath), for example:
https://grafana.example.comhttps://example.com/grafana
The client automatically targets the HTTP API under /api.
Raw API (escape hatch)
If an endpoint is not yet wrapped, use client.raw():
use Method;
use Client;
# async
Full OpenAPI coverage
Use client.openapi() for method-per-operation coverage based on Grafana operationIds:
use Client;
# async
Compatibility
Endpoint wrappers follow the latest Grafana OpenAPI spec (grafana/grafana public/openapi3.json).
For full coverage across Grafana versions, use raw() for unwrapped endpoints.
Contract tests (optional)
Run the ignored contract tests against a real Grafana:
# Bearer token auth
GRAFANA_BASE_URL="https://grafana.example.com" GRAFANA_TOKEN="..." \
# Basic auth
GRAFANA_BASE_URL="http://localhost:3000" GRAFANA_USERNAME="admin" GRAFANA_PASSWORD="admin" \