vector/sinks/prometheus/
mod.rs

1#[cfg(test)]
2use vector_lib::event::Metric;
3use vector_lib::sensitive_string::SensitiveString;
4
5mod collector;
6pub mod exporter;
7pub mod remote_write;
8
9use vector_lib::configurable::configurable_component;
10
11/// Authentication strategies.
12#[configurable_component]
13#[derive(Clone, Debug)]
14#[serde(deny_unknown_fields, rename_all = "snake_case", tag = "strategy")]
15#[configurable(metadata(docs::enum_tag_description = "The authentication strategy to use."))]
16pub enum PrometheusRemoteWriteAuth {
17    /// HTTP Basic Authentication.
18    Basic {
19        /// Basic authentication username.
20        user: String,
21
22        /// Basic authentication password.
23        password: String,
24    },
25
26    /// Bearer authentication.
27    ///
28    /// A bearer token (OAuth2, JWT, etc) is passed as-is.
29    Bearer {
30        /// The bearer token to send.
31        token: SensitiveString,
32    },
33
34    #[cfg(feature = "aws-core")]
35    /// Amazon Prometheus Service-specific authentication.
36    Aws(crate::aws::AwsAuthentication),
37}
38
39fn default_histogram_buckets() -> Vec<f64> {
40    vec![
41        0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0,
42    ]
43}
44
45fn default_summary_quantiles() -> Vec<f64> {
46    vec![0.5, 0.75, 0.9, 0.95, 0.99]
47}
48
49#[cfg(test)]
50fn distribution_to_agg_histogram(metric: Metric, buckets: &[f64]) -> Option<Metric> {
51    // If the metric isn;'t already a distribution, this ends up returning `None`.
52    let new_value = metric
53        .value()
54        .clone()
55        .distribution_to_agg_histogram(buckets);
56    new_value.map(move |value| metric.with_value(value))
57}
58
59#[cfg(test)]
60fn distribution_to_ddsketch(metric: Metric) -> Option<Metric> {
61    // If the metric isn;'t already a distribution, this ends up returning `None`.
62    let new_value = metric.value().clone().distribution_to_sketch();
63    new_value.map(move |value| metric.with_value(value))
64}