pub struct MetricsAPI { /* private fields */ }
Expand description
The metrics endpoint allows you to:
- Post metrics data so it can be graphed on Datadog’s dashboards
- Query metrics from any time period
- Modify tag configurations for metrics
- View tags and volumes for metrics
Note: A graph can only contain a set number of points and as the timeframe over which a metric is viewed increases, aggregation between points occurs to stay below that set number.
The Post, Patch, and Delete manage_tags
API methods can only be performed by
a user who has the Manage Tags for Metrics
permission.
See the Metrics page for more information.
Implementations§
Source§impl MetricsAPI
impl MetricsAPI
pub fn new() -> Self
Sourcepub fn with_config(config: Configuration) -> Self
pub fn with_config(config: Configuration) -> Self
Examples found in repository?
More examples
6async fn main() {
7 let configuration = datadog::Configuration::new();
8 let api = MetricsAPI::with_config(configuration);
9 let resp = api
10 .query_metrics(1636542671, 1636629071, "system.cpu.idle{*}".to_string())
11 .await;
12 if let Ok(value) = resp {
13 println!("{:#?}", value);
14 } else {
15 println!("{:#?}", resp.unwrap_err());
16 }
17}
7async fn main() {
8 let configuration = datadog::Configuration::new();
9 let api = MetricsAPI::with_config(configuration);
10 let resp = api
11 .list_active_metrics(
12 9223372036854775807,
13 ListActiveMetricsOptionalParams::default(),
14 )
15 .await;
16 if let Ok(value) = resp {
17 println!("{:#?}", value);
18 } else {
19 println!("{:#?}", resp.unwrap_err());
20 }
21}
7async fn main() {
8 let body = MetricMetadata::new()
9 .per_unit("second".to_string())
10 .type_("count".to_string())
11 .unit("byte".to_string());
12 let configuration = datadog::Configuration::new();
13 let api = MetricsAPI::with_config(configuration);
14 let resp = api
15 .update_metric_metadata("metric_name".to_string(), body)
16 .await;
17 if let Ok(value) = resp {
18 println!("{:#?}", value);
19 } else {
20 println!("{:#?}", resp.unwrap_err());
21 }
22}
9async fn main() {
10 let body = MetricsPayload::new(vec![Series::new(
11 "system.load.1".to_string(),
12 vec![vec![Some(1636629071.0 as f64), Some(1.1 as f64)]],
13 )
14 .tags(vec!["test:ExampleMetric".to_string()])
15 .type_("gauge".to_string())]);
16 let configuration = datadog::Configuration::new();
17 let api = MetricsAPI::with_config(configuration);
18 let resp = api
19 .submit_metrics(body, SubmitMetricsOptionalParams::default())
20 .await;
21 if let Ok(value) = resp {
22 println!("{:#?}", value);
23 } else {
24 println!("{:#?}", resp.unwrap_err());
25 }
26}
pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self
Sourcepub async fn get_metric_metadata(
&self,
metric_name: String,
) -> Result<MetricMetadata, Error<GetMetricMetadataError>>
pub async fn get_metric_metadata( &self, metric_name: String, ) -> Result<MetricMetadata, Error<GetMetricMetadataError>>
Get metadata about a specific metric.
Sourcepub async fn get_metric_metadata_with_http_info(
&self,
metric_name: String,
) -> Result<ResponseContent<MetricMetadata>, Error<GetMetricMetadataError>>
pub async fn get_metric_metadata_with_http_info( &self, metric_name: String, ) -> Result<ResponseContent<MetricMetadata>, Error<GetMetricMetadataError>>
Get metadata about a specific metric.
Sourcepub async fn list_active_metrics(
&self,
from: i64,
params: ListActiveMetricsOptionalParams,
) -> Result<MetricsListResponse, Error<ListActiveMetricsError>>
pub async fn list_active_metrics( &self, from: i64, params: ListActiveMetricsOptionalParams, ) -> Result<MetricsListResponse, Error<ListActiveMetricsError>>
Get the list of actively reporting metrics from a given time until now.
Examples found in repository?
7async fn main() {
8 let configuration = datadog::Configuration::new();
9 let api = MetricsAPI::with_config(configuration);
10 let resp = api
11 .list_active_metrics(
12 9223372036854775807,
13 ListActiveMetricsOptionalParams::default(),
14 )
15 .await;
16 if let Ok(value) = resp {
17 println!("{:#?}", value);
18 } else {
19 println!("{:#?}", resp.unwrap_err());
20 }
21}
Sourcepub async fn list_active_metrics_with_http_info(
&self,
from: i64,
params: ListActiveMetricsOptionalParams,
) -> Result<ResponseContent<MetricsListResponse>, Error<ListActiveMetricsError>>
pub async fn list_active_metrics_with_http_info( &self, from: i64, params: ListActiveMetricsOptionalParams, ) -> Result<ResponseContent<MetricsListResponse>, Error<ListActiveMetricsError>>
Get the list of actively reporting metrics from a given time until now.
Sourcepub async fn list_metrics(
&self,
q: String,
) -> Result<MetricSearchResponse, Error<ListMetricsError>>
pub async fn list_metrics( &self, q: String, ) -> Result<MetricSearchResponse, Error<ListMetricsError>>
Search for metrics from the last 24 hours in Datadog.
Sourcepub async fn list_metrics_with_http_info(
&self,
q: String,
) -> Result<ResponseContent<MetricSearchResponse>, Error<ListMetricsError>>
pub async fn list_metrics_with_http_info( &self, q: String, ) -> Result<ResponseContent<MetricSearchResponse>, Error<ListMetricsError>>
Search for metrics from the last 24 hours in Datadog.
Sourcepub async fn query_metrics(
&self,
from: i64,
to: i64,
query: String,
) -> Result<MetricsQueryResponse, Error<QueryMetricsError>>
pub async fn query_metrics( &self, from: i64, to: i64, query: String, ) -> Result<MetricsQueryResponse, Error<QueryMetricsError>>
Query timeseries points.
Examples found in repository?
6async fn main() {
7 let configuration = datadog::Configuration::new();
8 let api = MetricsAPI::with_config(configuration);
9 let resp = api
10 .query_metrics(1636542671, 1636629071, "system.cpu.idle{*}".to_string())
11 .await;
12 if let Ok(value) = resp {
13 println!("{:#?}", value);
14 } else {
15 println!("{:#?}", resp.unwrap_err());
16 }
17}
Sourcepub async fn query_metrics_with_http_info(
&self,
from: i64,
to: i64,
query: String,
) -> Result<ResponseContent<MetricsQueryResponse>, Error<QueryMetricsError>>
pub async fn query_metrics_with_http_info( &self, from: i64, to: i64, query: String, ) -> Result<ResponseContent<MetricsQueryResponse>, Error<QueryMetricsError>>
Query timeseries points.
Sourcepub async fn submit_distribution_points(
&self,
body: DistributionPointsPayload,
params: SubmitDistributionPointsOptionalParams,
) -> Result<IntakePayloadAccepted, Error<SubmitDistributionPointsError>>
pub async fn submit_distribution_points( &self, body: DistributionPointsPayload, params: SubmitDistributionPointsOptionalParams, ) -> Result<IntakePayloadAccepted, Error<SubmitDistributionPointsError>>
The distribution points end-point allows you to post distribution data that can be graphed on Datadog’s dashboards.
Examples found in repository?
10async fn main() {
11 let body = DistributionPointsPayload::new(vec![DistributionPointsSeries::new(
12 "system.load.1.dist".to_string(),
13 vec![vec![
14 DistributionPointItem::DistributionPointTimestamp(1636629071.0 as f64),
15 DistributionPointItem::DistributionPointData(vec![1.0, 2.0]),
16 ]],
17 )]);
18 let configuration = datadog::Configuration::new();
19 let api = MetricsAPI::with_config(configuration);
20 let resp = api
21 .submit_distribution_points(body, SubmitDistributionPointsOptionalParams::default())
22 .await;
23 if let Ok(value) = resp {
24 println!("{:#?}", value);
25 } else {
26 println!("{:#?}", resp.unwrap_err());
27 }
28}
More examples
11async fn main() {
12 let body = DistributionPointsPayload::new(vec![DistributionPointsSeries::new(
13 "system.load.1.dist".to_string(),
14 vec![vec![
15 DistributionPointItem::DistributionPointTimestamp(1636629071.0 as f64),
16 DistributionPointItem::DistributionPointData(vec![1.0, 2.0]),
17 ]],
18 )]);
19 let configuration = datadog::Configuration::new();
20 let api = MetricsAPI::with_config(configuration);
21 let resp = api
22 .submit_distribution_points(
23 body,
24 SubmitDistributionPointsOptionalParams::default()
25 .content_encoding(DistributionPointsContentEncoding::DEFLATE),
26 )
27 .await;
28 if let Ok(value) = resp {
29 println!("{:#?}", value);
30 } else {
31 println!("{:#?}", resp.unwrap_err());
32 }
33}
Sourcepub async fn submit_distribution_points_with_http_info(
&self,
body: DistributionPointsPayload,
params: SubmitDistributionPointsOptionalParams,
) -> Result<ResponseContent<IntakePayloadAccepted>, Error<SubmitDistributionPointsError>>
pub async fn submit_distribution_points_with_http_info( &self, body: DistributionPointsPayload, params: SubmitDistributionPointsOptionalParams, ) -> Result<ResponseContent<IntakePayloadAccepted>, Error<SubmitDistributionPointsError>>
The distribution points end-point allows you to post distribution data that can be graphed on Datadog’s dashboards.
Sourcepub async fn submit_metrics(
&self,
body: MetricsPayload,
params: SubmitMetricsOptionalParams,
) -> Result<IntakePayloadAccepted, Error<SubmitMetricsError>>
pub async fn submit_metrics( &self, body: MetricsPayload, params: SubmitMetricsOptionalParams, ) -> Result<IntakePayloadAccepted, Error<SubmitMetricsError>>
The metrics end-point allows you to post time-series data that can be graphed on Datadog’s dashboards. The maximum payload size is 3.2 megabytes (3200000 bytes). Compressed payloads must have a decompressed size of less than 62 megabytes (62914560 bytes).
If you’re submitting metrics directly to the Datadog API without using DogStatsD, expect:
- 64 bits for the timestamp
- 64 bits for the value
- 40 bytes for the metric names
- 50 bytes for the timeseries
- The full payload is approximately 100 bytes. However, with the DogStatsD API, compression is applied, which reduces the payload size.
Examples found in repository?
9async fn main() {
10 let body = MetricsPayload::new(vec![Series::new(
11 "system.load.1".to_string(),
12 vec![vec![Some(1636629071.0 as f64), Some(1.1 as f64)]],
13 )
14 .tags(vec!["test:ExampleMetric".to_string()])
15 .type_("gauge".to_string())]);
16 let configuration = datadog::Configuration::new();
17 let api = MetricsAPI::with_config(configuration);
18 let resp = api
19 .submit_metrics(body, SubmitMetricsOptionalParams::default())
20 .await;
21 if let Ok(value) = resp {
22 println!("{:#?}", value);
23 } else {
24 println!("{:#?}", resp.unwrap_err());
25 }
26}
More examples
10async fn main() {
11 let body = MetricsPayload::new(vec![Series::new(
12 "system.load.1".to_string(),
13 vec![vec![Some(1636629071.0 as f64), Some(1.1 as f64)]],
14 )
15 .tags(vec!["test:ExampleMetric".to_string()])
16 .type_("gauge".to_string())]);
17 let configuration = datadog::Configuration::new();
18 let api = MetricsAPI::with_config(configuration);
19 let resp = api
20 .submit_metrics(
21 body,
22 SubmitMetricsOptionalParams::default().content_encoding(MetricContentEncoding::DEFLATE),
23 )
24 .await;
25 if let Ok(value) = resp {
26 println!("{:#?}", value);
27 } else {
28 println!("{:#?}", resp.unwrap_err());
29 }
30}
Sourcepub async fn submit_metrics_with_http_info(
&self,
body: MetricsPayload,
params: SubmitMetricsOptionalParams,
) -> Result<ResponseContent<IntakePayloadAccepted>, Error<SubmitMetricsError>>
pub async fn submit_metrics_with_http_info( &self, body: MetricsPayload, params: SubmitMetricsOptionalParams, ) -> Result<ResponseContent<IntakePayloadAccepted>, Error<SubmitMetricsError>>
The metrics end-point allows you to post time-series data that can be graphed on Datadog’s dashboards. The maximum payload size is 3.2 megabytes (3200000 bytes). Compressed payloads must have a decompressed size of less than 62 megabytes (62914560 bytes).
If you’re submitting metrics directly to the Datadog API without using DogStatsD, expect:
- 64 bits for the timestamp
- 64 bits for the value
- 40 bytes for the metric names
- 50 bytes for the timeseries
- The full payload is approximately 100 bytes. However, with the DogStatsD API, compression is applied, which reduces the payload size.
Sourcepub async fn update_metric_metadata(
&self,
metric_name: String,
body: MetricMetadata,
) -> Result<MetricMetadata, Error<UpdateMetricMetadataError>>
pub async fn update_metric_metadata( &self, metric_name: String, body: MetricMetadata, ) -> Result<MetricMetadata, Error<UpdateMetricMetadataError>>
Edit metadata of a specific metric. Find out more about supported types.
Examples found in repository?
7async fn main() {
8 let body = MetricMetadata::new()
9 .per_unit("second".to_string())
10 .type_("count".to_string())
11 .unit("byte".to_string());
12 let configuration = datadog::Configuration::new();
13 let api = MetricsAPI::with_config(configuration);
14 let resp = api
15 .update_metric_metadata("metric_name".to_string(), body)
16 .await;
17 if let Ok(value) = resp {
18 println!("{:#?}", value);
19 } else {
20 println!("{:#?}", resp.unwrap_err());
21 }
22}
Sourcepub async fn update_metric_metadata_with_http_info(
&self,
metric_name: String,
body: MetricMetadata,
) -> Result<ResponseContent<MetricMetadata>, Error<UpdateMetricMetadataError>>
pub async fn update_metric_metadata_with_http_info( &self, metric_name: String, body: MetricMetadata, ) -> Result<ResponseContent<MetricMetadata>, Error<UpdateMetricMetadataError>>
Edit metadata of a specific metric. Find out more about supported types.
Trait Implementations§
Source§impl Clone for MetricsAPI
impl Clone for MetricsAPI
Source§fn clone(&self) -> MetricsAPI
fn clone(&self) -> MetricsAPI
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more