Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The `datadog_metrics` sink now uses zstd compression when submitting metrics to the Series v2 endpoint (`/api/v2/series`). Series v1 and Sketches continue to use zlib (deflate).

authors: vladimir-dd
2 changes: 1 addition & 1 deletion distribution/docker/debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LABEL org.opencontainers.image.documentation="https://vector.dev/docs"

# we want the latest versions of these
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata systemd && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata systemd libsasl2-2 && rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/bin/vector /usr/bin/vector
COPY --from=builder /usr/share/vector /usr/share/vector
Expand Down
2 changes: 1 addition & 1 deletion regression/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
# TARGET
#
FROM docker.io/debian:trixie-slim@sha256:c85a2732e97694ea77237c61304b3bb410e0e961dd6ee945997a06c788c545bb
RUN apt-get update && apt-get dist-upgrade -y && apt-get -y --no-install-recommends install zlib1g ca-certificates && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get dist-upgrade -y && apt-get -y --no-install-recommends install zlib1g ca-certificates libsasl2-2 && rm -rf /var/lib/apt/lists/*
COPY --from=builder /vector/vector /usr/bin/vector
RUN mkdir --parents --mode=0777 /var/lib/vector

Expand Down
33 changes: 27 additions & 6 deletions src/sinks/datadog/metrics/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ impl DatadogMetricsEndpoint {
}
}

// Gets whether or not this is a series endpoint.
pub const fn is_series(self) -> bool {
matches!(self, Self::Series { .. })
}

pub(super) const fn payload_limits(self) -> DatadogMetricsPayloadLimits {
// from https://docs.datadoghq.com/api/latest/metrics/#submit-metrics
let (uncompressed, compressed) = match self {
Expand All @@ -112,6 +107,32 @@ impl DatadogMetricsEndpoint {
compressed,
}
}

/// Returns the compression scheme used for this endpoint.
pub(super) const fn compression(self) -> DatadogMetricsCompression {
match self {
Self::Series(SeriesApiVersion::V2) => DatadogMetricsCompression::Zstd,
_ => DatadogMetricsCompression::Zlib,
}
}
}

/// Selects the compressor for a given Datadog metrics endpoint.
#[derive(Clone, Copy, Debug)]
pub(super) enum DatadogMetricsCompression {
/// zlib (deflate) — used by Series v1 and Sketches.
Zlib,
/// zstd — used by Series v2.
Zstd,
}

impl DatadogMetricsCompression {
pub(super) const fn content_encoding(self) -> &'static str {
match self {
Self::Zstd => "zstd",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Send Datadog v2 metrics with zstd1 encoding token

For Series v2, content_encoding() now emits "zstd", but Datadog’s generated Metrics v2 client docs for submit_metrics list allowed content_encoding values as deflate, zstd1, and gzip (see MetricsAPI#submit_metrics allowable values at https://datadoghq.dev/datadog-api-client-ruby/DatadogAPIClient/V2/MetricsAPI.html). If the intake strictly validates this enum, all v2 requests from this change will carry an invalid Content-Encoding header and be rejected with 4xx responses, causing metric loss.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@vladimir-dd vladimir-dd Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex agreed?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t agree with the “nah” reply.

src/sinks/datadog/metrics/config.rs currently sets Series v2 to Content-Encoding: zstd at line 132, not zstd1.
Given Datadog’s generated Metrics v2 client docs/code show allowed content_encoding values as deflate, zstd1, and gzip, this looks like a real compatibility risk if intake enforces that enum. (Source: https://datadoghq.dev/datadog-api-client-ruby/DatadogAPIClient/V2/MetricsAPI.html)

The datadog-agent reference is useful context, but it doesn’t conclusively prove the public v2 intake accepts zstd token interchangeably with zstd1 for this endpoint. So from a PR-review safety standpoint, I’d treat this as a valid P1 until proven otherwise.

Checks run

  • sed -n '110,150p' src/sinks/datadog/metrics/config.rs
  • nl -ba src/sinks/datadog/metrics/config.rs | sed -n '120,145p'

View task →

Copy link
Contributor Author

@vladimir-dd vladimir-dd Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn’t conclusively prove the public v2 intake accepts zstd token

are you saying that datadog agent might be failing all metrics requests today? that would be a disaster, wouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Updated Datadog Metrics v2 Content-Encoding token from "zstd" to "zstd1" in DatadogMetricsCompression::content_encoding(), while keeping v1/sketches on "deflate". This addresses the review-thread compatibility concern for /api/v2/series header enum handling.
  • Committed the change on the current branch as 413541c.
  • Created a follow-up PR via make_pr titled [Follow-up] Use \zstd1` Content-Encoding token for Datadog Metrics v2`.

Testing

  • make check-clippy
  • cargo test --no-default-features --features sinks-datadog_metrics datadog_metrics --lib

View task →

Self::Zlib => "deflate",
}
}
}

/// Maps Datadog metric endpoints to their actual URI.
Expand Down Expand Up @@ -270,7 +291,7 @@ impl DatadogMetricsConfig {
endpoint_configuration,
self.default_namespace.clone(),
self.series_api_version,
)?;
);

let protocol = self.get_protocol(dd_common);
let sink = DatadogMetricsSink::new(
Expand Down
Loading
Loading