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 (timeseries and scalar)
- 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 .delete_tag_configuration("ExampleMetric".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_tag_configurations(ListTagConfigurationsOptionalParams::default())
12 .await;
13 if let Ok(value) = resp {
14 println!("{:#?}", value);
15 } else {
16 println!("{:#?}", resp.unwrap_err());
17 }
18}
6async fn main() {
7 let configuration = datadog::Configuration::new();
8 let api = MetricsAPI::with_config(configuration);
9 let resp = api
10 .list_volumes_by_metric_name("static_test_metric_donotdelete".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_tag_configurations(
12 ListTagConfigurationsOptionalParams::default().filter_configured(true),
13 )
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
7async fn main() {
8 let configuration = datadog::Configuration::new();
9 let api = MetricsAPI::with_config(configuration);
10 let resp = api
11 .list_tag_configurations(
12 ListTagConfigurationsOptionalParams::default().filter_tags("ExampleMetric".to_string()),
13 )
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
- examples/v2_metrics_ListActiveMetricConfigurations.rs
- examples/v2_metrics_ListTagConfigurations_3969783727.rs
- examples/v2_metrics_ListTagsByMetricName.rs
- examples/v2_metrics_ListTagConfigurationByName.rs
- examples/v2_metrics_EstimateMetricsOutputSeries.rs
- examples/v2_metrics_SubmitMetrics_1762007427.rs
- examples/v2_metrics_SubmitMetrics.rs
- examples/v2_metrics_DeleteBulkTagsMetricsConfiguration.rs
- examples/v2_metrics_CreateTagConfiguration.rs
- examples/v2_metrics_UpdateTagConfiguration.rs
- examples/v2_metrics_CreateBulkTagsMetricsConfiguration.rs
- examples/v2_metrics_QueryScalarData.rs
- examples/v2_metrics_QueryTimeseriesData.rs
- examples/v2_metrics_QueryScalarData_3112571352.rs
- examples/v2_metrics_QueryTimeseriesData_301142940.rs
pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self
Create and define a list of queryable tag keys for a set of existing count, gauge, rate, and distribution metrics.
Metrics are selected by passing a metric name prefix. Use the Delete method of this API path to remove tag configurations.
Results can be sent to a set of account email addresses, just like the same operation in the Datadog web app.
If multiple calls include the same metric, the last configuration applied (not by submit order) is used, do not
expect deterministic ordering of concurrent calls. The exclude_tags_mode
value will set all metrics that match the prefix to
the same exclusion state, metric tag configurations do not support mixed inclusion and exclusion for tags on the same metric.
Can only be used with application keys of users with the Manage Tags for Metrics
permission.
Examples found in repository?
10async fn main() {
11 // there is a valid "user" in the system
12 let user_data_attributes_email = std::env::var("USER_DATA_ATTRIBUTES_EMAIL").unwrap();
13 let body = MetricBulkTagConfigCreateRequest::new(
14 MetricBulkTagConfigCreate::new(
15 "system.load.1".to_string(),
16 MetricBulkConfigureTagsType::BULK_MANAGE_TAGS,
17 )
18 .attributes(
19 MetricBulkTagConfigCreateAttributes::new()
20 .emails(vec![user_data_attributes_email.clone()])
21 .tags(vec!["test".to_string(), "examplemetric".to_string()]),
22 ),
23 );
24 let configuration = datadog::Configuration::new();
25 let api = MetricsAPI::with_config(configuration);
26 let resp = api.create_bulk_tags_metrics_configuration(body).await;
27 if let Ok(value) = resp {
28 println!("{:#?}", value);
29 } else {
30 println!("{:#?}", resp.unwrap_err());
31 }
32}
Create and define a list of queryable tag keys for a set of existing count, gauge, rate, and distribution metrics.
Metrics are selected by passing a metric name prefix. Use the Delete method of this API path to remove tag configurations.
Results can be sent to a set of account email addresses, just like the same operation in the Datadog web app.
If multiple calls include the same metric, the last configuration applied (not by submit order) is used, do not
expect deterministic ordering of concurrent calls. The exclude_tags_mode
value will set all metrics that match the prefix to
the same exclusion state, metric tag configurations do not support mixed inclusion and exclusion for tags on the same metric.
Can only be used with application keys of users with the Manage Tags for Metrics
permission.
Sourcepub async fn create_tag_configuration(
&self,
metric_name: String,
body: MetricTagConfigurationCreateRequest,
) -> Result<MetricTagConfigurationResponse, Error<CreateTagConfigurationError>>
pub async fn create_tag_configuration( &self, metric_name: String, body: MetricTagConfigurationCreateRequest, ) -> Result<MetricTagConfigurationResponse, Error<CreateTagConfigurationError>>
Create and define a list of queryable tag keys for an existing count/gauge/rate/distribution metric.
Optionally, include percentile aggregations on any distribution metric. By setting exclude_tags_mode
to true, the behavior is changed from an allow-list to a deny-list, and tags in the defined list are
not queryable. Can only be used with application keys of users with the Manage Tags for Metrics
permission.
Examples found in repository?
11async fn main() {
12 let body = MetricTagConfigurationCreateRequest::new(
13 MetricTagConfigurationCreateData::new(
14 "ExampleMetric".to_string(),
15 MetricTagConfigurationType::MANAGE_TAGS,
16 )
17 .attributes(MetricTagConfigurationCreateAttributes::new(
18 MetricTagConfigurationMetricTypes::GAUGE,
19 vec!["app".to_string(), "datacenter".to_string()],
20 )),
21 );
22 let configuration = datadog::Configuration::new();
23 let api = MetricsAPI::with_config(configuration);
24 let resp = api
25 .create_tag_configuration("ExampleMetric".to_string(), body)
26 .await;
27 if let Ok(value) = resp {
28 println!("{:#?}", value);
29 } else {
30 println!("{:#?}", resp.unwrap_err());
31 }
32}
Sourcepub async fn create_tag_configuration_with_http_info(
&self,
metric_name: String,
body: MetricTagConfigurationCreateRequest,
) -> Result<ResponseContent<MetricTagConfigurationResponse>, Error<CreateTagConfigurationError>>
pub async fn create_tag_configuration_with_http_info( &self, metric_name: String, body: MetricTagConfigurationCreateRequest, ) -> Result<ResponseContent<MetricTagConfigurationResponse>, Error<CreateTagConfigurationError>>
Create and define a list of queryable tag keys for an existing count/gauge/rate/distribution metric.
Optionally, include percentile aggregations on any distribution metric. By setting exclude_tags_mode
to true, the behavior is changed from an allow-list to a deny-list, and tags in the defined list are
not queryable. Can only be used with application keys of users with the Manage Tags for Metrics
permission.
Delete all custom lists of queryable tag keys for a set of existing count, gauge, rate, and distribution metrics.
Metrics are selected by passing a metric name prefix.
Results can be sent to a set of account email addresses, just like the same operation in the Datadog web app.
Can only be used with application keys of users with the Manage Tags for Metrics
permission.
Examples found in repository?
10async fn main() {
11 let body = MetricBulkTagConfigDeleteRequest::new(
12 MetricBulkTagConfigDelete::new(
13 "kafka.lag".to_string(),
14 MetricBulkConfigureTagsType::BULK_MANAGE_TAGS,
15 )
16 .attributes(MetricBulkTagConfigDeleteAttributes::new().emails(vec![
17 "sue@example.com".to_string(),
18 "bob@example.com".to_string(),
19 ])),
20 );
21 let configuration = datadog::Configuration::new();
22 let api = MetricsAPI::with_config(configuration);
23 let resp = api.delete_bulk_tags_metrics_configuration(body).await;
24 if let Ok(value) = resp {
25 println!("{:#?}", value);
26 } else {
27 println!("{:#?}", resp.unwrap_err());
28 }
29}
Delete all custom lists of queryable tag keys for a set of existing count, gauge, rate, and distribution metrics.
Metrics are selected by passing a metric name prefix.
Results can be sent to a set of account email addresses, just like the same operation in the Datadog web app.
Can only be used with application keys of users with the Manage Tags for Metrics
permission.
Sourcepub async fn delete_tag_configuration(
&self,
metric_name: String,
) -> Result<(), Error<DeleteTagConfigurationError>>
pub async fn delete_tag_configuration( &self, metric_name: String, ) -> Result<(), Error<DeleteTagConfigurationError>>
Deletes a metric’s tag configuration. Can only be used with application
keys from users with the Manage Tags for Metrics
permission.
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 .delete_tag_configuration("ExampleMetric".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 delete_tag_configuration_with_http_info(
&self,
metric_name: String,
) -> Result<ResponseContent<()>, Error<DeleteTagConfigurationError>>
pub async fn delete_tag_configuration_with_http_info( &self, metric_name: String, ) -> Result<ResponseContent<()>, Error<DeleteTagConfigurationError>>
Deletes a metric’s tag configuration. Can only be used with application
keys from users with the Manage Tags for Metrics
permission.
Sourcepub async fn estimate_metrics_output_series(
&self,
metric_name: String,
params: EstimateMetricsOutputSeriesOptionalParams,
) -> Result<MetricEstimateResponse, Error<EstimateMetricsOutputSeriesError>>
pub async fn estimate_metrics_output_series( &self, metric_name: String, params: EstimateMetricsOutputSeriesOptionalParams, ) -> Result<MetricEstimateResponse, Error<EstimateMetricsOutputSeriesError>>
Returns the estimated cardinality for a metric with a given tag, percentile and number of aggregations configuration using Metrics without Limits™.
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 .estimate_metrics_output_series(
12 "system.cpu.idle".to_string(),
13 EstimateMetricsOutputSeriesOptionalParams::default()
14 .filter_groups("app,host".to_string())
15 .filter_num_aggregations(4),
16 )
17 .await;
18 if let Ok(value) = resp {
19 println!("{:#?}", value);
20 } else {
21 println!("{:#?}", resp.unwrap_err());
22 }
23}
Sourcepub async fn estimate_metrics_output_series_with_http_info(
&self,
metric_name: String,
params: EstimateMetricsOutputSeriesOptionalParams,
) -> Result<ResponseContent<MetricEstimateResponse>, Error<EstimateMetricsOutputSeriesError>>
pub async fn estimate_metrics_output_series_with_http_info( &self, metric_name: String, params: EstimateMetricsOutputSeriesOptionalParams, ) -> Result<ResponseContent<MetricEstimateResponse>, Error<EstimateMetricsOutputSeriesError>>
Returns the estimated cardinality for a metric with a given tag, percentile and number of aggregations configuration using Metrics without Limits™.
Sourcepub async fn list_active_metric_configurations(
&self,
metric_name: String,
params: ListActiveMetricConfigurationsOptionalParams,
) -> Result<MetricSuggestedTagsAndAggregationsResponse, Error<ListActiveMetricConfigurationsError>>
pub async fn list_active_metric_configurations( &self, metric_name: String, params: ListActiveMetricConfigurationsOptionalParams, ) -> Result<MetricSuggestedTagsAndAggregationsResponse, Error<ListActiveMetricConfigurationsError>>
List tags and aggregations that are actively queried on dashboards, notebooks, monitors, the Metrics Explorer, and using the API for a given metric name.
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_metric_configurations(
12 "static_test_metric_donotdelete".to_string(),
13 ListActiveMetricConfigurationsOptionalParams::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_metric_configurations_with_http_info(
&self,
metric_name: String,
params: ListActiveMetricConfigurationsOptionalParams,
) -> Result<ResponseContent<MetricSuggestedTagsAndAggregationsResponse>, Error<ListActiveMetricConfigurationsError>>
pub async fn list_active_metric_configurations_with_http_info( &self, metric_name: String, params: ListActiveMetricConfigurationsOptionalParams, ) -> Result<ResponseContent<MetricSuggestedTagsAndAggregationsResponse>, Error<ListActiveMetricConfigurationsError>>
List tags and aggregations that are actively queried on dashboards, notebooks, monitors, the Metrics Explorer, and using the API for a given metric name.
Sourcepub async fn list_metric_assets(
&self,
metric_name: String,
) -> Result<MetricAssetsResponse, Error<ListMetricAssetsError>>
pub async fn list_metric_assets( &self, metric_name: String, ) -> Result<MetricAssetsResponse, Error<ListMetricAssetsError>>
Returns dashboards, monitors, notebooks, and SLOs that a metric is stored in, if any. Updated every 24 hours.
Sourcepub async fn list_metric_assets_with_http_info(
&self,
metric_name: String,
) -> Result<ResponseContent<MetricAssetsResponse>, Error<ListMetricAssetsError>>
pub async fn list_metric_assets_with_http_info( &self, metric_name: String, ) -> Result<ResponseContent<MetricAssetsResponse>, Error<ListMetricAssetsError>>
Returns dashboards, monitors, notebooks, and SLOs that a metric is stored in, if any. Updated every 24 hours.
Sourcepub async fn list_tag_configuration_by_name(
&self,
metric_name: String,
) -> Result<MetricTagConfigurationResponse, Error<ListTagConfigurationByNameError>>
pub async fn list_tag_configuration_by_name( &self, metric_name: String, ) -> Result<MetricTagConfigurationResponse, Error<ListTagConfigurationByNameError>>
Returns the tag configuration for the given metric name.
Examples found in repository?
6async fn main() {
7 // there is a valid "metric_tag_configuration" in the system
8 let metric_tag_configuration_data_id =
9 std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = MetricsAPI::with_config(configuration);
12 let resp = api
13 .list_tag_configuration_by_name(metric_tag_configuration_data_id.clone())
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
Sourcepub async fn list_tag_configuration_by_name_with_http_info(
&self,
metric_name: String,
) -> Result<ResponseContent<MetricTagConfigurationResponse>, Error<ListTagConfigurationByNameError>>
pub async fn list_tag_configuration_by_name_with_http_info( &self, metric_name: String, ) -> Result<ResponseContent<MetricTagConfigurationResponse>, Error<ListTagConfigurationByNameError>>
Returns the tag configuration for the given metric name.
Sourcepub async fn list_tag_configurations(
&self,
params: ListTagConfigurationsOptionalParams,
) -> Result<MetricsAndMetricTagConfigurationsResponse, Error<ListTagConfigurationsError>>
pub async fn list_tag_configurations( &self, params: ListTagConfigurationsOptionalParams, ) -> Result<MetricsAndMetricTagConfigurationsResponse, Error<ListTagConfigurationsError>>
Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits™ (matching additional filters if specified).
Optionally, paginate by using the page[cursor]
and/or page[size]
query parameters.
To fetch the first page, pass in a query parameter with either a valid page[size]
or an empty cursor like page[cursor]=
. To fetch the next page, pass in the next_cursor
value from the response as the new page[cursor]
value.
Once the meta.pagination.next_cursor
value is null, all pages have been retrieved.
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_tag_configurations(ListTagConfigurationsOptionalParams::default())
12 .await;
13 if let Ok(value) = resp {
14 println!("{:#?}", value);
15 } else {
16 println!("{:#?}", resp.unwrap_err());
17 }
18}
More examples
7async fn main() {
8 let configuration = datadog::Configuration::new();
9 let api = MetricsAPI::with_config(configuration);
10 let resp = api
11 .list_tag_configurations(
12 ListTagConfigurationsOptionalParams::default().filter_configured(true),
13 )
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
7async fn main() {
8 let configuration = datadog::Configuration::new();
9 let api = MetricsAPI::with_config(configuration);
10 let resp = api
11 .list_tag_configurations(
12 ListTagConfigurationsOptionalParams::default().filter_tags("ExampleMetric".to_string()),
13 )
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
Sourcepub fn list_tag_configurations_with_pagination(
&self,
params: ListTagConfigurationsOptionalParams,
) -> impl Stream<Item = Result<MetricsAndMetricTagConfigurations, Error<ListTagConfigurationsError>>> + '_
pub fn list_tag_configurations_with_pagination( &self, params: ListTagConfigurationsOptionalParams, ) -> impl Stream<Item = Result<MetricsAndMetricTagConfigurations, Error<ListTagConfigurationsError>>> + '_
Examples found in repository?
9async fn main() {
10 let configuration = datadog::Configuration::new();
11 let api = MetricsAPI::with_config(configuration);
12 let response = api.list_tag_configurations_with_pagination(
13 ListTagConfigurationsOptionalParams::default().page_size(2),
14 );
15 pin_mut!(response);
16 while let Some(resp) = response.next().await {
17 if let Ok(value) = resp {
18 println!("{:#?}", value);
19 } else {
20 println!("{:#?}", resp.unwrap_err());
21 }
22 }
23}
Sourcepub async fn list_tag_configurations_with_http_info(
&self,
params: ListTagConfigurationsOptionalParams,
) -> Result<ResponseContent<MetricsAndMetricTagConfigurationsResponse>, Error<ListTagConfigurationsError>>
pub async fn list_tag_configurations_with_http_info( &self, params: ListTagConfigurationsOptionalParams, ) -> Result<ResponseContent<MetricsAndMetricTagConfigurationsResponse>, Error<ListTagConfigurationsError>>
Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits™ (matching additional filters if specified).
Optionally, paginate by using the page[cursor]
and/or page[size]
query parameters.
To fetch the first page, pass in a query parameter with either a valid page[size]
or an empty cursor like page[cursor]=
. To fetch the next page, pass in the next_cursor
value from the response as the new page[cursor]
value.
Once the meta.pagination.next_cursor
value is null, all pages have been retrieved.
View indexed tag key-value pairs for a given metric name over the previous hour.
Examples found in repository?
6async fn main() {
7 // there is a valid "metric_tag_configuration" in the system
8 let metric_tag_configuration_data_id =
9 std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = MetricsAPI::with_config(configuration);
12 let resp = api
13 .list_tags_by_metric_name(metric_tag_configuration_data_id.clone())
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
View indexed tag key-value pairs for a given metric name over the previous hour.
Sourcepub async fn list_volumes_by_metric_name(
&self,
metric_name: String,
) -> Result<MetricVolumesResponse, Error<ListVolumesByMetricNameError>>
pub async fn list_volumes_by_metric_name( &self, metric_name: String, ) -> Result<MetricVolumesResponse, Error<ListVolumesByMetricNameError>>
View distinct metrics volumes for the given metric name.
Custom metrics generated in-app from other products will return null
for ingested volumes.
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 .list_volumes_by_metric_name("static_test_metric_donotdelete".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 list_volumes_by_metric_name_with_http_info(
&self,
metric_name: String,
) -> Result<ResponseContent<MetricVolumesResponse>, Error<ListVolumesByMetricNameError>>
pub async fn list_volumes_by_metric_name_with_http_info( &self, metric_name: String, ) -> Result<ResponseContent<MetricVolumesResponse>, Error<ListVolumesByMetricNameError>>
View distinct metrics volumes for the given metric name.
Custom metrics generated in-app from other products will return null
for ingested volumes.
Sourcepub async fn query_scalar_data(
&self,
body: ScalarFormulaQueryRequest,
) -> Result<ScalarFormulaQueryResponse, Error<QueryScalarDataError>>
pub async fn query_scalar_data( &self, body: ScalarFormulaQueryRequest, ) -> Result<ScalarFormulaQueryResponse, Error<QueryScalarDataError>>
Query scalar values (as seen on Query Value, Table, and Toplist widgets). Multiple data sources are supported with the ability to process the data using formulas and functions.
Examples found in repository?
17async fn main() {
18 let body = ScalarFormulaQueryRequest::new(ScalarFormulaRequest::new(
19 ScalarFormulaRequestAttributes::new(
20 1568899800000,
21 vec![ScalarQuery::MetricsScalarQuery(Box::new(
22 MetricsScalarQuery::new(
23 MetricsAggregator::AVG,
24 MetricsDataSource::METRICS,
25 "avg:system.cpu.user{*} by {env}".to_string(),
26 ),
27 ))],
28 1568923200000,
29 )
30 .formulas(vec![QueryFormula::new("a+b".to_string())
31 .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]),
32 ScalarFormulaRequestType::SCALAR_REQUEST,
33 ));
34 let configuration = datadog::Configuration::new();
35 let api = MetricsAPI::with_config(configuration);
36 let resp = api.query_scalar_data(body).await;
37 if let Ok(value) = resp {
38 println!("{:#?}", value);
39 } else {
40 println!("{:#?}", resp.unwrap_err());
41 }
42}
More examples
17async fn main() {
18 let body = ScalarFormulaQueryRequest::new(ScalarFormulaRequest::new(
19 ScalarFormulaRequestAttributes::new(
20 1636625471000,
21 vec![ScalarQuery::MetricsScalarQuery(Box::new(
22 MetricsScalarQuery::new(
23 MetricsAggregator::AVG,
24 MetricsDataSource::METRICS,
25 "avg:system.cpu.user{*}".to_string(),
26 )
27 .name("a".to_string()),
28 ))],
29 1636629071000,
30 )
31 .formulas(vec![QueryFormula::new("a".to_string())
32 .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]),
33 ScalarFormulaRequestType::SCALAR_REQUEST,
34 ));
35 let configuration = datadog::Configuration::new();
36 let api = MetricsAPI::with_config(configuration);
37 let resp = api.query_scalar_data(body).await;
38 if let Ok(value) = resp {
39 println!("{:#?}", value);
40 } else {
41 println!("{:#?}", resp.unwrap_err());
42 }
43}
Sourcepub async fn query_scalar_data_with_http_info(
&self,
body: ScalarFormulaQueryRequest,
) -> Result<ResponseContent<ScalarFormulaQueryResponse>, Error<QueryScalarDataError>>
pub async fn query_scalar_data_with_http_info( &self, body: ScalarFormulaQueryRequest, ) -> Result<ResponseContent<ScalarFormulaQueryResponse>, Error<QueryScalarDataError>>
Query scalar values (as seen on Query Value, Table, and Toplist widgets). Multiple data sources are supported with the ability to process the data using formulas and functions.
Sourcepub async fn query_timeseries_data(
&self,
body: TimeseriesFormulaQueryRequest,
) -> Result<TimeseriesFormulaQueryResponse, Error<QueryTimeseriesDataError>>
pub async fn query_timeseries_data( &self, body: TimeseriesFormulaQueryRequest, ) -> Result<TimeseriesFormulaQueryResponse, Error<QueryTimeseriesDataError>>
Query timeseries data across various data sources and process the data by applying formulas and functions.
Examples found in repository?
16async fn main() {
17 let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new(
18 TimeseriesFormulaRequestAttributes::new(
19 1568899800000,
20 vec![TimeseriesQuery::MetricsTimeseriesQuery(Box::new(
21 MetricsTimeseriesQuery::new(
22 MetricsDataSource::METRICS,
23 "avg:system.cpu.user{*} by {env}".to_string(),
24 ),
25 ))],
26 1568923200000,
27 )
28 .formulas(vec![QueryFormula::new("a+b".to_string())
29 .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))])
30 .interval(5000),
31 TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
32 ));
33 let configuration = datadog::Configuration::new();
34 let api = MetricsAPI::with_config(configuration);
35 let resp = api.query_timeseries_data(body).await;
36 if let Ok(value) = resp {
37 println!("{:#?}", value);
38 } else {
39 println!("{:#?}", resp.unwrap_err());
40 }
41}
More examples
16async fn main() {
17 let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new(
18 TimeseriesFormulaRequestAttributes::new(
19 1636625471000,
20 vec![TimeseriesQuery::MetricsTimeseriesQuery(Box::new(
21 MetricsTimeseriesQuery::new(
22 MetricsDataSource::METRICS,
23 "avg:datadog.estimated_usage.metrics.custom{*}".to_string(),
24 )
25 .name("a".to_string()),
26 ))],
27 1636629071000,
28 )
29 .formulas(vec![QueryFormula::new("a".to_string())
30 .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))])
31 .interval(5000),
32 TimeseriesFormulaRequestType::TIMESERIES_REQUEST,
33 ));
34 let configuration = datadog::Configuration::new();
35 let api = MetricsAPI::with_config(configuration);
36 let resp = api.query_timeseries_data(body).await;
37 if let Ok(value) = resp {
38 println!("{:#?}", value);
39 } else {
40 println!("{:#?}", resp.unwrap_err());
41 }
42}
Sourcepub async fn query_timeseries_data_with_http_info(
&self,
body: TimeseriesFormulaQueryRequest,
) -> Result<ResponseContent<TimeseriesFormulaQueryResponse>, Error<QueryTimeseriesDataError>>
pub async fn query_timeseries_data_with_http_info( &self, body: TimeseriesFormulaQueryRequest, ) -> Result<ResponseContent<TimeseriesFormulaQueryResponse>, Error<QueryTimeseriesDataError>>
Query timeseries data across various data sources and process the data by applying formulas and functions.
Sourcepub async fn submit_metrics(
&self,
body: MetricPayload,
params: SubmitMetricsOptionalParams,
) -> Result<IntakePayloadAccepted, Error<SubmitMetricsError>>
pub async fn submit_metrics( &self, body: MetricPayload, 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 500 kilobytes (512000 bytes). Compressed payloads must have a decompressed size of less than 5 megabytes (5242880 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
- 20 bytes for the metric names
- 50 bytes for the timeseries
- The full payload is approximately 100 bytes.
Host name is one of the resources in the Resources field.
Examples found in repository?
12async fn main() {
13 let body = MetricPayload::new(vec![MetricSeries::new(
14 "system.load.1".to_string(),
15 vec![MetricPoint::new().timestamp(1636629071).value(0.7 as f64)],
16 )
17 .type_(MetricIntakeType::UNSPECIFIED)]);
18 let configuration = datadog::Configuration::new();
19 let api = MetricsAPI::with_config(configuration);
20 let resp = api
21 .submit_metrics(
22 body,
23 SubmitMetricsOptionalParams::default().content_encoding(MetricContentEncoding::ZSTD1),
24 )
25 .await;
26 if let Ok(value) = resp {
27 println!("{:#?}", value);
28 } else {
29 println!("{:#?}", resp.unwrap_err());
30 }
31}
More examples
12async fn main() {
13 let body = MetricPayload::new(vec![MetricSeries::new(
14 "system.load.1".to_string(),
15 vec![MetricPoint::new().timestamp(1636629071).value(0.7 as f64)],
16 )
17 .resources(vec![MetricResource::new()
18 .name("dummyhost".to_string())
19 .type_("host".to_string())])
20 .type_(MetricIntakeType::UNSPECIFIED)]);
21 let configuration = datadog::Configuration::new();
22 let api = MetricsAPI::with_config(configuration);
23 let resp = api
24 .submit_metrics(body, SubmitMetricsOptionalParams::default())
25 .await;
26 if let Ok(value) = resp {
27 println!("{:#?}", value);
28 } else {
29 println!("{:#?}", resp.unwrap_err());
30 }
31}
Sourcepub async fn submit_metrics_with_http_info(
&self,
body: MetricPayload,
params: SubmitMetricsOptionalParams,
) -> Result<ResponseContent<IntakePayloadAccepted>, Error<SubmitMetricsError>>
pub async fn submit_metrics_with_http_info( &self, body: MetricPayload, 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 500 kilobytes (512000 bytes). Compressed payloads must have a decompressed size of less than 5 megabytes (5242880 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
- 20 bytes for the metric names
- 50 bytes for the timeseries
- The full payload is approximately 100 bytes.
Host name is one of the resources in the Resources field.
Sourcepub async fn update_tag_configuration(
&self,
metric_name: String,
body: MetricTagConfigurationUpdateRequest,
) -> Result<MetricTagConfigurationResponse, Error<UpdateTagConfigurationError>>
pub async fn update_tag_configuration( &self, metric_name: String, body: MetricTagConfigurationUpdateRequest, ) -> Result<MetricTagConfigurationResponse, Error<UpdateTagConfigurationError>>
Update the tag configuration of a metric or percentile aggregations of a distribution metric or custom aggregations
of a count, rate, or gauge metric. By setting exclude_tags_mode
to true the behavior is changed
from an allow-list to a deny-list, and tags in the defined list will not be queryable.
Can only be used with application keys from users with the Manage Tags for Metrics
permission. This endpoint requires
a tag configuration to be created first.
Examples found in repository?
10async fn main() {
11 // there is a valid "metric_tag_configuration" in the system
12 let metric_tag_configuration_data_id =
13 std::env::var("METRIC_TAG_CONFIGURATION_DATA_ID").unwrap();
14 let body = MetricTagConfigurationUpdateRequest::new(
15 MetricTagConfigurationUpdateData::new(
16 metric_tag_configuration_data_id.clone(),
17 MetricTagConfigurationType::MANAGE_TAGS,
18 )
19 .attributes(MetricTagConfigurationUpdateAttributes::new().tags(vec!["app".to_string()])),
20 );
21 let configuration = datadog::Configuration::new();
22 let api = MetricsAPI::with_config(configuration);
23 let resp = api
24 .update_tag_configuration(metric_tag_configuration_data_id.clone(), body)
25 .await;
26 if let Ok(value) = resp {
27 println!("{:#?}", value);
28 } else {
29 println!("{:#?}", resp.unwrap_err());
30 }
31}
Sourcepub async fn update_tag_configuration_with_http_info(
&self,
metric_name: String,
body: MetricTagConfigurationUpdateRequest,
) -> Result<ResponseContent<MetricTagConfigurationResponse>, Error<UpdateTagConfigurationError>>
pub async fn update_tag_configuration_with_http_info( &self, metric_name: String, body: MetricTagConfigurationUpdateRequest, ) -> Result<ResponseContent<MetricTagConfigurationResponse>, Error<UpdateTagConfigurationError>>
Update the tag configuration of a metric or percentile aggregations of a distribution metric or custom aggregations
of a count, rate, or gauge metric. By setting exclude_tags_mode
to true the behavior is changed
from an allow-list to a deny-list, and tags in the defined list will not be queryable.
Can only be used with application keys from users with the Manage Tags for Metrics
permission. This endpoint requires
a tag configuration to be created first.
Trait Implementations§
Source§impl Clone for MetricsAPI
impl Clone for MetricsAPI
Source§fn clone(&self) -> MetricsAPI
fn clone(&self) -> MetricsAPI
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more