Struct 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 (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

Source

pub fn new() -> Self

Source

pub fn with_config(config: Configuration) -> Self

Examples found in repository?
examples/v2_metrics_ListMetricAssets.rs (line 8)
6async fn main() {
7    let configuration = datadog::Configuration::new();
8    let api = MetricsAPI::with_config(configuration);
9    let resp = api.list_metric_assets("system.cpu.user".to_string()).await;
10    if let Ok(value) = resp {
11        println!("{:#?}", value);
12    } else {
13        println!("{:#?}", resp.unwrap_err());
14    }
15}
More examples
Hide additional examples
examples/v2_metrics_DeleteTagConfiguration.rs (line 8)
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}
examples/v2_metrics_ListTagConfigurations.rs (line 9)
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}
examples/v2_metrics_ListVolumesByMetricName.rs (line 8)
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}
examples/v2_metrics_ListTagConfigurations_2739018321.rs (line 9)
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}
examples/v2_metrics_ListTagConfigurations_265033704.rs (line 9)
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}
Source

pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self

Source

pub async fn create_bulk_tags_metrics_configuration( &self, body: MetricBulkTagConfigCreateRequest, ) -> Result<MetricBulkTagConfigResponse, Error<CreateBulkTagsMetricsConfigurationError>>

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?
examples/v2_metrics_CreateBulkTagsMetricsConfiguration.rs (line 26)
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}
Source

pub async fn create_bulk_tags_metrics_configuration_with_http_info( &self, body: MetricBulkTagConfigCreateRequest, ) -> Result<ResponseContent<MetricBulkTagConfigResponse>, Error<CreateBulkTagsMetricsConfigurationError>>

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.

Source

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?
examples/v2_metrics_CreateTagConfiguration.rs (line 25)
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}
Source

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.

Source

pub async fn delete_bulk_tags_metrics_configuration( &self, body: MetricBulkTagConfigDeleteRequest, ) -> Result<MetricBulkTagConfigResponse, Error<DeleteBulkTagsMetricsConfigurationError>>

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?
examples/v2_metrics_DeleteBulkTagsMetricsConfiguration.rs (line 23)
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}
Source

pub async fn delete_bulk_tags_metrics_configuration_with_http_info( &self, body: MetricBulkTagConfigDeleteRequest, ) -> Result<ResponseContent<MetricBulkTagConfigResponse>, Error<DeleteBulkTagsMetricsConfigurationError>>

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.

Source

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?
examples/v2_metrics_DeleteTagConfiguration.rs (line 10)
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}
Source

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.

Source

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?
examples/v2_metrics_EstimateMetricsOutputSeries.rs (lines 11-16)
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}
Source

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™.

Source

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?
examples/v2_metrics_ListActiveMetricConfigurations.rs (lines 11-14)
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}
Source

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.

Source

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.

Examples found in repository?
examples/v2_metrics_ListMetricAssets.rs (line 9)
6async fn main() {
7    let configuration = datadog::Configuration::new();
8    let api = MetricsAPI::with_config(configuration);
9    let resp = api.list_metric_assets("system.cpu.user".to_string()).await;
10    if let Ok(value) = resp {
11        println!("{:#?}", value);
12    } else {
13        println!("{:#?}", resp.unwrap_err());
14    }
15}
Source

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.

Source

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?
examples/v2_metrics_ListTagConfigurationByName.rs (line 13)
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}
Source

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.

Source

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?
examples/v2_metrics_ListTagConfigurations.rs (line 11)
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
Hide additional examples
examples/v2_metrics_ListTagConfigurations_2739018321.rs (lines 11-13)
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}
examples/v2_metrics_ListTagConfigurations_265033704.rs (lines 11-13)
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}
Source

pub fn list_tag_configurations_with_pagination( &self, params: ListTagConfigurationsOptionalParams, ) -> impl Stream<Item = Result<MetricsAndMetricTagConfigurations, Error<ListTagConfigurationsError>>> + '_

Examples found in repository?
examples/v2_metrics_ListTagConfigurations_3969783727.rs (lines 12-14)
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}
Source

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.

Source

pub async fn list_tags_by_metric_name( &self, metric_name: String, ) -> Result<MetricAllTagsResponse, Error<ListTagsByMetricNameError>>

View indexed tag key-value pairs for a given metric name over the previous hour.

Examples found in repository?
examples/v2_metrics_ListTagsByMetricName.rs (line 13)
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}
Source

pub async fn list_tags_by_metric_name_with_http_info( &self, metric_name: String, ) -> Result<ResponseContent<MetricAllTagsResponse>, Error<ListTagsByMetricNameError>>

View indexed tag key-value pairs for a given metric name over the previous hour.

Source

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?
examples/v2_metrics_ListVolumesByMetricName.rs (line 10)
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}
Source

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.

Source

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?
examples/v2_metrics_QueryScalarData.rs (line 36)
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
Hide additional examples
examples/v2_metrics_QueryScalarData_3112571352.rs (line 37)
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}
Source

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.

Source

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?
examples/v2_metrics_QueryTimeseriesData.rs (line 35)
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
Hide additional examples
examples/v2_metrics_QueryTimeseriesData_301142940.rs (line 36)
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}
Source

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.

Source

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?
examples/v2_metrics_SubmitMetrics_1762007427.rs (lines 21-24)
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
Hide additional examples
examples/v2_metrics_SubmitMetrics.rs (line 24)
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}
Source

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.

Source

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?
examples/v2_metrics_UpdateTagConfiguration.rs (line 24)
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}
Source

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

Source§

fn clone(&self) -> MetricsAPI

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MetricsAPI

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MetricsAPI

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,