agent_data_plane_config/
shared.rs

1//! Cross-cutting values consumed by more than one domain.
2
3use std::collections::HashMap;
4use std::path::PathBuf;
5use std::time::Duration;
6
7use serde::Serialize;
8
9/// Cross-cutting configuration shared across domains.
10#[derive(Clone, Debug, Default, PartialEq, Serialize)]
11pub struct SharedConfiguration {
12    /// Primary forwarder endpoints and transport.
13    pub endpoints: Endpoints,
14
15    /// Global and host-level tagging.
16    pub tags: GlobalTags,
17
18    /// Tags attached to basic liveness telemetry.
19    pub basic_telemetry: BasicTelemetry,
20
21    /// Metrics-encoder settings reused across the metrics-emitting pipelines.
22    pub metrics_encoding: MetricsEncoding,
23
24    /// Cluster Agent connection, shared by checks, DogStatsD, and OTLP.
25    pub cluster_agent: ClusterAgent,
26
27    /// Autoscaling failover, shared by checks, DogStatsD, and OTLP.
28    pub autoscaling_failover: AutoscalingFailover,
29
30    /// Verbosity of the internal telemetry emitted about the runtime itself. (not in Datadog Agent
31    /// config schema)
32    pub metrics_level: String,
33}
34
35/// Primary outbound endpoints plus the forwarder, proxy, TLS, and compression settings that apply
36/// to every pipeline emitting to the intake.
37#[derive(Clone, Debug, Default, PartialEq, Serialize)]
38pub struct Endpoints {
39    /// API key for the primary intake.
40    pub api_key: String,
41
42    /// Base site domain for the primary intake, when set (for example, `datadoghq.com`).
43    pub site: Option<String>,
44
45    /// Full primary intake URL override, when set; takes precedence over `site`. A config-sourced
46    /// value equal to the Core Agent's default intake is dropped during translation so that `site`
47    /// is honored (see `consume_dd_url`); programmatic overrides are not filtered.
48    pub dd_url: Option<String>,
49
50    /// Additional dual-shipping endpoints, keyed by intake URL with their API keys.
51    pub additional_endpoints: HashMap<String, Vec<String>>,
52
53    /// Whether metrics may carry arbitrary tags.
54    pub allow_arbitrary_tags: bool,
55
56    /// Outbound HTTP proxy settings.
57    pub proxy: Proxy,
58
59    /// Outbound TLS client settings.
60    pub tls: Tls,
61
62    /// Payload compression settings.
63    pub compression: Compression,
64
65    /// Forwarder retry, backoff, worker, and disk-storage settings.
66    pub forwarder: Forwarder,
67
68    /// Alternate metrics intake for the Observability Pipelines Worker, used in place of the
69    /// default intake when enabled.
70    pub opw_intake: AltMetricsIntake,
71
72    /// Alternate metrics intake for Vector, used in place of the default intake when enabled.
73    pub vector_intake: AltMetricsIntake,
74}
75
76/// An alternate metrics intake (Observability Pipelines Worker or Vector) that replaces the Datadog
77/// intake when enabled.
78#[derive(Clone, Debug, Default, PartialEq, Serialize)]
79pub struct AltMetricsIntake {
80    /// Whether this alternate intake replaces the default one.
81    pub enabled: bool,
82
83    /// URL of the alternate metrics intake.
84    pub url: String,
85
86    /// Whether metrics ship to this intake over the V3 series protocol
87    /// (`observability_pipelines_worker.metrics.use_v3_api.series` / `vector.metrics.use_v3_api.series`).
88    pub use_v3_series: bool,
89}
90
91/// Outbound HTTP proxy settings.
92#[derive(Clone, Debug, Default, PartialEq, Serialize)]
93pub struct Proxy {
94    /// Proxy URL for plain HTTP requests.
95    pub http: String,
96
97    /// Proxy URL for HTTPS requests.
98    pub https: String,
99
100    /// Hosts that bypass the proxy.
101    pub no_proxy: Vec<String>,
102
103    /// Whether no-proxy entries match by suffix rather than exact host.
104    pub no_proxy_nonexact_match: bool,
105
106    /// Whether cloud-metadata requests also go through the proxy.
107    pub use_proxy_for_cloud_metadata: bool,
108}
109
110/// Outbound TLS client settings.
111#[derive(Clone, Debug, Default, PartialEq, Serialize)]
112pub struct Tls {
113    /// Whether server certificate validation is skipped.
114    pub skip_ssl_validation: bool,
115
116    /// Minimum TLS version enforced on outbound connections.
117    pub min_tls_version: String,
118
119    /// Path to which TLS session keys are logged, for debugging.
120    pub sslkeylogfile: String,
121}
122
123/// Payload compression settings applied before transmission.
124#[derive(Clone, Debug, Default, PartialEq, Serialize)]
125pub struct Compression {
126    /// Which compression algorithm the encoder uses.
127    pub compressor_kind: String,
128
129    /// Compression level used when the algorithm is zstd.
130    pub zstd_compressor_level: i32,
131}
132
133/// HTTP protocol the forwarder negotiates with the intake.
134#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)]
135pub enum ForwarderHttpProtocol {
136    #[default]
137    Auto,
138    Http1,
139}
140
141/// Forwarder retry, backoff, worker, and disk-storage settings.
142#[derive(Clone, Debug, Default, PartialEq, Serialize)]
143pub struct Forwarder {
144    /// How often, in seconds, API keys are checked for validity against the intake.
145    pub apikey_validation_interval: i64,
146
147    /// Base delay, in seconds, for retry backoff.
148    pub backoff_base: f64,
149
150    /// Multiplier applied to the backoff delay after each failed attempt.
151    pub backoff_factor: f64,
152
153    /// Maximum retry backoff delay, in seconds.
154    pub backoff_max: f64,
155
156    /// How often, in seconds, idle connections are reset.
157    pub connection_reset_interval: u64,
158
159    /// Fraction of the in-memory retry queue at which payloads spill to disk.
160    pub flush_to_disk_mem_ratio: f64,
161
162    /// Capacity of the high-priority send buffer.
163    pub high_prio_buffer_size: usize,
164
165    /// HTTP protocol the forwarder negotiates with the intake.
166    pub http_protocol: ForwarderHttpProtocol,
167
168    /// Maximum number of in-flight requests to the intake.
169    pub max_concurrent_requests: usize,
170
171    /// Number of forwarder worker tasks.
172    pub num_workers: usize,
173
174    /// Age, in days, after which payloads queued on disk are discarded.
175    pub outdated_file_in_days: u32,
176
177    /// Number of retry cycles between attempts to recover a failed endpoint.
178    pub recovery_interval: u32,
179
180    /// Whether the recovery interval resets after a successful send.
181    pub recovery_reset: bool,
182
183    /// Retry-queue capacity expressed as seconds of buffered payloads.
184    pub retry_queue_capacity_time_interval_sec: u64,
185
186    /// Maximum number of payloads held in the in-memory retry queue.
187    pub retry_queue_max_size: Option<u64>,
188
189    /// Maximum total size, in bytes, of payloads held in the retry queue.
190    pub retry_queue_payloads_max_size: Option<u64>,
191
192    /// Grace period, in seconds, the forwarder is given to drain before shutdown.
193    pub stop_timeout: u64,
194
195    /// Fraction of available disk the on-disk retry store may use.
196    pub storage_max_disk_ratio: f64,
197
198    /// Maximum size, in bytes, of the on-disk retry store.
199    pub storage_max_size_in_bytes: u64,
200
201    /// Directory where retry payloads are persisted to disk.
202    pub storage_path: PathBuf,
203
204    /// Per-request timeout, in seconds, for calls to the intake.
205    pub timeout: u64,
206}
207
208/// Global / host tagging.
209#[derive(Clone, Debug, Default, PartialEq, Serialize)]
210pub struct GlobalTags {
211    /// How long, after startup, host tags remain attached to emitted data.
212    pub expected_tags_duration: Duration,
213}
214
215/// Tagging options for basic liveness telemetry.
216#[derive(Clone, Debug, Default, PartialEq, Serialize)]
217pub struct BasicTelemetry {
218    /// Whether liveness signals include the process container's low-cardinality tags.
219    ///
220    /// Defaults to `false`. Enable this for containerized deployments that need to associate basic
221    /// telemetry with the running container. If the container cannot be resolved, liveness signals
222    /// are emitted without these tags.
223    pub add_container_tags: bool,
224}
225
226/// Metrics-encoder settings reused across the metrics-emitting pipelines (DogStatsD, checks, and
227/// OTLP): histogram settings, payload limits, and the encoder flush timeout.
228#[derive(Clone, Debug, Default, PartialEq, Serialize)]
229pub struct MetricsEncoding {
230    /// How long the encoder waits before flushing a partially filled payload. (not in Datadog Agent
231    /// config schema)
232    pub flush_timeout: Duration,
233
234    /// Maximum number of metrics packed into a single payload. (not in Datadog Agent config schema)
235    pub max_metrics_per_payload: usize,
236
237    /// Maximum compressed payload size, in bytes.
238    pub max_payload_size: usize,
239
240    /// Maximum compressed size, in bytes, of a series payload.
241    pub max_series_payload_size: usize,
242
243    /// Maximum number of series data points per payload.
244    pub max_series_points_per_payload: usize,
245
246    /// Maximum uncompressed size, in bytes, of a series payload.
247    pub max_series_uncompressed_payload_size: usize,
248
249    /// Maximum uncompressed payload size, in bytes.
250    pub max_uncompressed_payload_size: usize,
251
252    /// Whether series are submitted via the v2 intake API.
253    pub use_v2_series_api: bool,
254
255    /// Whether outgoing payloads are logged for debugging.
256    pub log_payloads: bool,
257
258    /// Histogram aggregation and encoding settings.
259    pub histogram: HistogramEncoding,
260
261    /// V3 metrics-intake protocol settings (`serializer_experimental_use_v3_api.*`).
262    pub v3_api: V3ApiEncoding,
263
264    /// Global and per-endpoint V3 series routing mode (`use_v3_api.series.*`).
265    pub v3_series_mode: V3SeriesMode,
266}
267
268/// V3 metrics-intake protocol settings for the series and sketches payloads
269/// (`serializer_experimental_use_v3_api.*`).
270#[derive(Clone, Debug, Default, PartialEq, Serialize)]
271pub struct V3ApiEncoding {
272    /// V3 series intake settings.
273    pub series: V3ApiSettings,
274
275    /// V3 sketches intake settings (the series-only fields stay at their defaults).
276    pub sketches: V3ApiSettings,
277
278    /// zstd compression level for V3 payloads.
279    pub compression_level: i32,
280}
281
282/// Per-payload V3 intake settings, reused for both series and sketches. Sketches read only
283/// `endpoints` and `validate`; the remaining series-only fields stay at their defaults.
284#[derive(Clone, Debug, PartialEq, Serialize)]
285pub struct V3ApiSettings {
286    /// Endpoints enabled for the V3 intake.
287    pub endpoints: Vec<String>,
288
289    /// Whether payloads are dual-sent to v2 and v3 for validation.
290    pub validate: bool,
291
292    /// Whether the beta V3 route is used instead of the stable one (series only).
293    pub use_beta: bool,
294
295    /// Route for the beta V3 series API (series only).
296    pub beta_route: String,
297
298    /// Shadow-mode sample rate (series only).
299    pub shadow_sample_rate: f64,
300
301    /// Sites for which shadow mode is enabled (series only).
302    pub shadow_sites: Vec<String>,
303}
304
305impl Default for V3ApiSettings {
306    fn default() -> Self {
307        Self {
308            endpoints: Vec::new(),
309            validate: false,
310            use_beta: false,
311            beta_route: "/api/intake/metrics/v3beta/series".to_string(),
312            shadow_sample_rate: 0.0,
313            shadow_sites: vec!["datadoghq.com".to_string()],
314        }
315    }
316}
317
318/// Global and per-endpoint V3 series routing mode (`use_v3_api.series.*`).
319#[derive(Clone, Debug, PartialEq, Serialize)]
320pub struct V3SeriesMode {
321    /// Global V3 series mode.
322    ///
323    /// Defaults to `datadog_only`, which enables V3 only for configured Datadog intake URLs.
324    /// TODO: consider modeling as an enum.
325    pub mode: String,
326
327    /// Per-endpoint V3 series mode overrides, keyed by endpoint URL.
328    pub endpoint_modes: HashMap<String, String>,
329}
330
331impl Default for V3SeriesMode {
332    fn default() -> Self {
333        Self {
334            mode: "datadog_only".to_string(),
335            endpoint_modes: HashMap::new(),
336        }
337    }
338}
339
340/// Histogram aggregation/encoding settings, shared by the DogStatsD and checks metrics pipelines.
341#[derive(Clone, Debug, Default, PartialEq, Serialize)]
342pub struct HistogramEncoding {
343    /// Which histogram aggregations (for example, `max` or `median`) are computed.
344    pub aggregates: Vec<String>,
345
346    /// Whether histograms are also emitted as distributions.
347    pub copy_to_distribution: bool,
348
349    /// Metric-name prefix applied to the distribution copies.
350    pub copy_to_distribution_prefix: String,
351
352    /// Which percentile aggregations are computed for histograms.
353    pub percentiles: Vec<String>,
354}
355
356/// Cluster Agent connection, shared by checks, DogStatsD, and OTLP.
357#[derive(Clone, Debug, Default, PartialEq, Serialize)]
358pub struct ClusterAgent {
359    /// Whether the Cluster Agent connection is used.
360    pub enabled: bool,
361
362    /// URL of the Cluster Agent.
363    pub url: Option<String>,
364
365    /// Token used to authenticate to the Cluster Agent.
366    pub auth_token: Option<String>,
367
368    /// Kubernetes service name used to discover the Cluster Agent.
369    pub kubernetes_service_name: Option<String>,
370}
371
372/// Autoscaling failover, shared by checks, DogStatsD, and OTLP.
373#[derive(Clone, Debug, Default, PartialEq, Serialize)]
374pub struct AutoscalingFailover {
375    /// Whether autoscaling metrics failover is active.
376    pub enabled: bool,
377
378    /// Metrics designated for failover.
379    pub metrics: Vec<String>,
380}