Struct datadog_api_client::datadogV1::api::api_metrics::MetricsAPI
source · 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
6 7 8 9 10 11 12 13 14 15 16 17
async fn main() {
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.query_metrics(1636542671, 1636629071, "system.cpu.idle{*}".to_string())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
async fn main() {
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.list_active_metrics(
9223372036854775807,
ListActiveMetricsOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() {
let body = MetricMetadata::new()
.per_unit("second".to_string())
.type_("count".to_string())
.unit("byte".to_string());
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.update_metric_metadata("metric_name".to_string(), body)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn main() {
let body = MetricsPayload::new(vec![Series::new(
"system.load.1".to_string(),
vec![vec![Some(1636629071.0 as f64), Some(1.1 as f64)]],
)
.tags(vec!["test:ExampleMetric".to_string()])
.type_("gauge".to_string())]);
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.submit_metrics(body, SubmitMetricsOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}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?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
async fn main() {
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.list_active_metrics(
9223372036854775807,
ListActiveMetricsOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}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?
6 7 8 9 10 11 12 13 14 15 16 17
async fn main() {
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.query_metrics(1636542671, 1636629071, "system.cpu.idle{*}".to_string())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}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?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
async fn main() {
let body = DistributionPointsPayload::new(vec![DistributionPointsSeries::new(
"system.load.1.dist".to_string(),
vec![vec![
DistributionPointItem::DistributionPointTimestamp(1636629071.0 as f64),
DistributionPointItem::DistributionPointData(vec![1.0, 2.0]),
]],
)]);
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.submit_distribution_points(body, SubmitDistributionPointsOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
async fn main() {
let body = DistributionPointsPayload::new(vec![DistributionPointsSeries::new(
"system.load.1.dist".to_string(),
vec![vec![
DistributionPointItem::DistributionPointTimestamp(1636629071.0 as f64),
DistributionPointItem::DistributionPointData(vec![1.0, 2.0]),
]],
)]);
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.submit_distribution_points(
body,
SubmitDistributionPointsOptionalParams::default()
.content_encoding(DistributionPointsContentEncoding::DEFLATE),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}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?
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn main() {
let body = MetricsPayload::new(vec![Series::new(
"system.load.1".to_string(),
vec![vec![Some(1636629071.0 as f64), Some(1.1 as f64)]],
)
.tags(vec!["test:ExampleMetric".to_string()])
.type_("gauge".to_string())]);
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.submit_metrics(body, SubmitMetricsOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}More examples
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
async fn main() {
let body = MetricsPayload::new(vec![Series::new(
"system.load.1".to_string(),
vec![vec![Some(1636629071.0 as f64), Some(1.1 as f64)]],
)
.tags(vec!["test:ExampleMetric".to_string()])
.type_("gauge".to_string())]);
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.submit_metrics(
body,
SubmitMetricsOptionalParams::default().content_encoding(MetricContentEncoding::DEFLATE),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}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?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
async fn main() {
let body = MetricMetadata::new()
.per_unit("second".to_string())
.type_("count".to_string())
.unit("byte".to_string());
let configuration = datadog::Configuration::new();
let api = MetricsAPI::with_config(configuration);
let resp = api
.update_metric_metadata("metric_name".to_string(), body)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}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 moresource§impl Debug for MetricsAPI
impl Debug for MetricsAPI
Auto Trait Implementations§
impl Freeze for MetricsAPI
impl !RefUnwindSafe for MetricsAPI
impl Send for MetricsAPI
impl Sync for MetricsAPI
impl Unpin for MetricsAPI
impl !UnwindSafe for MetricsAPI
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)