Repository navigation
Description
Part of #5164 (child 7).
Problem or Motivation
The job grades (#5164) must show on a dashboard and drive alerts. Today each panel of the row Roadmap Job Success scans 7 days of the Service log: one 7-day ratio query scanned about 414,000 lines on 2026-11-12. Prometheus has no series of the result lines, so an alert with a promtool test cannot read them, and no history of a ratio exists for the baselines of child 9.
- Loki (
k8s/logging/loki-values.yaml, Monolithic) has no ruler configuration. - Prometheus has
web.enable-remote-write-receiverand keeps 30 days. Its rules live inserverFilesofk8s/monitoring/prometheus-values.yaml.
Proposed Solution & Architectural Design
- Turn on the Loki ruler: local rule storage from a ConfigMap,
remote_writeto the Prometheus remote-write receiver, a WAL directory. Add the network policy fromloggingtomonitoring. - Loki recording rules, every 1 minute, over
[1m], on the base query ofjob-success.md(all streams, child 4):devops_cli:job_attempts:count1mbyroadmap_job,repo,version,success,first_pass,infra,failure_class.devops_cli:job_tokens:sum1m,devops_cli:job_seconds:sum1m,devops_cli:job_cost_usd_micros:sum1m,devops_cli:job_model_calls:sum1m,devops_cli:job_gh_requests:sum1m(sum_over_time ... | unwrap) byroadmap_job,repo,version,success.
- Prometheus recording rules, with promtool tests, for the windows 6h, 24h and 7d: attempts, successes and first-pass attempts with
infra=false, the infrastructure share,p, the Wilson 95% lower and upper bounds (sqrtarithmetic, z = 1.96), the point grade (100, 90, 80, 70, 60, 0; no series under 30 attempts), and tokens, seconds, cost, model calls and GitHub requests for each success. - The p90 and max of tokens and seconds stay Loki queries: a quantile does not come from 1-minute sums.
- A missed ruler evaluation loses 1 minute of counts. The alert
RoadmapJobResultsMissingof feat(roadmap): a dashboard and alerts for the pipeline #3655 finds a gap.
Target Subsystem
Kubernetes monitoring (k8s/logging/, k8s/monitoring/prometheus-values.yaml).
Existing Tool Considered
Loki ruler recording rules with remote write (Grafana Loki docs, "Recording rules") and Prometheus recording rules. Rejected: Grafana-managed recording rules (state in the Grafana database, no promtool); Sloth (#4709) for each job (one objective and burn windows; tens of attempts a day are too few); a Prometheus counter in the Service (job-success.md gives the reason). Cost: about 300,000 tokens, 6 hours elapsed.
Acceptance Criteria
promtool test rulespasses for each Prometheus rule, with a case at 22 of 25, a case under 30 attempts and a case with infrastructure cuts.- The Loki rules pass
lokitool rules lint(or the check that the Loki chart gives). - After the deploy,
devops_cli:job_attempts:count1mhas series in Prometheus, and the 24-hour sums equal the Lokicount_over_timeof the same window within 2%.
Dependencies
#5168 (the counts), #5169 (the streams).
Alternatives check of 2026-11-22: in-use.
The repository already uses this tool.
Tool: grafana/loki (https://github.com/grafana/loki), AGPL-3.0, last activity 2026-11-22, maintained.
Reason: Searches found no single tool that both reads the result-line logs and computes promtool-tested grades. Loki, already the cluster's log store, covers the ruler recording rules and remote write of the one-minute aggregates; the grade and Wilson rules stay Prometheus work.
Covers:
- Ruler loads local recording rules from a ConfigMap
- Recording rules aggregate the LogQL result-line query every minute
- remote_write pushes the samples to the Prometheus receiver
- Labels roadmap_job, repo, version, success and failure_class kept
Lacks:
- No promtool test rules for the grade formula
- Wilson 95% bounds and point grade need Prometheus rules
- p90 and max of tokens and seconds need raw samples
- No 6h, 24h and 7d ratio history without remote write
Proposed design
Problem statement
The Roadmap Job Success row scans seven days of Loki logs for each panel, about 414,000 lines for one ratio query on 2026-11-12. Prometheus holds no series of the job result lines, so a promtool alert test cannot read the grades and child 9 has no ratio history. This change records one-minute job result aggregates in Loki and remote-writes them to Prometheus, then computes the grades and Wilson bounds as Prometheus recording rules.
Acceptance criteria
Requirement: Loki ruler remote write
The Loki ruler SHALL load local rules from a ConfigMap, keep its WAL on a volume, and remote-write samples to the Prometheus remote-write receiver.
Scenario: Rendered Loki values enable the ruler
- WHEN
uv run devops ci --check --only k8sruns the Loki chart check. - THEN The check passes and the rendered Loki configuration has the ruler enabled with local rule storage, a WAL directory and a remote-write URL for Prometheus.
Requirement: Ruler network policy
The logging namespace SHALL reach the Prometheus remote-write receiver in monitoring.
Scenario: The network policy permits the remote write
- WHEN
uv run devops ci --check --only k8sruns. - THEN The check passes and the rendered network policy permits egress from
loggingpods to the Prometheus service port inmonitoring.
Requirement: Loki one-minute rules
The Loki recording rules SHALL aggregate the all-streams result-line query every minute into the attempt count and five sum series, with roadmap_job, repo, version, success, first_pass, infra and failure_class labels on the attempt count and roadmap_job, repo, version and success on each sum.
Scenario: The rule group is valid
- WHEN
uv run devops ci --check --only k8srenders the Loki rules. - THEN The check passes and the group holds
devops_cli:job_attempts:count1m,devops_cli:job_tokens:sum1m,devops_cli:job_seconds:sum1m,devops_cli:job_cost_usd_micros:sum1m,devops_cli:job_model_calls:sum1manddevops_cli:job_gh_requests:sum1mwith the required labels.
Requirement: Prometheus grade rules
The Prometheus recording rules SHALL compute attempts, successes, first-pass attempts, infrastructure share, p, Wilson 95% bounds, and the point grade in bands 100, 90, 80, 70, 60 and 0 for 6h, 24h and 7d, with no grade series under 30 attempts.
Scenario: The grade rule cases pass
- WHEN
promtool test rulesruns on the new Prometheus rule test files. - THEN Every case passes, including 22 successes of 25 attempts as grade 80, fewer than 30 attempts with no grade series, and infrastructure cuts left out of the success ratio.
Requirement: Prometheus per-success resources
The Prometheus recording rules SHALL compute tokens, seconds, cost, model calls and GitHub requests for each success.
Scenario: The resource rule cases pass
- WHEN
promtool test rulesruns on the new Prometheus rule test files. - THEN Each case passes and each per-success series equals the fixture sum divided by the success count.
Requirement: Prometheus rule file registration
The Prometheus server SHALL load the new recording rule file from serverFiles.prometheus.yml.rule_files with the four chart defaults and devops_cli_alerting_rules.yml.
Scenario: The rendered Prometheus config lists the new rule file
- WHEN
uv run devops ci --check --only k8sruns the Prometheus chart check. - THEN The check passes and the rendered
prometheus.ymlrule_fileslists the new recording rule file afterdevops_cli_alerting_rules.yml.
Requirement: Live Prometheus and Loki parity
The deployed Prometheus SHALL hold the one-minute attempt series, and each 24-hour sum SHALL match the Loki count of the same window within 2%.
Scenario: The live parity check passes
- WHEN The live check runs
promtool query instanton Prometheus andlogcli instant-queryon Loki for the same 24-hour window. - THEN Prometheus returns
devops_cli:job_attempts:count1mseries and each sum differs from the Loki count by no more than 2%.
Existing Tool Considered
The alternatives check in the issue body records an in-use verdict for grafana/loki (https://github.com/grafana/loki), an open, maintained tool. The proposal uses the Loki ruler and remote write for the one-minute aggregates. It uses Prometheus recording rules for the promtool-tested grade and Wilson rules, which Loki lacks. The change builds configuration, not code.
Key questions
- Which component records the one-minute job result aggregates?: Use the Loki ruler with recording rules and remote write to Prometheus. Loki holds the result-line streams. Prometheus already accepts remote write. (best practice) [sources: k8s/logging/loki-values.yaml, k8s/monitoring/prometheus-values.yaml, docs/roadmap/job-success.md]
- Chosen: Loki ruler and Prometheus rules. It reads the log lines where they live and writes samples to the existing receiver.
- Rejected: Prometheus scrape of a Service counter.
docs/roadmap/job-success.mdrejects a counter in the Service. - Rejected: Grafana-managed recording rules. The rules live in the Grafana database and
promtoolcannot test them. - Rejected: Sloth SLO rules. One objective and burn windows need more attempts than tens a day.
- How do the Prometheus grade rules prove the formula offline?: Use
promtool test ruleswith fixture series for the 6h, 24h and 7d windows. The tests cover 22 of 25 attempts, fewer than 30 attempts, and infrastructure cuts. (best practice) [sources: k8s/monitoring/prometheus-values.yaml, docs/roadmap/job-success.md]- Chosen: promtool test rules. The project keeps Prometheus rule files in
serverFilesand can test them with promtool. - Rejected: Python unit tests on query strings. They check text, not the result of the rule.
- Rejected: No rule tests. The issue requires a test case for the grade formula.
- Chosen: promtool test rules. The project keeps Prometheus rule files in
- What is the grade formula and the minimum attempt count?: The grade is the floor of the success ratio of attempts with no infrastructure cut, in bands 100, 90, 80, 70, 60 and 0. It is 100 when each attempt is a first pass. Fewer than 30 attempts gives no grade. [sources: src/devops_cli/roadmap/job_grade.py:166, docs/roadmap/job-success.md, CONTEXT.md]
- What is the base query for the Loki recording rules?: The base query is the all-streams result-line query in
docs/roadmap/job-success.mdfrom child 4. The rules aggregate it over[1m]and keeproadmap_job,repo,version,success,first_pass,infraandfailure_class. [sources: docs/roadmap/job-success.md, src/devops_cli/roadmap/job_result.py] - Should the p90 and max of tokens and seconds become Prometheus rules?: No. Keep the p90 and max as Loki queries. A quantile does not come from one-minute sums. (best practice) [sources: docs/roadmap/job-success.md]
- Chosen: Keep p90 and max in Loki. A quantile needs the raw samples, not one-minute sums.
- Rejected: Add Prometheus quantile rules. The issue records no histogram buckets for a quantile rule.
- Where does the Prometheus server load the new recording rules?: Add the new recording rule file to
serverFiles.prometheus.yml.rule_files. Keep the four chart defaults anddevops_cli_alerting_rules.yml. [sources: k8s/monitoring/prometheus-values.yaml]
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 12, 2026
Both are children of #5164 and deal with job grades, but #5165 delivers a CLI command while this candidate delivers Prometheus and Loki recording rules.devops-cli-service commentedon Nov 17, 2026
Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.
devops-cli-service commentedon Nov 22, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (8)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 22, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.