Skip to content

fix(k8s): Measure SearXNG throttle and stop CAPTCHA repeat #4201

Closed

Description

@devops-cli-service

Split from #4141.

Problem or Motivation The duckduckgo engine of SearXNG raises SearxEngineCaptchaException with suspended_time=0. SearXNG does not suspend the engine, so the next query asks it again and gets the CAPTCHA again. The 3-hour log of 2026-11-08 also holds Too many request (suspended_time=180) for superuser, stackoverflow, askubuntu and arxiv, and HTTP 400 from api.stackexchange.com for the three Stack Exchange engines. The cause of the throttle is not proven: the query rate, or a flag on the cluster egress address. ## Why this part is deferred The fix waits on a measure that does not exist yet. The measure needs at least 3 days of real Service traffic in devops_cli_web_searches_total by backend and result, and a person's query from another egress address, to tell the two causes apart. #4141 removes only the three Stack Exchange engines, because they return HTTP 400 on each request without an API key. ## Acceptance Criteria - The issue holds the query rate for each backend and the share of each result, over at least 3 days, split into Service traffic and check or manual traffic. - The issue names the cause: the query rate or the cluster egress address. - A test over the searxng-settings ConfigMap holds the engine set that the measure chooses, and the test fails before the change. - A devops k8s searxng-check run gets at least one hit for the general category. - The settings add no retry loop (#4094).

Alternatives check of 2026-11-20: in-use.
The repository already uses this tool.
Tool: searxng/searxng (https://github.com/searxng/searxng), AGPL-3.0, last activity 2026-11-19, maintained.
Reason: Searches surfaced SearXNG itself as the only per-engine measure: its OpenMetrics endpoint exposes each engine's request, error and reliability counts, so it covers the engine-level throttle measure; the caller split and password handling are integration work.

Covers:

  • Per-engine request and error counts
  • Engine reliability and suspended-engine state
  • Scrapeable OpenMetrics endpoint behind basic auth

Lacks:

  • No environment variable for the metrics password
  • Cannot split Service from check or manual traffic
  • Metric name unverified until the first scrape

Proposed design

Problem statement

The duckduckgo engine of SearXNG answers with a CAPTCHA and suspended_time=0. SearXNG does not suspend the engine, so the next query asks it again. Other engines return Too many request. The cause is not proven: it is the query rate, or a flag on the cluster egress address. The search counter counts a reply by backend and result, so a refused engine hides behind another engine's hits. This change enables the OpenMetrics endpoint of SearXNG and scrapes its per-engine series. A separate item names the cause from that series, and #5595 chooses the engine set.

Acceptance criteria

Requirement: OpenMetrics password placeholder

The searxng-settings ConfigMap SHALL set general.open_metrics to the placeholder ${SEARXNG_METRICS_PASSWORD}, SHALL hold no password, and SHALL add no retry loop.

Scenario: Manifest check passes with the placeholder

  • WHEN uv run devops ci --check --only k8s runs on the branch that holds the new k8s/devops/searxng/configmap.yaml
  • THEN the check exits 0 and reports no error for k8s/devops/searxng/configmap.yaml

Requirement: Rendered settings at pod start

The SearXNG Deployment SHALL render /etc/searxng/settings.yml at pod start from the settings ConfigMap and the metrics password Secret.

Scenario: Live check after the rollout

  • WHEN uv run devops k8s searxng-check runs after the rollout of the new Deployment
  • THEN the check exits 0 and its general row holds at least one hit, so the pod started on the rendered file

Requirement: Metrics Secret from the keyring

devops k8s push-secrets SHALL write the searxng-metrics-auth basic-auth Secret from the keyring entry searxng_metrics_password.

Scenario: Push table row for the metrics Secret

  • WHEN the unit test reads the secret push table of devops k8s push-secrets
  • THEN the table holds a row that writes Secret searxng-metrics-auth in namespace devops with username searxng and the password from keyring entry searxng_metrics_password, and the test fails before the change

Requirement: ServiceMonitor scrapes the metrics

A ServiceMonitor SHALL scrape /metrics of the SearXNG Service on its port 8080 with the searxng-metrics-auth basic-auth Secret.

Scenario: Manifest check passes with the new ServiceMonitor

  • WHEN uv run devops ci --check --only k8s runs on the branch that adds k8s/devops/searxng/servicemonitor.yaml
  • THEN the check exits 0 and reports no error for the new ServiceMonitor

Requirement: Perimeter admits the scrape

The searxng-perimeter-ingress NetworkPolicy SHALL admit the monitoring namespace to TCP port 8080.

Scenario: Manifest check passes with the new ingress peer

  • WHEN uv run devops ci --check --only k8s runs on the branch that changes k8s/devops/searxng/networkpolicy.yaml
  • THEN the check exits 0 and reports no error for k8s/devops/searxng/networkpolicy.yaml

Existing Tool Considered

The alternatives check in the issue body records the verdict in-use for searxng/searxng (https://github.com/searxng/searxng), AGPL-3.0, maintained. The block of that check lists what the tool covers and what it lacks. This proposal does what the tool lacks: general.open_metrics reads no environment variable, so an init container renders settings.yml at pod start from the ConfigMap and a keyring-backed Secret. The change builds no tool of its own; the render is one init container of a few shell lines, about 15k tokens to build, about 2k tokens a month to keep and fix, and about 3 hours of elapsed time.

Key questions

  • Which measure shows the refusal of each SearXNG engine?: The OpenMetrics endpoint of SearXNG. The settings set general.open_metrics, and a ServiceMonitor scrapes /metrics with basic auth. (best practice) [sources: k8s/devops/searxng/configmap.yaml, docs/CLUSTER.md:243, docs/TELEMETRY.md]
    • Chosen: SearXNG OpenMetrics endpoint. It gives the request, error and reliability counts of each engine, and the cluster already scrapes its workloads.
    • Rejected: devops_cli_web_searches_total by backend and result. A reply with hits from another engine counts ok, so a refused engine leaves no trace.
    • Rejected: A new counter on the web-search chain. It measures the client's view and not the engine's, and it adds code that the project keeps.
  • Which settings key enables the endpoint, and does it read an environment variable?: general.open_metrics holds the password of the /metrics endpoint. It reads no environment variable, so the value stays in settings.yml as the placeholder ${SEARXNG_METRICS_PASSWORD} and an init container writes the Secret value at pod start. (best practice) [sources: k8s/devops/searxng/configmap.yaml, k8s/devops/searxng/deployment.yaml]
    • Chosen: general.open_metrics with a rendered placeholder. The key holds the password, the settings stay in git under review, and the Secret stays out of git.
    • Rejected: An environment variable. open_metrics reads no environment variable.
    • Rejected: The whole settings.yml in a Secret. The engine set leaves git, and no test can hold it.
    • Rejected: The password in the ConfigMap. It puts a secret in git.
  • How does the metrics password reach the pod with no secret in git?: A kubernetes.io/basic-auth Secret searxng-metrics-auth holds username searxng and the keyring password, and devops k8s push-secrets writes it. An init container renders settings.yml from the ConfigMap and the Secret into an emptyDir, and the SearXNG container mounts that file. (best practice) [sources: src/devops_cli/k8s/cluster_secrets.py, k8s/devops/searxng/deployment.yaml, k8s/README.md]
    • Chosen: Secret and a render step. The settings stay in git under review, and the password stays in the keyring and the Secret.
    • Rejected: The whole settings.yml in a Secret. The engine set leaves git, and no test can hold it.
    • Rejected: The password in the ConfigMap. It puts a secret in git.
  • Which port and path does the scrape use?: Port 8080, the SearXNG HTTP port that the container names http. The Service port that targets it must carry the same name for the ServiceMonitor. The path is /metrics. [sources: k8s/devops/searxng/service.yaml, k8s/devops/searxng/deployment.yaml]
  • Where does the ServiceMonitor live?: In k8s/devops/searxng/servicemonitor.yaml, next to the Service, and k8s/devops/searxng/kustomization.yaml lists it. k8s/llm/gateway/servicemonitor.yaml is the same pattern for the gateway. [sources: k8s/llm/gateway/servicemonitor.yaml, k8s/devops/searxng/kustomization.yaml, k8s/devops/searxng/service.yaml]
  • Which namespace does the ingress rule admit for the scrape?: The namespace of the Prometheus stack under k8s/monitoring/. The rule selects it by the automatic label kubernetes.io/metadata.name on that namespace. [sources: k8s/monitoring/prometheus-values.yaml]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

#5595, #6753

Activity

  1. added
    source/agent
    type/bug
    scope/k8s
    status/new
    value/medium
    effort/medium
    on Nov 9, 2026
  2. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    ContributorAuthor

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

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. The fix waits on 3 days of traffic data, so the item is not urgent.
    • Value: Medium. The change makes the web search more reliable for the roadmap jobs.
    • Effort: Medium. The measure needs 3 days of traffic data, and the test needs a new check.
    • Related: fix(k8s): SearXNG engines are throttled from the cluster #4141, which asks for a different change. Both items address the SearXNG throttle. #4141 removes three engines; the candidate measures the cause and stops the DuckDuckGo CAPTCHA repeat.
  3. changed the title [-]fix(k8s): measure the SearXNG throttle and stop the duckduckgo CAPTCHA repeat[/-] [+]fix(k8s): Measure SearXNG throttle and stop CAPTCHA repeat[/+] on Nov 9, 2026
  4. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    ContributorAuthor

    The job shortened the title of this item. The summary had 67 characters, and the limit is 60. The type and the scope stay.

    • Before: fix(k8s): measure the SearXNG throttle and stop the duckduckgo CAPTCHA repeat
    • After: fix(k8s): Measure SearXNG throttle and stop CAPTCHA repeat
    • Source of the summary: the background model
  5. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    ContributorAuthor

    Refine cannot set this item to Ready at 816cfe0 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Who runs the query from another egress address? (a person decides)
  6. dan-petty commented on Nov 12, 2026

    @dan-petty
    Owner

    Scope from the cluster integration plan (2026-11-12)

    The cluster integration plan #4989 gives this item its measure (rank 14). This issue is now a sub-issue of #4989.

    1. Set general.open_metrics in the SearXNG settings.
    2. Scrape /metrics with basic auth from a ServiceMonitor.
    3. Admit monitoring on 8080 in searxng-perimeter.
    4. Alert on searxng_engines_reliability_total below 50 for 1 h.

    open_metrics reads no environment variable. So settings.yml moves to a Secret that devops k8s push-secrets writes, or a start step renders it.

    Owner decision (decision 2 on #4989): the metrics password is a new Secret. The recommended answer is to approve it: push-secrets writes the Secret from the keyring, and a start step renders the password into settings.yml, so settings.yml stays in git with no secret.

    Why: SearXNG is the only search provider that answers, and a failing engine shows today only as WARNING lines in Loki. This issue must measure the throttle of each engine to choose the engine set; this metric is that measure. About 415 of 629 engine warnings in 24 h come from the Stack Exchange engines that #4141 removes.

  7. added
    status/ready
    and removed
    status/new
    on Nov 14, 2026
  8. 24 remaining items

  9. added
    owner/service
    status/in-progress
    and removed
    owner/service
    status/ready
    on Nov 22, 2026
  10. added
    status/in-review
    and removed
    status/in-progress
    on Nov 22, 2026
  11. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    ContributorAuthor

    The draft pull request #6755 holds the final title and body. In mode on of roadmap.fix_checks.mode, the watch row marks it ready when its checks pass, and a fix-checks Job repairs a failed check whose name gives the class test, lint or types. In each other case the watch row stops the item: another failed check, a cancelled check, a conflict, a fix-checks Job that ended with no repair, or another mode.

    Spend: 253 model requests, 14941595 input tokens, 83676 output tokens.

  12. removed
    owner/service
    on Nov 22, 2026
  13. removed
    status/in-review
    on Nov 22, 2026
  14. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    ContributorAuthor
  15. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    ContributorAuthor

    Live since 2026-11-22 13:47 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/mediumpriority/p2-mediumscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions