Logs, metrics and alerts have different purposes
A log records an individual event with context. A metric summarises a trend, such as failed call counts or operation duration. An alert selects a condition from these signals for a responsible person to address. A dashboard alone provides no response path.
An API needs technical and business perspectives together. A gateway may see a fast HTTP response while a job accepted behind it remains stuck in a queue. Conversely, a 403 may reflect a correctly enforced rule and a 200 may contain a business error in its body.
OWASP therefore emphasises application events alongside infrastructure logs. They provide context a web-server log often lacks. OWASP: Logging Cheat Sheet.
Choose events around a concrete decision
On narrow screens, scroll the table sideways.
| Event | Useful context | Possible follow-up question |
|---|---|---|
| Authentication failed | Affected integration identifier, error category, time | Expired key, client migration or unusual use? |
| Object/function access denied | Verified actor/tenant reference, operation type, rule reason | Individual user error or systematic pattern? |
| Resource limit reached | Budget class, affected function, extent | Is the rule suitable, or is load crowding out ordinary users? |
| Webhook rejected or delayed | Integration, validation reason, age of open events | Key rotation, signature error or processing outage? |
| Privileged configuration changed | Acting identity, affected rule, change record | Was the change intended and traceable? |
| Job with uncertain outcome | Job reference, last reliably known state | Who resolves it without triggering a second effect? |
Not every individual event needs an immediate alert. Choose by impact and expected frequency. A rejected access is not proof of attack; multiple signals together may be much more meaningful.
Also capture the health of collection itself. No new logs may mean a quiet service or failed delivery. Without this context, the absence of an alert does not prove a healthy API.
Log only the data needed
A useful event reliably states ‘when, where, who, what and with what result’. Internal references, operation names and bounded error categories often suffice. Complete URLs may contain sensitive query values; a route template such as /exports/{id} suits many analyses better.
A self-created example illustrates the form, not a mandatory schema:
{
"timestamp": "2026-09-27T12:00:00Z",
"event": "api.authorization.denied",
"request_id": "demo-req-17",
"actor_ref": "demo-user-3",
"tenant_ref": "demo-org-2",
"operation": "export.read",
"reason": "object_not_accessible"
}
Actor and tenant references must come from verified application context. If identity is not established, a caller-claimed value must not be logged as a verified user. Even the example references might be personal data in a real application; shortening or pseudonymising an identifier does not automatically anonymise data.
Exclude access tokens, passwords, API secrets and complete sensitive payloads by default. Hashing a secret does not automatically make it a suitable log identifier. Instead, use a designated key ID, provided it grants no access itself.
Use structured output, fixed field types and bounded lengths. External text must not generate additional log lines or apparent system events. Safe encoding and limited field selection therefore belong in the log writer. OWASP explicitly covers data exclusions, log injection and verification. OWASP: ‘Data to exclude’, ‘Event collection’, ‘Verification’.
Organise correlation and access cleanly
An internal request ID connects related entries. Background jobs additionally need a durable job identifier because multiple requests and delivery attempts may be involved. Keep external correlation values separate and initially treat them as input, not trusted identity.
Ensure a traceable time basis across systems. Where sources are not reliably synchronised, retain visible uncertainty; displaying seconds does not prove actual event order.
Restrict read and modification access to logs and protect transport and storage. Access to particularly sensitive logs also needs accountable responsibility. Separate permissions and storage protected against later alteration can improve evidential value, but do not automatically create court-proof evidence.
Determine data scope, retention and deletion with the responsible privacy and legal functions. This technical guide sets neither a statutory retention period nor general permission for personal monitoring. Do not replace unresolved requirements with unlimited collection.
Connect each alert to an actionable first response
A useful alert includes the affected service, period, observed deviation and a safe entry into diagnosis. It also names responsibility and cover. A signal without a recipient may go unattended at the wrong moment.
For a growing webhook backlog, the first response might ask: is reception intact? Are signature errors or key rotation involved? Is only one integration growing, or the whole queue? Was a new receiver version deployed? These questions bound diagnosis to a testable flow.
Choose thresholds from normal operation and possible impact. A fixed number does not automatically fit every API. Consider rates and denominators too: twenty errors in twenty calls differs from twenty errors in a million.
Automatic blocking needs its own limits. If a third party can lock arbitrary accounts through failed login attempts, the protection itself becomes a problem. Alerting and an irreversible automatic action are therefore separate decisions.
Handle a key incident methodically
An exposed API key warrants response even without proven misuse. Name a responsible person and preserve necessary facts: affected key ID and permissions, known exposure location, period, observed use and actions taken. Do not copy the secret into more tickets or chats.
Restrict access through the designated revocation path and, if needed, provide a replacement with narrow permissions. Merely removing the value from a file does not invalidate a known key. Check which services use it and whether derived sessions or tokens need separate handling. OWASP: Secrets Management, sections 2.7 and 9.
Then investigate scope using your available data. ‘No unusual entries found’ is meaningful only within the checked period and available collection. A missing log must not count as proof of no effect.
Document containment, cause and recovery. Keep relevant evidence securely available instead of deleting all logs indiscriminately during cleanup. Where personal data or other reporting and notification consequences are involved, involve the responsible legal/privacy functions early; specific duties and deadlines need case-specific clarification.
NIST connects incident analysis, containment and verified recovery in its current SP 800-61 Revision 3 guidance. This is an organisational framework, not acceptance of your service. NIST SP 800-61r3, final April 2025.
Recovery means more than being reachable again
Before the affected function returns, check the original safeguard and incident cause. For the key example, this includes the old credential no longer working, the new one having intended permissions and the exposure cause being fixed. Also check whether open jobs continue correctly after interruption.
For rollback of a faulty logging change, keep the last tested writer or narrowly affected configuration available. Debug mode with complete payloads must not remain enabled indefinitely. A faulty alert rule can be corrected specifically; existing events and required baseline logging should remain.
Use the retrospective for a concrete improvement: add a missing event, clarify responsibility or make key rotation easier to verify. Completion needs an accountable decision and known residual uncertainty, not merely a green graph again.
Practise the operational process in your own environment
Using test identities, generate a permitted and a deliberately rejected event of your own. Check correct association and absence of secrets. In the isolated test, give the log writer oversized or newline-containing values and verify that format and limits remain intact.
Also simulate log-destination failure, a full buffer and a missing data stream there. Your application needs a deliberately defined response. It must neither silently fill unlimited memory nor expose sensitive debug data to clients because logging failed. Explicitly plan failure handling for actions with particularly strong evidence requirements.
Practise the alert path with a clearly labelled test message in your system and check whether the responsible role can perform diagnosis. No real alerts were triggered and no services, accounts or keys changed for this article. The JSON example is synthetic.
The API Security Check is a limited snapshot of public responses. It does not continuously monitor your API, receive internal logs or handle incident response. Your operational evidence instead connects events, alerting, decisions and verified recovery. Testing your own API security helps turn these promises into bounded test cases.
Sources and date
Sources checked: 27 September 2026. Links also appear alongside the statements they support.