Watch
0
0
Fork
You've already forked hyperhive
0

swarm-otel: scrape the authenticated targets only once the collector has its client secret

An empty secret file made the prometheus receiver request a token for each published target every scrape; authelia's per-address limit then refused every client behind that address. Without a secret the collector starts on the config minus those jobs. full-setup asserts the limiter never fired.
This commit is contained in:
atlas 2026-11-23 12:15:37 +01:00 • committed by mara
commit 480855dfaf

View file

@ -0,0 +1,33 @@
# Pure function — NOT a NixOS module. An OpenTelemetry collector config minus
# the named prometheus scrape jobs.
#
# scrapeWithoutJobs = import ./lib/scrape-without-jobs.nix { inherit lib; };
# scrapeWithoutJobs { inherit settings jobs; pipeline = "metrics/swarm"; }
#
# `jobs` are `job_name`s of the `prometheus` receiver. When none is left the
# receiver goes, and `pipeline` with it: a prometheus receiver without scrape
# configs fails the collector's validation, and a pipeline naming an absent
# receiver does too.
{ lib }:
{
settings,
jobs,
pipeline,
}:
let
kept = lib.filter (job: !(lib.elem job.job_name jobs)) (
settings.receivers.prometheus.config.scrape_configs or [ ]
);
in
if !(settings.receivers ? prometheus) then
settings
else if kept != [ ] then
lib.recursiveUpdate settings { receivers.prometheus.config.scrape_configs = kept; }
else
settings
// {
receivers = removeAttrs settings.receivers [ "prometheus" ];
service = settings.service // {
pipelines = removeAttrs settings.service.pipelines [ pipeline ];
};
}