Skip to main content

Send high-value security logs from your app

I'm trying to send security events from my application to Bower without becoming a Sentinel expert.

This guide gets a developer from zero to sending verified, redacted, high-value security events in about five minutes.

High-value security events vs application logs​

Keep your normal application logger (Serilog, Pino, logging, log/slog, Monolog, Logback) for debugging, performance diagnostics and operational traces. Send security decisions to Bower as structured events:

  • Application logs answer "Why did this request fail or run slowly?"
  • Bower security events answer "Who tried to sign in, who changed permissions, who exported sensitive data, and who was denied access?"

Bower is default-deny: the collector only accepts event types named by an approved policy, and it redacts sensitive data (Australian identifiers, cards, secrets, tokens) before anything is written to disk. Unknown event types are rejected with HTTP 422 and a clear reason.

Need concrete payloads first?

Jump straight to High-value security log examples for copy-paste JSON envelopes, before-and-after comparisons, and what not to send.

Choose how your app integrates​

I'm trying to…Use thisWhy
Send events from C# / ASP.NET CoreBower .NET SDKStrongly typed IBowerTelemetry and IAsvsTelemetry APIs with local buffering, retries and non-blocking delivery.
Send events from Next.jsNext.js guideRoute handlers, Server Actions, proxy.ts trusted client IP, and instrumentation.ts error hooks.
Send events from Express, Fastify or NestJSNode.js guideZero-dependency helper (bower-events.mjs) with trusted-proxy IP parsing and secret stripping.
Send events from Django, Flask or FastAPIPython guideStandard-library helper (bower_events.py) with middleware and signal wiring.
Send events from Go, Rails, Laravel or Spring BootWeb frameworks hubStandard-library helpers tested against one shared cross-language contract.
Send events from any other languagePOST /v1/events (this page + examples)Standard JSON envelope over HTTP with a Bearer ingest token.
Collect logs from an existing app you cannot modify yetLocal files, Syslog, or Custom parsersTail or receive existing logs and map them with a signed pack parser.

5-minute local quick start​

You do not need an Azure subscription or Sentinel workspace to test your application's security events. Run a throwaway local collector with BOWER_OUTPUT=none (nothing leaves your machine) and inspect every accepted, redacted and rejected event live.

Local test vs Sentinel proof

This local loop verifies your envelope schema, policy selection and redaction. It proves local collector receipt only — not arrival in Microsoft Sentinel. When you are ready to prove delivery in Sentinel, follow Your first verified event.

1. Start a local collector​

From the repository root:

dotnet build Bower.sln -c Release
examples/asvs-logging/run-local-collector.sh

The script starts a collector loaded with policies/default and the signed owasp-asvs-app-logging pack, using an ephemeral ingest token and HMAC key. Copy the two export lines it prints (BOWER_COLLECTOR_URL and BOWER_INGEST_TOKEN) into a second terminal.

2. Watch events live with bower tap​

In a second terminal (with BOWER_COLLECTOR_URL and BOWER_INGEST_TOKEN exported), open a live redacted view of what the collector accepts:

dotnet run --project src/Bower.Cli -- \
tap --collector "$BOWER_COLLECTOR_URL" --stage redacted

3. Send your first high-value event​

In a third terminal (with the same two environment variables exported), send a failed sign-in event — accepted by the shipped default policy (BWR-POL-AUTH-FAILURE):

curl -i -X POST "$BOWER_COLLECTOR_URL/v1/events" \
-H "Authorization: Bearer $BOWER_INGEST_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"schemaVersion": "1.0.0",
"eventId": "0195c8a2-7b4d-7000-8000-000000000001",
"timeGenerated": "2026-11-09T01:02:03.456Z",
"eventCategory": "authentication",
"eventType": "authentication_failure",
"eventAction": "authentication.attempt",
"eventResult": "failure",
"eventSeverity": "low",
"eventOutcomeReason": "InvalidCredentials",
"application": {
"name": "contoso-portal",
"environment": "development",
"version": "1.0.0"
},
"actor": {
"username": "alice@example.com",
"type": "human"
},
"source": {
"ipAddress": "203.0.113.24"
},
"request": {
"correlationId": "req-demo-001",
"method": "POST",
"path": "/api/login",
"statusCode": 401
},
"labels": {
"route": "/api/login"
}
}'

You should get HTTP 202 Accepted, and in your bower tap terminal you will see the stored event — notice that actor.username has already been pseudonymised with the host's HMAC key before touching disk.

4. See default-deny and idempotency in action​

Try two quick experiments so you know how Bower behaves before you ship code:

  1. Send the exact same curl command again. You get HTTP 200 OK — Bower deduplicates retries safely when eventId and content match. (If you reuse the same eventId with different content, Bower returns HTTP 409 Conflict.)
  2. Change "eventType" to "debug_http_request" and give it a new "eventId". You get HTTP 422 Unprocessable Entity — default-deny rejects event types not named by an approved policy, keeping noise out of Sentinel.

The 5 rules for high-value app events​

  1. Emit once at the authoritative decision point. Emit after the authentication check, permission check or database transaction has finished — never from controller, service and repository layers for the same action.
  2. Use a unique eventId, kept identical across retries. Generate one UUID (v7 or v4) per security event. Reusing an eventId for a different payload causes HTTP 409 (event-identity-conflict).
  3. Include investigation context. Always send UTC timeGenerated (ending in Z), request.correlationId (matching your X-Request-Id or W3C trace ID), the actor (actor.userId or actor.username), and the target where relevant (target.type and target.id).
  4. Trust X-Forwarded-For only from your own proxies. Read source.ipAddress from the direct peer unless that peer is in your configured TRUSTED_PROXIES list. See Client IP from trusted proxies only.
  5. Never send secrets, credentials or raw request data. Do not attach passwords, MFA codes, bearer tokens, cookies, Authorization headers, query strings, raw request bodies, SQL statements, or raw exception messages/stack traces. Bower redacts what it catches, but redaction is your safety net, not a reason to send secrets over the wire.

Reading collector HTTP responses​

Your application should send security events asynchronously with a short timeout (for example 2 seconds) and fail open for business requests — a slow or unreachable collector should never break sign-in or checkout.

HTTP statusWhat it meansWhat your app should do
202 AcceptedCollector validated, redacted and durably queued the event.Done. (Note: 202 means collector-queued, not yet verified in Sentinel.)
200 OKExact duplicate of an already-stored eventId.Done — safe retry outcome.
400 Bad RequestSchema invalid or quarantined because a required policy field is missing.Do not retry. Fix your payload; check bower tap or collector diagnostics for the missing field.
401 / 403Missing/invalid ingest token, or your token's producer scope does not allow this application.name or eventType.Do not retry. Check BOWER_INGEST_TOKEN and ask Security Operations to verify your producer scope.
409 ConflictSame eventId sent with different event content.Do not retry with the same ID. Fix ID generation so each distinct event gets a fresh UUID. See event identity conflicts.
422 Unprocessable EntityRejected by policy (unknown eventType or unmet policy match).Do not retry. Pick a supported type from the high-value examples or event catalogue, or check whether the ASVS pack is loaded.
503 Service UnavailableCollector queue is full or redaction is unavailable.Retry with bounded backoff, or buffer locally (Bower.Sdk handles this automatically).

Before going to staging or production​

Ask your security or platform team for four things:

  1. Collector URL (BOWER_COLLECTOR_URL, typically local loopback http://127.0.0.1:4319 on the same host, or an internal HTTPS endpoint).
  2. A dedicated ingest token (BOWER_INGEST_TOKEN) with a producer scope pinned to your application.name — stored in your secret manager, never in source control.
  3. Which policies/packs are active — policies/default alone covers authentication_failure, account_lockout, role_membership_changed and sensitive_data_exported. Adding the signed owasp-asvs-app-logging pack adds sign-in success, MFA, authorisation failures, session lifecycle, sensitive data access, admin/config changes, anti-automation and application errors.
  4. Your ingress proxy CIDRs (TRUSTED_PROXIES) so source.ipAddress records the real client address.

Next steps​