Skip to content

feat: add Dynatrace adaptor for Generic Log Ingest v2#3441

Open
StefanPostma wants to merge 3 commits into
Logflare:mainfrom
StefanPostma:feat/dynatrace-adaptor
Open

feat: add Dynatrace adaptor for Generic Log Ingest v2#3441
StefanPostma wants to merge 3 commits into
Logflare:mainfrom
StefanPostma:feat/dynatrace-adaptor

Conversation

@StefanPostma

Copy link
Copy Markdown

Summary

  • Adds Logflare.Backends.Adaptor.DynatraceAdaptor, an ingest-only backend that wraps WebhookAdaptor to POST log events to a Dynatrace environment's Generic Log Ingest v2 endpoint ({env_url}/api/v2/logs/ingest, header Authorization: Api-Token <token>, scope logs.ingest).
  • Config takes a base environment URL (so SaaS, Managed, and ActiveGate deployments all work — the path is appended automatically) and an api_token. Each event is translated into Dynatrace's expected shape (timestamp ISO 8601 / content / service / log.source / data) before being sent. redact_config masks the token; test_connection POSTs an empty [] array.
  • Registers :dynatrace in Backend.adaptor_mapping, the backend-types dropdown in backends_live.ex, and adds form fields in backend_form.heex. 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.

Test plan

  • mix format --check-formatted — passes locally
  • mix compile — passes locally on Elixir 1.19.5 / OTP 28 with no warnings touching the new files
  • mix test test/logflare/backends/adaptor/dynatrace_adaptor_test.exsnot run locally (no Postgres on the dev machine used to author this); needs to be run in a setup with the test DB
  • Manual smoke: create a Dynatrace backend in the UI, attach to a source, ingest a few events, confirm they land in Dynatrace's log viewer

🤖 Generated with Claude Code

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>
Comment thread lib/logflare/backends/adaptor/dynatrace_adaptor.ex Outdated
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>
Comment thread lib/logflare/backends/adaptor/dynatrace_adaptor.ex Outdated
@Ziinc

Ziinc commented May 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution,please verify locally on dev and post a demo video to show that it works.
For clarity, this PR does not mean that this adaptor will trickle down into the supabase platform as we are being very selective about what log drain destinations are exposed.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants