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:
parent
9237948c2c
commit
480855dfaf
1 changed files with 157 additions and 4 deletions
33
nix/host-modules/lib/scrape-without-jobs.nix
Normal file
33
nix/host-modules/lib/scrape-without-jobs.nix
Normal 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 ];
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue