Skip to content

Conversation

@jakehwll
Copy link
Contributor

@jakehwll jakehwll commented Dec 3, 2025

Related to internal#1139

This implements some prometheus metrics for records being removed from the database. Currently we're tracking the following fields being removed from the DB by this. They're viewable in the /api/v2/debug/metrics endpoint.

  • expired_api_keys
  • aibridge_records
  • connection_logs
  • duration
# HELP coderd_dbpurge_iteration_duration_seconds Duration of each dbpurge iteration in seconds.
# TYPE coderd_dbpurge_iteration_duration_seconds histogram
coderd_dbpurge_iteration_duration_seconds_bucket{success="true",le="1"} 1
coderd_dbpurge_iteration_duration_seconds_bucket{success="true",le="5"} 1
coderd_dbpurge_iteration_duration_seconds_bucket{success="true",le="10"} 1
coderd_dbpurge_iteration_duration_seconds_bucket{success="true",le="30"} 1
coderd_dbpurge_iteration_duration_seconds_bucket{success="true",le="60"} 1
coderd_dbpurge_iteration_duration_seconds_bucket{success="true",le="300"} 1
coderd_dbpurge_iteration_duration_seconds_bucket{success="true",le="600"} 1
coderd_dbpurge_iteration_duration_seconds_bucket{success="true",le="+Inf"} 1
coderd_dbpurge_iteration_duration_seconds_sum{success="true"} 0.014787814
coderd_dbpurge_iteration_duration_seconds_count{success="true"} 1
# HELP coderd_dbpurge_records_purged_total Total number of records purged by type.
# TYPE coderd_dbpurge_records_purged_total counter
coderd_dbpurge_records_purged_total{record_type="aibridge_records"} 0
coderd_dbpurge_records_purged_total{record_type="audit_logs"} 0
coderd_dbpurge_records_purged_total{record_type="connection_logs"} 0
coderd_dbpurge_records_purged_total{record_type="expired_api_keys"} 0
coderd_dbpurge_records_purged_total{record_type="workspace_agent_logs"} 0
Position Pull-request
feat: add prometheus observability metrics for dbpurge
feat: add rbac specificity for dbpurge

@jakehwll jakehwll changed the title feature: dbpurge prometheus observability metrics feature: add prometheus observability metrics for dbpurge Dec 3, 2025
@jakehwll jakehwll changed the title feature: add prometheus observability metrics for dbpurge feat: add prometheus observability metrics for dbpurge Dec 3, 2025
@jakehwll jakehwll requested review from dannykopping and removed request for dannykopping December 9, 2025 00:26
@jakehwll jakehwll marked this pull request as ready for review December 12, 2025 12:03
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a test to validate that at least one of the metrics is set correctly?

Looking good otherwise 👍

Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jakehwll jakehwll merged commit 00793cc into main Dec 19, 2025
30 checks passed
@jakehwll jakehwll deleted the jakehwll/dbpurge-observability-metrics-prometheus branch December 19, 2025 13:21
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants