DuoWorkflowSessionCreditsSyncStale
This playbook covers both freshness alerts of the v2 Duo Agent Platform session credits sync:
| Alert | Fires when |
|---|---|
DuoWorkflowSessionCreditsSyncStale | A top-level group in scope has not had a complete sync for more than 18 hours |
DuoWorkflowSessionCreditsSyncFirstSyncOverdue | A top-level group has been in scope for more than 7 days without any complete sync |
Overview
Section titled “Overview”The sync copies Duo Agent Platform credit usage from CustomersDot into ClickHouse. A group is in scope when CustomersDot billed it for Duo Agent Platform sessions in the last 90 days.
- Every 6 hours,
Ai::DuoWorkflows::SyncSessionCreditsCronWorkerlists the groups in scope from the CustomersDotsessionNamespacesquery and enqueues oneAi::DuoWorkflows::SyncNamespaceSessionCreditsWorkerjob per group in scope. - A job that reads every page CustomersDot has for the group completes the sync (
stop_reason: completed). A job that runs out of its 120-second budget stops withover_timeand continues on the next tick. - At the start of every tick, the cron observes each group in scope: how long ago its last complete sync was, or, for a group with no complete sync since it entered scope, how long it has been waiting.
When an alert fires, credit usage in GitLab is stale or missing for some groups. Find which groups and why (see Troubleshooting), then act on the cause.
Services
Section titled “Services”- Sidekiq service overview
- Failed syncs alert
- Owner: group::optimize, Slack
#g_analytics_optimize
Metrics
Section titled “Metrics”Two histograms, observed once per group in scope at the start of every tick. Both have bucket edges at 6h, 12h, 16h, 18h, 24h, 48h and 7 days.
duo_workflow_session_credits_v2_sync_age_seconds: seconds since the group’s last complete sync.duo_workflow_session_credits_v2_awaiting_sync_seconds: seconds a group has been in scope without a complete sync.
Each alert counts the observations above its threshold in the last 7 hours, one tick plus slack: the +Inf bucket’s increase minus the threshold bucket’s.
- 18 hours allows two missed ticks. A group that completes every tick is under 6 hours old at the next tick, and each missed tick adds 6 hours, so over 18 hours means the last three ticks did not complete.
- 7 days for groups awaiting a first sync, because a new group reads up to 90 days of sessions and can take several ticks to finish. That is normal for groups new to Duo Agent Platform.
Under normal conditions both counts are 0.
Alert Behavior
Section titled “Alert Behavior”- Both alerts are
s3: they do not page, and in gprd go to#g_analytics_optimize. - An alert fires 10 to 15 minutes after the tick that observed the group and clears 7 hours after the last tick that still sees it over the threshold.
- The alerts measure only groups in scope. A group that CustomersDot stops listing drops out of scope after two ticks and is not alerted on.
- The alerts measure nothing, and stay silent, if the cron does not run, if ClickHouse analytics is disabled, if the cron cannot list groups from CustomersDot (
stop_reason: cdot_erroron its done line), or if Redis SharedState fails during the tick (the done line then has nooldest_*fields). A CustomersDot outage that only fails the namespace jobs does not stop the measurement: the cron still observes every group in scope while their syncs fail. - A group CustomersDot has no subscription for (
failure_reason: no_cdot_subscription_found) counts as synced: there is nothing in CustomersDot to go stale. - Only a job that reads every page completes a sync. A group whose jobs end with
over_time,rate_limited,undefined_fieldorno_billable_licenseon every tick never completes, so it can be stale or awaiting a first sync while the failed syncs alert stays silent.
Severities
Section titled “Severities”- Impact: customers of the affected top-level groups see stale or missing Duo Agent Platform credit usage in GitLab. Billing data in CustomersDot is not affected.
- Incident severity: usually
S4. Raise toS3if many groups are affected, or customers report it.
Verification
Section titled “Verification”Groups over the threshold per tick:
sum by (env) (increase(duo_workflow_session_credits_v2_sync_age_seconds_bucket{env="gprd", le="+Inf"}[7h]))-sum by (env) (increase(duo_workflow_session_credits_v2_sync_age_seconds_bucket{env="gprd", le=~"64800|64800.0"}[7h]))Replace the metric with duo_workflow_session_credits_v2_awaiting_sync_seconds and the edge with 604800 for groups awaiting a first sync.
Kibana, pubsub-sidekiq-inf-gprd index, cron done lines:
json.class: "Ai::DuoWorkflows::SyncSessionCreditsCronWorker" and json.job_status: "done"Under json.extra.ai_duo_workflows_sync_session_credits_cron_worker.*:
oldest_sync_age_s: the oldest last complete sync among synced groups, in seconds.namespaces_awaiting_syncandoldest_awaiting_sync_s: groups waiting for a first sync, and the longest wait.namespaces_enumerated,namespaces_enqueued,namespace_jobs_bufferedandstop_reason.
Troubleshooting
Section titled “Troubleshooting”-
Check whether the failed syncs alert or a concurrency limit alert for
Ai::DuoWorkflows::SyncNamespaceSessionCreditsWorker(such asSidekiqConcurrencyLimitQueueGrowing) is firing too. They usually name the cause. -
Find the affected groups. In Kibana, take the namespace job done lines of the last day and look for groups whose runs never end in
stop_reason: completed:json.class: "Ai::DuoWorkflows::SyncNamespaceSessionCreditsWorker" and json.job_status: ("done" or "fail")Break the results down by
json.extra.ai_duo_workflows_sync_namespace_session_credits_worker.root_namespace_idandstop_reason. -
For one group, read its freshness record in a Rails console:
Ai::DuoWorkflows::SessionCredits::SyncFreshness.status(<root_namespace_id>)# => { last_completed_at:, last_seen_in_scope_at:, in_scope_since: } -
Act on what the group’s runs show:
| Runs of the group | Likely cause | Action |
|---|---|---|
stop_reason: error with failure_reason server_error or connection_error for many groups | CustomersDot outage | Follow the failed syncs playbook. The groups recover on the first tick after CustomersDot does. |
stop_reason: rate_limited | CustomersDot rate-limited the group’s job; the next tick resumes from the stored page token | Act only if it repeats for many groups: contact the Fulfillment team in #g_monetization_platform. |
stop_reason: error | A failure specific to the group, named by failure_reason | Follow the failure_reason table in the failed syncs playbook. |
stop_reason: interrupted | Sidekiq shut down mid-job, for example during a deploy, and re-queued it | Expected on deploy-heavy days. Act only if it repeats for the same group on quiet days. |
stop_reason: over_time on every tick | The group has more sessions than one 120-second job can read; cursor_lag_s keeps growing | Expected for a few ticks after the group enters scope. If it never catches up, open an issue: the job budget or page size may need tuning for the group. |
| No runs at all | The job never ran, usually queued behind the concurrency limit | Check namespace_jobs_buffered on the cron’s done line and the worker’s concurrency limit queue. |
Possible Resolutions
Section titled “Possible Resolutions”- CustomersDot outage: the groups recover on their own on the first tick after CustomersDot does.
Dependencies
Section titled “Dependencies”- CustomersDot GraphQL
sessionNamespacesandsessionsqueries. - ClickHouse (
duo_workflow_session_enrichments,sync_cursors). - Redis SharedState (freshness records, page tokens).
Escalation
Section titled “Escalation”- group::optimize in
#g_analytics_optimize. - CustomersDot problems: the Fulfillment team in
#g_monetization_platform.
Definitions
Section titled “Definitions”- Alert definition, generator wiring and unit tests.
- The thresholds must sit on bucket edges of the histograms, which the Rails code defines.
- Update the template used to format this playbook