GhaylStackDocumentationv1.0.2
العربيةWebsite
Platform modules

Platform modules

Audit history and investigation

Trace activity, data changes and security events while controlling access, captured data and retention.

Follow an operation across the system

Auditing records activity, entity changes, security events and exceptions. HTTP middleware captures request activity, an EF Core interceptor observes saved changes, and IAuditClient lets modules record explicit events. A background worker delivers queued audit records to the configured sink.

Start an investigation with the tenant, approximate time, user and action. Use /api/v1/audits to list and search records, then follow their correlation or trace identifiers. The module also exposes detail, security, exception and summary endpoints. Audit history explains recorded operations; the business module remains the authority for its current state.

Search with bounded filters

The listing accepts filters including time range, user, event type, severity, source, correlation ID, trace ID and search text. When no time range is supplied, the handler uses a seven-day window. It limits a requested window to 90 days and orders newest first.

Use narrower windows and a source or user filter before free-text search. A broad JSON payload search has different database cost from an indexed tenant and time lookup. If an older record seems missing, inspect the effective range and retention settings before assuming it was never recorded.

Respect tenant boundaries

Reading requires Permissions.AuditTrails.View. Requesting another tenant additionally requires Permissions.AuditTrails.ViewCrossTenant, registered as a root permission. The cross-tenant path still applies an explicit target-tenant predicate rather than returning every tenant's records.

Test an ordinary tenant administrator and a specifically authorized operator separately. Do not solve a missing audit screen by giving all users cross-tenant inspection. Audit payloads may contain business information beyond what appears in a summary row.

Control the captured data

The Auditing options class enables body capture by default and limits request and response previews to 8,192 and 16,384 bytes. JSON and problem JSON are allowed content types. Health, metrics and API documentation paths are excluded by default.

JsonMaskingService masks JSON properties whose names contain known sensitive terms such as password, token, secret, API key or connection string. This is a field-name rule, not a guarantee that arbitrary personal or confidential content is removed. Review custom payloads and use the provided NoAudit or body-only exclusion metadata where appropriate.

Configure retention and add explicit events

Auditing:Retention:Enabled defaults to false. When deliberately enabled, its default retention periods are 30 days for activity, 90 for entity changes, 365 for security and 180 for exceptions. The default purge schedule is 03:30 UTC and deletes in batches of 5,000. Choose periods according to your application's requirements before enabling deletion.

For a meaningful application event, use IAuditClient.WriteActivityAsync, WriteSecurityAsync, WriteEntityChangeAsync or WriteExceptionAsync. Include a useful source and action name, and avoid copying entire documents into audit previews. Keep the write in the existing scope so correlation information can accompany the record.

Verify and troubleshoot

Change a development record and locate its activity and entity-change entries. Compare user, tenant, timestamp and correlation identifiers. Submit a harmless test payload with a field named password and inspect masking; also review any custom sensitive fields you introduce.

If recent entries are absent, inspect the background worker, database health and dead-letter sink alongside capture exclusions. If a request succeeds but its audit record is delayed, distinguish the asynchronous audit pipeline from the business transaction. Test retention on disposable data before enabling a purge against an existing environment.

Implementation references

View MarkdownBack to top

Search documentation

Use ↑ ↓ to move, Enter to open and Esc to close.