Skip to content

fix(datadog_metrics sink): preserve dd agent v2 series resources - #25973

Open
tessneau wants to merge 5 commits into
masterfrom
fix-datadog-metric-resource-roundtrip
Open

fix(datadog_metrics sink): preserve dd agent v2 series resources#25973
tessneau wants to merge 5 commits into
masterfrom
fix-datadog-metric-resource-roundtrip

Conversation

@tessneau

@tessneau tessneau commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserves datadog agent metric resources when forwarding them through a v2 datadog_metrics sink. This
applies only to metrics received from a datadog_agent source; v1 behavior is unchanged.

The datadog agent converts dd.internal.resource:<type>:<name> tags into series resources, which it then encodes in the v2 protobuf resources field.

Vector currently represents unknown resources internally as resource.<type> tags, which was leading to some integration dashboards e.g. mongo integration check not working. This change converts those tags
back into v2 resources before forwarding the metrics.

Vector configuration

sources:
  agent:
    type: datadog_agent
    address: 0.0.0.0:8181
    multiple_outputs: true
    disable_logs: true
    disable_traces: true
    store_api_key: false

sinks:
  datadog:
    type: datadog_metrics
    inputs:
      - agent.metrics
    default_api_key: "${DD_API_KEY}"
    site: "${DD_SITE}"
    series_api_version: v2
    batch:
      timeout_secs: 1

How did you test this PR?

Besides the updated tests, I did a manual test:

DogStatsD → Datadog Agent 7.80.4 → Vector → Datadog v2 series intake

With the above vector config. I then emitted the following to the datadog agent's dogstatsd port (8125)

vector.resource_roundtrip:1|g|#dd.internal.resource:database_instance:vector-tess-test,test_source:vector-resource-live

After the metric reached Datadog, this query returned the series:

avg:vector.resource_roundtrip{database_instance:vector-tess-test}

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.

@github-actions github-actions Bot added domain: sources Anything related to the Vector's sources domain: sinks Anything related to the Vector's sinks labels Jul 30, 2026
@tessneau
tessneau force-pushed the fix-datadog-metric-resource-roundtrip branch from 645bed7 to cd4d384 Compare August 3, 2026 12:49
@tessneau
tessneau marked this pull request as ready for review August 4, 2026 16:35
@tessneau
tessneau requested a review from a team as a code owner August 4, 2026 16:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd4d3848f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sinks/datadog/metrics/encoder.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not crazy about adding source specific logic into the encoder but the alternative of adding first-class support for arbitrary resources to Vector’s generic metric model felt pretty invasive for this fix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agree, makes sense to me

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4be28772c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sinks/datadog/metrics/encoder.rs Outdated
Comment thread src/sources/datadog_agent/metrics.rs
@pront pront self-assigned this Aug 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b4fa44424

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +644 to +648
if let Some(values) = tags.remove_set(&tag) {
for value in values {
match value {
TagValue::Value(name) => {
resources.push(ddmetric_proto::metric_payload::Resource {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Track resource values before promotion

Fresh evidence: this commit now records only the resource type keys in metadata, not the specific values that decode_ddseries_v2 inserted. If a v2 Agent series also carries an ordinary tag with the same key, such as resource.database_instance:custom, or a transform adds one after decoding, remove_set takes the whole value set and every TagValue::Value is emitted as a protobuf resource, so the ordinary tag is still removed/misclassified in v2 output. Preserve per-value provenance or otherwise promote only values that came from the original resources field.

Useful? React with 👍 / 👎.

Comment thread src/common/datadog.rs Outdated

if !resource_types.is_empty() {
metadata.value_mut().insert(
vrl::path!("datadog_agent", "v2_resource_types"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: could we use the constants for both values, since they are used in the method below?

@vladimir-dd

vladimir-dd commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

overall looks good to me, but wondering if we could simplify it for this single specific use case and just populate resources at the sink from tags, prefixed with dd.internal.resource: only(no custom logic at the source)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: sinks Anything related to the Vector's sinks domain: sources Anything related to the Vector's sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants