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

source

pub fn new() -> Self

source

pub fn with_config(config: Configuration) -> Self

Examples found in repository?
examples/v1_metrics_ListMetrics.rs (line 8)
6
7
8
9
10
11
12
13
14
15
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.list_metrics("q".to_string()).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
More examples
Hide additional examples
examples/v1_metrics_GetMetricMetadata.rs (line 8)
6
7
8
9
10
11
12
13
14
15
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.get_metric_metadata("metric_name".to_string()).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
examples/v1_metrics_QueryMetrics.rs (line 8)
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());
    }
}
examples/v1_metrics_ListActiveMetrics.rs (line 9)
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());
    }
}
examples/v1_metrics_UpdateMetricMetadata.rs (line 13)
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());
    }
}
examples/v1_metrics_SubmitMetrics.rs (line 17)
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());
    }
}
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)
6
7
8
9
10
11
12
13
14
15
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.get_metric_metadata("metric_name".to_string()).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
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)
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());
    }
}
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)
6
7
8
9
10
11
12
13
14
15
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MetricsAPI::with_config(configuration);
    let resp = api.list_metrics("q".to_string()).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
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)
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());
    }
}
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)
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
Hide additional examples
examples/v1_metrics_SubmitDistributionPoints_3109558960.rs (lines 22-26)
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());
    }
}
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)
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
Hide additional examples
examples/v1_metrics_SubmitMetrics_2203981258.rs (lines 20-23)
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());
    }
}
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)
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());
    }
}
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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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