prom-remote-api

Crates.io docs.rs

Prometheus remote storage API for Rust.

Usage

There are two interfaces in Prometheus remote storage API: write/read.

Both interfaces use a snappy-compressed protocol buffer encoding over HTTP.

This crate provides: - Rust-binding to prometheus remote storage protocol buffer definitions - Various web framework utils to serve the remote wire protocols, which are controlled by corresponding feature-gates. Available features: - warp - more web framework will be added

Any third-party storage can integrate with Prometheus by implementing this RemoteStorage trait.

```rust

[async_trait]

pub trait RemoteStorage { type Err; type Context;

/// Write samples to remote storage
async fn write(
    &self,
    ctx: Self::Context,
    req: WriteRequest,
) -> std::result::Result<(), Self::Err>;

/// Read samples from remote storage,
/// [ReadRequest](crate::types::ReadRequest) may contain more than one sub queries.
async fn read(
    &self,
    ctx: Self::Context,
    req: ReadRequest,
) -> std::result::Result<ReadResponse, Self::Err>;

} ```

See simple.rs to learn how to build a remote storage with warp web framework.