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.
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 this | Why |
|---|---|---|
| Send events from C# / ASP.NET Core | Bower .NET SDK | Strongly typed IBowerTelemetry and IAsvsTelemetry APIs with local buffering, retries and non-blocking delivery. |
| Send events from Next.js | Next.js guide | Route handlers, Server Actions, proxy.ts trusted client IP, and instrumentation.ts error hooks. |
| Send events from Express, Fastify or NestJS | Node.js guide | Zero-dependency helper (bower-events.mjs) with trusted-proxy IP parsing and secret stripping. |
| Send events from Django, Flask or FastAPI | Python guide | Standard-library helper (bower_events.py) with middleware and signal wiring. |
| Send events from Go, Rails, Laravel or Spring Boot | Web frameworks hub | Standard-library helpers tested against one shared cross-language contract. |
| Send events from any other language | POST /v1/events (this page + examples) | Standard JSON envelope over HTTP with a Bearer ingest token. |
| Collect logs from an existing app you cannot modify yet | Local files, Syslog, or Custom parsers | Tail 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.
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:
- Send the exact same
curlcommand again. You get HTTP200 OK— Bower deduplicates retries safely wheneventIdand content match. (If you reuse the sameeventIdwith different content, Bower returns HTTP409 Conflict.) - Change
"eventType"to"debug_http_request"and give it a new"eventId". You get HTTP422 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
- 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.
- Use a unique
eventId, kept identical across retries. Generate one UUID (v7 or v4) per security event. Reusing aneventIdfor a different payload causes HTTP409(event-identity-conflict). - Include investigation context. Always send UTC
timeGenerated(ending inZ),request.correlationId(matching yourX-Request-Idor W3C trace ID), the actor (actor.userIdoractor.username), and the target where relevant (target.typeandtarget.id). - Trust
X-Forwarded-Foronly from your own proxies. Readsource.ipAddressfrom the direct peer unless that peer is in your configuredTRUSTED_PROXIESlist. See Client IP from trusted proxies only. - Never send secrets, credentials or raw request data. Do not attach passwords, MFA codes,
bearer tokens, cookies,
Authorizationheaders, 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 status | What it means | What your app should do |
|---|---|---|
202 Accepted | Collector validated, redacted and durably queued the event. | Done. (Note: 202 means collector-queued, not yet verified in Sentinel.) |
200 OK | Exact duplicate of an already-stored eventId. | Done — safe retry outcome. |
400 Bad Request | Schema 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 / 403 | Missing/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 Conflict | Same 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 Entity | Rejected 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 Unavailable | Collector 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:
- Collector URL (
BOWER_COLLECTOR_URL, typically local loopbackhttp://127.0.0.1:4319on the same host, or an internal HTTPS endpoint). - A dedicated ingest token (
BOWER_INGEST_TOKEN) with a producer scope pinned to yourapplication.name— stored in your secret manager, never in source control. - Which policies/packs are active —
policies/defaultalone coversauthentication_failure,account_lockout,role_membership_changedandsensitive_data_exported. Adding the signedowasp-asvs-app-loggingpack adds sign-in success, MFA, authorisation failures, session lifecycle, sensitive data access, admin/config changes, anti-automation and application errors. - Your ingress proxy CIDRs (
TRUSTED_PROXIES) sosource.ipAddressrecords the real client address.
Next steps
- Browse copy-paste payloads for every scenario: High-value security log examples
- Wire up your stack: ASP.NET Core SDK or Web frameworks (Next.js, Node, Python, Go, Rails, Laravel, Spring Boot)
- See the full list of accepted event types: Default security event catalogue
- Accept logs from anywhere or external third parties (Azure Functions + APIM): Hosting behind Azure API Management
- Prove events arrive in Sentinel: Your first verified event