feat: add Dynatrace adaptor for Generic Log Ingest v2#3441
Open
StefanPostma wants to merge 3 commits into
Open
feat: add Dynatrace adaptor for Generic Log Ingest v2#3441StefanPostma wants to merge 3 commits into
StefanPostma wants to merge 3 commits into
Conversation
Adds Logflare.Backends.Adaptor.DynatraceAdaptor, an ingest-only backend that wraps WebhookAdaptor to POST log events to a Dynatrace environment's /api/v2/logs/ingest endpoint with an Api-Token header. Config takes a base environment URL (so SaaS, Managed and ActiveGate deployments are all supported) plus an API token with the logs.ingest scope. Each event is translated into Dynatrace's expected shape (timestamp / content / service / log.source / data) before being sent. Registers :dynatrace in Backend.adaptor_mapping, the backends_live dropdown, and the backend_form HEEx case clause. Tests mirror the DatadogAdaptor pattern: cast/validate, redaction, test_connection (success / 401 / nxdomain / trailing-slash url) and ingestion-path assertions on payload shape and service-name fallback. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Address review feedback on PR Logflare#3441: - Tighten URL validation to reject http://, with an explicit error message explaining why. The Dynatrace API token is a long-lived credential sent in the Authorization header, so allowing cleartext transport would expose both the credential and log payloads. - Make ingest_url/1 idempotent: if the configured URL already ends in /api/v2/logs/ingest the suffix is not appended again, so users who paste the full ingest URL get a sensible result instead of /api/v2/logs/ingest/api/v2/logs/ingest. - Add tests for both behaviors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Thanks for the contribution,please verify locally on dev and post a demo video to show that it works. |
Without the \A anchor, a url like "http://attacker.example.com/?x=https://anything" would satisfy the validate_format check and let the adaptor POST API tokens over cleartext to an unintended host. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Logflare.Backends.Adaptor.DynatraceAdaptor, an ingest-only backend that wrapsWebhookAdaptorto POST log events to a Dynatrace environment's Generic Log Ingest v2 endpoint ({env_url}/api/v2/logs/ingest, headerAuthorization: Api-Token <token>, scopelogs.ingest).api_token. Each event is translated into Dynatrace's expected shape (timestampISO 8601 /content/service/log.source/data) before being sent.redact_configmasks the token;test_connectionPOSTs an empty[]array.:dynatraceinBackend.adaptor_mapping, the backend-types dropdown inbackends_live.ex, and adds form fields inbackend_form.heex. Tests mirror theDatadogAdaptorpattern: cast/validate, redaction,test_connection(success / 401 / nxdomain / trailing-slash url) and ingestion-path assertions on payload shape and service-name fallback.Test plan
mix format --check-formatted— passes locallymix compile— passes locally on Elixir 1.19.5 / OTP 28 with no warnings touching the new filesmix test test/logflare/backends/adaptor/dynatrace_adaptor_test.exs— not run locally (no Postgres on the dev machine used to author this); needs to be run in a setup with the test DB🤖 Generated with Claude Code