In this lesson, you will learn how to systematically audit and report on the metrics that define your database’s Service Level Agreements (SLAs) regarding uptime and data durability.
The Role of Auditing in Reliability
While monitoring gives you real-time visibility into your cluster state, auditing is the retrospective process of proving that your database environment met its committed performance targets. To satisfy SLAs, you must translate raw telemetry into structured reliability reports that quantify Availability (uptime percentage) and Durability (recovery point success).
Measuring Availability (The "Nines")
Availability is typically audited by calculating the ratio of successful connection attempts or query executions against total requests over a rolling window. When auditing, you must filter out "planned" maintenance to distinguish between unavoidable downtime and reliability failures.
-- Auditing Availability Percentage
SELECT
(SUM(CASE WHEN status = 'SUCCESS' THEN 1 ELSE 0 END)::FLOAT / COUNT(*)) * 100 AS availability_percentage
FROM database_access_logs
WHERE timestamp >= NOW() - INTERVAL '30 days'
AND event_type = 'CONNECTION_ATTEMPT'
AND NOT is_planned_maintenance;
Measuring Durability (RPO Compliance)
Auditing for durability focuses on the Recovery Point Objective (RPO). You must prove that your backups or replica lag never exceeded a specific threshold. If your SLA dictates an RPO of 15 minutes, you audit your transaction logs against your immutable backup timestamps to ensure no gap exists that exceeds that window.
Reporting the Metrics
An effective audit report should include:
- MTTD (Mean Time to Detect): How long before an observability tool triggered an alert?
- MTTR (Mean Time to Recover): Time elapsed between the detected failure and the return to service.
- SLA Breach Count: A tally of incidents where the database failed to meet the agreed-upon uptime percentage.
By maintaining these audit logs—separate from your production data—you create a verifiable trail of accountability. This proves that your self-healing mechanisms and backup strategies are not just conceptually sound, but operationally compliant with the promises made to your stakeholders.
Key Takeaway: Auditing reliability transforms operational telemetry into verifiable evidence that your database is meeting its availability and durability SLAs.