Skip to content

Keep audit instance logs out of the authorization audit trail - #6196

Open
johnsimons wants to merge 1 commit into
masterfrom
john/audit_instance_logging
Open

johnsimons wants to merge 1 commit into
masterfrom
john/audit_instance_logging

Conversation

@johnsimons

Copy link
Copy Markdown
Member

The NLog rule for the authorization audit trail matched every logger whose name starts with ServiceControl.Audit. That prefix is also the namespace of the audit instance, so the rule captured every entry at Info or above that the audit instance writes from its own classes. Those entries lost the operational layout: no timestamp, level, logger name or exception. Outside a container they also went to audit.json instead of logfile.txt, mixed in with the ECS documents. Debug and Trace entries were not affected, because the rule starts at Info. The rule came in with #5518 and has shipped since 6.18.0.

The audit trail categories, ServiceControl.Audit and ServiceControl.Audit.Messages, now each have a rule that matches the exact name. No logger writes to a name below those two categories, so no audit trail entry moves to the operational log.

Before and after

In each run, the logging configuration received two sample authorization decisions and two messages from audit instance classes. This is the audit.json it wrote outside a container.

Before, on master:

Found persistence manifest for PostgreSQL
{"@timestamp":"2026-11-26T22:40:32.8471470+00:00","ecs":{"version":"8.11.0"},"event":{"kind":"event","category":["iam"],"type":["allowed"],"action":"audit:message:view","outcome":"success"},"user":{"id":"8f14e45f","name":"Alice Smith","roles":["reader"]},"servicecontrol":{"permission":"audit:message:view","reason":"User holds 'audit:message:view' via role(s) [reader]"}}
Processing of message 'fa0a1625-af14-4a17-9870-b50e0069779c' failed
{"@timestamp":"2026-11-26T22:40:32.8715750+00:00","ecs":{"version":"8.11.0"},"event":{"kind":"event","category":["iam"],"type":["denied"],"action":"audit:saga:view","outcome":"failure"},"user":{"id":"c9f0f895","name":"Bob Jones"},"servicecontrol":{"permission":"audit:saga:view","reason":"User has no roles granting 'audit:saga:view'"}}

After, on this branch:

{"@timestamp":"2026-11-26T22:40:00.1194890+00:00","ecs":{"version":"8.11.0"},"event":{"kind":"event","category":["iam"],"type":["allowed"],"action":"audit:message:view","outcome":"success"},"user":{"id":"8f14e45f","name":"Alice Smith","roles":["reader"]},"servicecontrol":{"permission":"audit:message:view","reason":"User holds 'audit:message:view' via role(s) [reader]"}}
{"@timestamp":"2026-11-26T22:40:00.1374840+00:00","ecs":{"version":"8.11.0"},"event":{"kind":"event","category":["iam"],"type":["denied"],"action":"audit:saga:view","outcome":"failure"},"user":{"id":"c9f0f895","name":"Bob Jones"},"servicecontrol":{"permission":"audit:saga:view","reason":"User has no roles granting 'audit:saga:view'"}}

On this branch the two text lines go to logfile.txt with the full layout.

The audit rule used a prefix pattern (`AuthorizationAuditLog.AuditCategory*`), which also matched the audit instance's own loggers under the `ServiceControl.Audit` namespace (e.g. `AuditPersister`). Those loggers were being routed to the audit target instead of the operational log.

Switch to exact-name matching per audit category and split the authorization and message-action audit categories into separate rules, so only genuine audit events are final-routed to the audit target while audit instance diagnostics keep flowing to the operational log with the full layout.
@johnsimons johnsimons self-assigned this Nov 26, 2026

@warwickschroeder warwickschroeder left a comment

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.

Nice catch

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants