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
  • 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/v1_metrics_ListMetrics.rs (line 8)
6async fn main() {
7    let configuration = datadog::Configuration::new();
8    let api = MetricsAPI::with_config(configuration);
9    let resp = api.list_metrics("q".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/v1_metrics_GetMetricMetadata.rs (line 8)
6async fn main() {
7    let configuration = datadog::Configuration::new();
8    let api = MetricsAPI::with_config(configuration);
9    let resp = api.get_metric_metadata("metric_name".to_string()).await;
10    if let Ok(value) = resp {
11        println!("{:#?}", value);
12    } else {
13        println!("{:#?}", resp.unwrap_err());
14    }
15}
examples/v1_metrics_QueryMetrics.rs (line 8)
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}
examples/v1_metrics_ListActiveMetrics.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_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}
examples/v1_metrics_UpdateMetricMetadata.rs (line 13)
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}
examples/v1_metrics_SubmitMetrics.rs (line 17)
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}
Source

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

Source

pub async fn get_metric_metadata( &self, metric_name: String, ) -> Result<MetricMetadata, Error<GetMetricMetadataError>>

Get metadata about a specific metric.

Examples found in repository?
examples/v1_metrics_GetMetricMetadata.rs (line 9)
6async fn main() {
7    let configuration = datadog::Configuration::new();
8    let api = MetricsAPI::with_config(configuration);
9    let resp = api.get_metric_metadata("metric_name".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 get_metric_metadata_with_http_info( &self, metric_name: String, ) -> Result<ResponseContent<MetricMetadata>, Error<GetMetricMetadataError>>

Get metadata about a specific metric.

Source

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?
examples/v1_metrics_ListActiveMetrics.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_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}
Source

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.

Source

pub async fn list_metrics( &self, q: String, ) -> Result<MetricSearchResponse, Error<ListMetricsError>>

Search for metrics from the last 24 hours in Datadog.

Examples found in repository?
examples/v1_metrics_ListMetrics.rs (line 9)
6async fn main() {
7    let configuration = datadog::Configuration::new();
8    let api = MetricsAPI::with_config(configuration);
9    let resp = api.list_metrics("q".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_metrics_with_http_info( &self, q: String, ) -> Result<ResponseContent<MetricSearchResponse>, Error<ListMetricsError>>

Search for metrics from the last 24 hours in Datadog.

Source

pub async fn query_metrics( &self, from: i64, to: i64, query: String, ) -> Result<MetricsQueryResponse, Error<QueryMetricsError>>

Query timeseries points.

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

pub async fn query_metrics_with_http_info( &self, from: i64, to: i64, query: String, ) -> Result<ResponseContent<MetricsQueryResponse>, Error<QueryMetricsError>>

Query timeseries points.

Source

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?
examples/v1_metrics_SubmitDistributionPoints.rs (line 21)
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
Hide additional examples
examples/v1_metrics_SubmitDistributionPoints_3109558960.rs (lines 22-26)
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}
Source

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.

Source

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?
examples/v1_metrics_SubmitMetrics.rs (line 19)
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
Hide additional examples
examples/v1_metrics_SubmitMetrics_2203981258.rs (lines 20-23)
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}
Source

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

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

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

Source§

fn clone(&self) -> MetricsAPI

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

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,

Source§

impl<T> MaybeSendSync for T