Expand description
A lean, protocol-first SDK for building Grafana backend plugins in Rust.
Backend plugins communicate with Grafana via gRPC (the pluginv2 protocol),
run as a go-plugin subprocess. This crate implements that protocol.
The default build is intentionally small and dependency-light — it implements
only what a resource/health plugin needs: custom HTTP-style requests
(CallResource) and health checks (CheckHealth). Dataframe queries and
streaming are opt-in behind cargo features (see below).
The crate is organised into:
backendcontains the traits a plugin implements (e.g.ResourceServiceandDiagnosticsService) and thePlugintype that serves them.livecontains channel/path types used by Grafana Live.data(featuredata) contains the fundamental dataframe structures (Frame,Field) and their metadata.
The prelude re-exports the [GrafanaPlugin] derive macro and, with the
data feature, the traits for building frames and fields.
The low-level generated structs are exposed in the pluginv2 module as an
escape hatch, if required.
See the docs on backend plugins on grafana.com for an introduction to backend Grafana plugins.
§Logging
Emit logs with the tracing macros; install backend::layer, call
backend::init_hclog_subscriber before bootstrap work, or enable
Plugin::init_subscriber so they are written
in the hclog format Grafana understands. This is the idiomatic replacement for
the Go SDK’s backend/log logger.
§Build information
build_info! captures the plugin’s BuildInfo (id and
version) from its Cargo metadata.
§Feature flags
automtls— go-plugin automatic mTLS, required to connect to a Grafana instance that serves backend plugins with AutoMTLS (the default). Opt-in.data— dataframe support: thedatamodule (Frame/Field),DataService/QueryData, and Arrow IPC serialization. Pulls in Apache Arrow.stream— Grafana LiveStreamService(impliesdata).httpadapter— aResourceServicethat servesCallResourcerequests by running them through anaxum::Router.reqwest— adds thehttpclientmodule and anIntoHttpResponseimplementation forreqwest::Response.prometheus— encodes aprometheus::Registrydirectly intoCollectMetricsResponse.opentelemetry— extracts distributed trace context from Grafana’s incoming gRPC metadata and attaches it to each request’stracingspan.gen-proto— regenerate the protobuf bindings using a vendoredprotocbinary.
Re-exports§
pub use arrow;
Modules§
- backend
- Functionality for use by backend plugins.
- buildinfo
- Plugin build information.
- data
- Data types used throughout the SDK.
- httpadapter
- Serve Grafana
CallResourcerequests using anaxum::Router. - httpclient
- A configurable HTTP client for calling Grafana or other services.
- live
- Grafana Live features, providing streaming functionality to Grafana.
- pluginv2
- The low-level structs generated from protocol definitions.
- prelude
- Contains useful helper traits, in particular the [
GrafanaPlugin] derive macro and (with thedatafeature) the traits for constructingFields andFrames.
Macros§
- build_
info - Capture
BuildInfofrom the calling crate’s Cargo package metadata.