swarm-otel: scrape VictoriaLogs through its published name
VictoriaLogs' own metrics were scraped over loopback, declared only on the host running the store, so a collector on any other host had no job for it. Its target is now declared on every host as `https://<swarm.victorialogs.domain>/metrics`, next to forgejo's and authelia's, and the store's vhost serves `= /metrics` behind a bare `auth_request` to authelia. The rules derived from `publishedScrapeTargets` admit the collector's client there and deny every other subject. The loopback entry is gone, so a single host still scrapes the store once, now by name. On that vhost `/metrics` was reachable through the `/` location by any authelia session. The exact-match location now takes it, so a session gets a `deny` on `/metrics` and nothing else on the name changes. Part of #5205
This commit is contained in:
parent
f19a9f546e
commit
5fe04da559
3 changed files with 104 additions and 16 deletions
|
|
@ -360,5 +360,7 @@ in
|
|||
authelia = "https://${hyperhiveCfg.swarm.authelia.domain}/metrics";
|
||||
# The vhost location is in ./swarm-victoriametrics.nix.
|
||||
victoriametrics = "https://${vmCfg.domain}/metrics";
|
||||
# The vhost location is in ./swarm-victorialogs.nix.
|
||||
victorialogs = "https://${hyperhiveCfg.swarm.victorialogs.domain}/metrics";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ let
|
|||
};
|
||||
baoCfg = hyperhiveCfg.swarm.bao;
|
||||
|
||||
# Shared host netns, like every sibling swarm container: the collector
|
||||
# and Grafana reach this at 127.0.0.1:<port>.
|
||||
# Shared host netns, like every sibling swarm container: Grafana reaches
|
||||
# this at 127.0.0.1:<port>.
|
||||
privateNetwork = false;
|
||||
in
|
||||
{
|
||||
|
|
@ -215,18 +215,6 @@ in
|
|||
limit_req_zone $binary_remote_addr zone=swarm_logs_agent_auth:1m rate=${deployCfg.victorialogs.authRate};
|
||||
'';
|
||||
|
||||
# This store publishes its own health as prometheus metrics on the same
|
||||
# listener it serves queries on, so the swarm's collector scrapes it with
|
||||
# no exporter and no extra port — same arrangement as the metrics store.
|
||||
#
|
||||
# Declared here rather than in the collector's module because that is the
|
||||
# rule the option carries: an entry exists only where the service that
|
||||
# named it runs. ⚠️ That constrains the TARGET, not the scraper — a
|
||||
# deployment that splits this container away from the collector's host
|
||||
# silently drops the entry, and no assertion can see it, because separate
|
||||
# hosts are separate evaluations.
|
||||
services.hyperhive.swarm.otel.scrapeTargets.victorialogs = "127.0.0.1:${toString cfg.port}";
|
||||
|
||||
# The gateway name, inside `deployCfg.victorialogs.enable` — same
|
||||
# "only the host that runs the service may claim the name" guard every
|
||||
# sibling swarm-service module uses (`swarm-grafana.nix`,
|
||||
|
|
@ -313,6 +301,23 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
# The store's own health, which it publishes as prometheus metrics
|
||||
# on the listener it serves queries on. The swarm collector requests
|
||||
# exactly this URL, declared as `publishedScrapeTargets.victorialogs`
|
||||
# in ./swarm-otel-service.nix; the two must agree, since that string
|
||||
# is also the token's audience.
|
||||
#
|
||||
# Bare `auth_request` to authelia, as on the ingest route above, and
|
||||
# never `/__swarm_logs_auth`, which admits an agent's bearer:
|
||||
# authelia's rules for this URL admit the collector's client and
|
||||
# deny every other subject (see `metricsRules` in ./swarm-authelia.nix).
|
||||
"= /metrics" = {
|
||||
proxyPass = "http://127.0.0.1:${toString cfg.port}/metrics";
|
||||
extraConfig = ''
|
||||
auth_request /__hive_authelia;
|
||||
'';
|
||||
};
|
||||
|
||||
# `rewrite … last` re-matches locations, so the subrequest lands in
|
||||
# one of the two internal locations named by the map.
|
||||
"= /__swarm_logs_auth" = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue