Send data from Rust app to Axiom
This page explains how to send data from a Rust app to Axiom.
To send data from a Rust app to Axiom, use the Axiom Rust SDK.
To send spans generated by the tracing library, use the tracing-axiom layer. For more information, see Send traces from Rust tracing to Axiom.
Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to ingest data to the dataset you have created.
Install SDK
Add the following to your Cargo.toml:
Replace VERSION with the latest version number specified on the GitHub Releases page. For example, 0.11.0.
If you use the Axiom CLI, run eval $(axiom config export -f) to configure your environment variables. Otherwise, create an API token and export it as AXIOM_TOKEN.
Use client
For more examples, see the examples in GitHub.
Query metrics
Query metrics datasets with the Metrics Processing Language (MPL) using client.metrics().query(...). Configure an edge domain with with_edge (or AXIOM_EDGE) for the region your dataset lives in:
Discover metrics
Use client.metrics() to inspect metrics and tags in a dataset:
list(dataset, start, end): List metric names and metadata in a dataset.tags(start, end)anddataset_tags(dataset, start, end): List tag keys.tag_values(tag, start, end)anddataset_tag_values(dataset, tag, start, end): List values for a tag key.find_metrics(dataset, value, start, end): Find metrics in a dataset that match a tag value.spec(dataset, start, end): Fetch the metrics specification.
List dashboards
Use client.dashboards() to access the v2 dashboards API:
Configure region
By default, the client sends data to api.axiom.co. To target a specific edge region, add the with_edge method to the builder with the edge domain that matches the region your dataset lives in:
The following edge domains are available:
| Edge deployment | Base domain for ingest and query |
|---|---|
US East 1 (AWS) | us-east-1.aws.edge.axiom.co |
EU Central 1 (AWS) | eu-central-1.aws.edge.axiom.co |
For more information about edge deployments, see Edge deployments.
You can also configure the region without changing code by exporting environment variables. When you build the client with Client::new(), these are read automatically:
To point at a custom edge endpoint such as a proxy or load balancer, use .with_edge_url("https://your-edge-host"). with_edge_url takes precedence over with_edge if both are set.
Optional features
You can use the Cargo features:
default-tls: Provides TLS support to connect over HTTPS. Enabled by default.native-tls: Enables TLS functionality provided bynative-tls.rustls-tls: Enables TLS functionality provided byrustls.tokio: Enables usage with thetokioruntime. Enabled by default.async-std: Enables usage with theasync-stdruntime.