From 183681c19a1f6164446b6d5ee6518fb9a9764249 Mon Sep 17 00:00:00 2001 From: Mackenzie <63265430+mackjmr@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:44:23 +0200 Subject: [PATCH] [exporter/datadogexporter] Add support for custom log source (#35051) **Description:** This PR updates `github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter` to include commit: https://github.com/DataDog/datadog-agent/commit/09b07ebe76698d875721f6a482b5176ba2df7ed9. This adds support for setting a custom log source from resource attribute or log attribute `datadog.log.source`. **Link to tracking Issue:** **Testing:** Tested this locally by sending logs with attribute `datadog.log.source` and ensuring this was used as the source. **Documentation:** Updated datadog exporter README. --- .chloggen/mackjmr_custom-log-src-support.yaml | 27 +++++++++++++++++++ exporter/datadogexporter/README.md | 14 ++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .chloggen/mackjmr_custom-log-src-support.yaml diff --git a/.chloggen/mackjmr_custom-log-src-support.yaml b/.chloggen/mackjmr_custom-log-src-support.yaml new file mode 100644 index 0000000000000..888a50e302062 --- /dev/null +++ b/.chloggen/mackjmr_custom-log-src-support.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: datadogexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add support for setting a custom log source from resource attribute `datadog.log.source` + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [35051] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/exporter/datadogexporter/README.md b/exporter/datadogexporter/README.md index ecb7c4341f6fb..bc9803f3bae3d 100644 --- a/exporter/datadogexporter/README.md +++ b/exporter/datadogexporter/README.md @@ -72,3 +72,17 @@ To get the service field correctly populated in your logs, you can specify servi [alpha]:https://github.com/open-telemetry/opentelemetry-collector#alpha [contrib]:https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib [AWS]:https://aws-otel.github.io/docs/partners/datadog + +### How to add custom log source + +In order to add a custom source to your OTLP logs, set resource attribute `datadog.log.source`. This feature requires `exporter.datadogexporter.UseLogsAgentExporter` feature flag to be enabled (now enabled by default). + +Example: +``` +processors: + transform/logs: + log_statements: + - context: resource + statements: + - set(attributes["datadog.log.source"], "otel") +```