Skip to content

feat(k8s): alert when Crawl4AI fetches fail #3893

Closed

Description

@dan-petty

Problem

Crawl4AI is a heavy pod (Chromium, 2.3 GB image) with a record of 14 or more advisories in 5 months. If it is down or if it fails often, the refine and alternatives jobs lose their page text without a visible sign. The Firecrawl search already has alerts on devops_cli_firecrawl_searches_total in k8s/monitoring/prometheus-values.yaml; the fetch has none.

Expected

Alert rules in k8s/monitoring/prometheus-values.yaml: (1) the error ratio of devops_cli_crawl4ai_fetches_total over one hour above a limit, with a minimum count so that one failure does not fire; (2) the Deployment crawl4ai has no ready replica for 15 minutes, if kube-state-metrics runs (check first; if not, rule 1 only). The alerts follow the shape of the Firecrawl alerts. k8s/README.md lists them.

Acceptance criteria

  • The existing promtool and rule tests fail on the base for the new rules and pass with them (a rule test with a synthetic series that fires and one that does not).
  • The alert text names the counter label and the log command, and holds no secret.
  • The rule does not fire when crawl4ai.url is unset (no series).

Existing tool considered

Prometheus rules in the existing values file, promtool. No new tool.

Related

Related: the manifests issue and the client issue (the counter). Do not scrape Crawl4AI's own /metrics: it needs the token.

Proposed design

Problem statement

Crawl4AI is a heavy pod with a history of security advisories. If it fails, the refine and alternatives jobs lose page text with no visible sign. The Firecrawl search has alerts, but the Crawl4AI fetch has none. Add two Prometheus alert rules, their promtool tests, and the README rows.

Acceptance criteria

Requirement: crawl4ai-fetch-error-alert

The crawl4ai rule group SHALL fire Crawl4aiFetchErrors when the ratio of non-ok results to all devops_cli_crawl4ai_fetches_total results over one hour is above 0.2 and the total is at least 5.

Scenario: Frequent fetch failures fire

  • WHEN A synthetic devops_cli_crawl4ai_fetches_total{job="roadmap-service",result="ok"} series has 3 and a result="error" series has 2 in one hour.
  • THEN promtool test rules reports Crawl4aiFetchErrors firing with the expected labels and annotations.

Requirement: crawl4ai-fetch-error-quiet

Crawl4aiFetchErrors SHALL NOT fire when the total fetches in one hour is below 5 or the error ratio is 0.2 or less.

Scenario: One failure stays quiet

  • WHEN A synthetic series has 4 ok results and 1 error result in one hour.
  • THEN promtool test rules reports no Crawl4aiFetchErrors alert.

Requirement: crawl4ai-no-series-quiet

Crawl4aiFetchErrors SHALL NOT fire when devops_cli_crawl4ai_fetches_total has no series.

Scenario: Crawl4AI URL is unset

  • WHEN The rule test supplies no devops_cli_crawl4ai_fetches_total series.
  • THEN promtool test rules reports no Crawl4aiFetchErrors alert.

Requirement: crawl4ai-unavailable-alert

The crawl4ai rule group SHALL fire Crawl4aiUnavailable when kube_deployment_status_replicas_available{namespace="devops",deployment="crawl4ai"} is below 1 for 15 minutes.

Scenario: No ready replica fires

  • WHEN A synthetic kube_deployment_status_replicas_available series for devops/crawl4ai stays at 0 for 15 minutes.
  • THEN promtool test rules reports Crawl4aiUnavailable firing with the expected labels and annotations.

Requirement: crawl4ai-alert-text

The annotations of Crawl4aiFetchErrors and Crawl4aiUnavailable SHALL name the counter or Deployment and the log command, and SHALL contain no token or secret.

Scenario: Annotations name the cause and the log

  • WHEN The rule tests render the annotations of both alerts.
  • THEN The fetch annotation contains devops_cli_crawl4ai_fetches_total and result; both annotations contain kubectl -n devops logs deploy/crawl4ai; neither contains CRAWL4AI_API_TOKEN.

Requirement: crawl4ai-rule-test-pin

The alerting test SHALL pin the crawl4ai group and its test file, so the test fails on the base commit and passes with the rules.

Scenario: Rule test fails on base

  • WHEN tests/test_k8s_monitoring_alerting.py runs on the base commit and on the change.
  • THEN It fails on the base commit and passes on the change.

Requirement: crawl4ai-readme-alerts

k8s/README.md SHALL list Crawl4aiFetchErrors and Crawl4aiUnavailable in its Alerting table.

Scenario: README lists both alerts

  • WHEN The Alerting table in k8s/README.md is read.
  • THEN It has one row for Crawl4aiFetchErrors and one for Crawl4aiUnavailable with their fire conditions.

Requirement: crawl4ai-no-metrics-scrape

The change SHALL NOT add a scrape target or ServiceMonitor for Crawl4AI's /metrics endpoint.

Scenario: No new scrape target

  • WHEN The rendered Prometheus scrape configuration and k8s-monitoring values are checked.
  • THEN No scrape target names crawl4ai or port 11235.

Existing Tool Considered

No alternatives check has run. Prometheus alerting rules and the pinned promtool cover the need. The tool has no built-in Crawl4AI alert, so the change writes two rule expressions and their tests. No new tool or application code is needed.

Key questions

  • Which counter and label identify a failed Crawl4AI fetch?: devops_cli_crawl4ai_fetches_total counts each fetch by result. The value ok is a success. Every other value is an HTTP status or error. [sources: docs/TELEMETRY.md:94, src/devops_cli/telemetry/instruments.py, openspec/changes/archive/2026-11-07-3887-crawl4ai-page-text/specs/crawl4ai-page-text/spec.md:24]
  • Does kube-state-metrics run, so the Deployment rule can use its series?: Yes. k8s-monitoring deploys kube-state-metrics. Existing rules read kube_deployment_status_replicas_available. [sources: k8s/README.md, k8s/monitoring/prometheus-values.yaml]
  • Which expression and threshold detect frequent fetch failures?: Use the ratio of non-ok results to all results over one hour. Fire when the ratio is above 0.2 and the total is at least 5. Select job="roadmap-service". (best practice) [sources: k8s/monitoring/prometheus-values.yaml, docs/TELEMETRY.md:94]
    • Chosen: Ratio over 1h with minimum 5. One failure in five is 20% and does not fire. Two failures in five fire. The 1-hour window smooths low volume.
    • Rejected: Absolute error count. A count of 1 fires on one failure. It also hides a high error ratio at low volume.
    • Rejected: Any non-ok fetch. One failed fetch fires, which the issue forbids.
  • Which expression detects a Crawl4AI Deployment with no ready replica?: Use kube_deployment_status_replicas_available{namespace="devops", deployment="crawl4ai"} < 1 for 15 minutes. (best practice) [sources: k8s/monitoring/prometheus-values.yaml, k8s/README.md]
    • Chosen: Available replicas below 1. It matches the issue wording and the existing Mattermost rule.
    • Rejected: Unavailable replicas above 0. It fires during a normal Recreate rollout while a replica still serves.
  • Which severity and pending period should each rule use?: Use severity warning for both rules. Use for: 10m for Crawl4aiFetchErrors and for: 15m for Crawl4aiUnavailable. (best practice) [sources: k8s/monitoring/prometheus-values.yaml, k8s/README.md]
    • Chosen: warning, 10m and 15m. Page text loss degrades refinement but does not stop the Service. The 15m matches the issue.
    • Rejected: critical, 0m and 15m. It pages for a degraded page-text path and ignores the 1-hour ratio window.
  • Where should the rules live and how should the tests run?: Add a crawl4ai group under serverFiles.alerting_rules.yml. Add tests/fixtures/prometheus_rules/crawl4ai_tests.yaml. Pin the group and its test file in tests/test_k8s_monitoring_alerting.py. (best practice) [sources: k8s/monitoring/prometheus-values.yaml, k8s/README.md]
    • Chosen: New crawl4ai group and test file. The alerts concern the Crawl4AI dependency, not one roadmap row. The existing test runner discovers a group from its pinned test file.
    • Rejected: Add to roadmap-service-activity. It mixes the Crawl4AI dependency health with the Service's own write activity.
  • Should the change scrape Crawl4AI's own /metrics?: No. The client counter and kube-state-metrics cover both alerts. Crawl4AI's /metrics needs the bearer token. (best practice) [sources: k8s/README.md, docs/TELEMETRY.md:94]
    • Chosen: Use client counter and kube-state-metrics. It needs no token and adds no scrape.
    • Rejected: Scrape Crawl4AI /metrics. The endpoint needs the bearer token, and the issue forbids the scrape.
  • Does Crawl4aiFetchErrors fire when crawl4ai.url is unset?: No. With no URL, the client sends no fetch and the counter has no series. The ratio expression then returns no vector. [sources: k8s/README.md, docs/TELEMETRY.md:94]
  • What should the alert annotations say?: The fetch alert names devops_cli_crawl4ai_fetches_total and its result label. Both alerts name deployment/crawl4ai and the command kubectl -n devops logs deploy/crawl4ai. They hold no token. (best practice) [sources: k8s/monitoring/prometheus-values.yaml, k8s/README.md]
    • Chosen: Name the counter, deployment and log command. An operator can identify the failed fetch and read the service log without a secret.
    • Rejected: Name only the alert name. The operator cannot find the counter or the log.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/k8s
    status/new
    value/medium
    effort/low
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. Operational visibility for a heavy pod with a known advisory record, but not a blocker for other work.
    • Value: Medium. Gives operators a visible signal when Crawl4AI is down or failing, preventing silent loss of page text in refine and alternatives jobs.
    • Effort: Low. Two alert rules in an existing values file following the Firecrawl pattern, plus a README line and a synthetic rule test.
    • Related: feat(k8s): run Crawl4AI 0.9.5 in namespace devops #3884, which asks for a different change. Both concern the Crawl4AI deployment in k8s; #3884 creates the Deployment and Service while the candidate adds Prometheus alert rules for that Deployment.
  3. added
    priority/p2-medium
    owner/agent
    on Nov 7, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  5. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at a6fff84 (see proposed design in issue body).

  6. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 7, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 7, 2026
  8. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor
  9. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-07 22:00 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/k8ssource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions