Skip to content

feat: add auth metrics emission#19552

Open
cecemei wants to merge 4 commits into
apache:masterfrom
cecemei:deny
Open

feat: add auth metrics emission#19552
cecemei wants to merge 4 commits into
apache:masterfrom
cecemei:deny

Conversation

@cecemei
Copy link
Copy Markdown
Contributor

@cecemei cecemei commented Jun 4, 2026

Description

Introduces an opt-in mechanism to emit Druid service metrics for authorization events. When enabled, Druid emits metrics for access denials and authorization exceptions, making it easier to monitor and alert on security-relevant events.

Changes

New config flag (AuthConfig)

  • Adds emitAuthMetrics boolean property (default: false)
  • Enable via runtime config: druid.auth.emitAuthMetrics=true

AuthorizerMapper

  • Accepts an optional ServiceEmitter to pass through to authorization utilities
  • Defaults to null (no-op) when metrics are disabled

AuthorizerMapperModule

  • Injects ServiceEmitter directly instead of via Injector (cleaner dependency graph)
  • Wires the emitter into AuthorizerMapper only when emitAuthMetrics is enabled

AuthorizationUtils

  • Adds private emitAuthMetric() helper that fires metrics with dimensions: identity, authorizerName, resourceName, resourceType, action, and errorMessage
  • Emits auth/accessDenied on denied resource access
  • Emits auth/exception on internal errors (missing authorizer, duplicate policies, double-authorization check)

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@github-actions github-actions Bot added Area - Batch Ingestion Area - Querying Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Jun 4, 2026
@cecemei cecemei changed the title feat: add auth metric feat: add auth metrics emission Jun 4, 2026
@cecemei cecemei marked this pull request as ready for review June 4, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Batch Ingestion Area - Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Querying

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant