Official Rust bindings for the Axiom API
Axiom unlocks observability at any scale.
For more information check out the official documentation and our community Discord.
Add the following to your Cargo.toml:
[dependencies]
axiom-rs = "0.9"
If you use the Axiom CLI, run
eval $(axiom config export -f)
to configure your environment variables.
Otherwise create a personal token in the Axiom settings and make note of the organization ID from the settings page of the organization you want to access.
Create and use a client like this:
use axiom_rs::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Build your client by providing a personal token and an org id:
let client = Client::builder()
.with_token("my-token")
.with_org_id("my-org")
.build()?;
// Alternatively you autoconfigure the client from the environment variables
// AXIOM_TOKEN and AXIOM_ORG_ID:
let client = Client::new()?;
client.datasets.create("my-dataset", "").await?;
client
.ingest(
"my-dataset",
vec![json!({
"foo": "bar",
})],
)
.await?;
let res = client
.query(r#"['my-dataset'] | where foo == "bar" | limit 100"#, None)
.await?;
println!("{:?}", res);
client.datasets.delete("my-dataset").await?;
Ok(())
}
For further examples, head over to the examples directory.
The following are a list of Cargo features that can be enabled or disabled:
native-tls
.rustls
.tokio
runtime.async-std
runtime.Licensed under either of
at your option.