matrix: report homeserver up, latency and database size through existing collectors
tuwunel 1.9.4 exports no metrics. The host collector gets an httpcheck receiver on the gateway's /_matrix/client/versions (new services.hyperhive.otel.httpChecks, declared by hive-matrix), and a timer in the hive-matrix container pushes the database directory's size through the forwarder's OTLP port, as the attic cache-size unit does. The size step dereferences the state directory's symlink and pushes nothing for a result under 4096 bytes.
This commit is contained in:
parent
839dbd642a
commit
bef9d401a4
1 changed files with 311 additions and 0 deletions
|
|
@ -178,6 +178,65 @@ let
|
|||
&& !(apex ? "= /.well-known/matrix/client")
|
||||
&& !(apex ? "= /.well-known/matrix/server");
|
||||
}
|
||||
{
|
||||
# tuwunel has no metrics of its own, so the hive collector requests
|
||||
# `/_matrix/client/versions` through the gateway. The URL carries no
|
||||
# port, like the rest of this module's URLs. The elsewhere host is the
|
||||
# control: the same lookups there find no check, and the receiver stays
|
||||
# out of its pipeline.
|
||||
name = "the hive collector requests the homeserver's versions endpoint through the gateway, only where the homeserver runs";
|
||||
ok =
|
||||
let
|
||||
url = "https://chat.t.local/_matrix/client/versions";
|
||||
settings = m: m.services.opentelemetry-collector.settings;
|
||||
pipeline = m: (settings m).service.pipelines.metrics.receivers;
|
||||
in
|
||||
matrixNoBaoIdentity.services.hyperhive.otel.httpChecks == [ url ]
|
||||
&&
|
||||
(settings matrixNoBaoIdentity).receivers.httpcheck.targets == [
|
||||
{
|
||||
endpoint = url;
|
||||
method = "GET";
|
||||
}
|
||||
]
|
||||
&& lib.elem "httpcheck" (pipeline matrixNoBaoIdentity)
|
||||
&& matrixElsewhere.services.hyperhive.otel.httpChecks == [ ]
|
||||
&& !((settings matrixElsewhere).receivers ? httpcheck)
|
||||
&& !(lib.elem "httpcheck" (pipeline matrixElsewhere))
|
||||
# Presence control for the two lookups above.
|
||||
&& (settings matrixElsewhere).receivers ? hostmetrics
|
||||
&& lib.elem "hostmetrics" (pipeline matrixElsewhere);
|
||||
}
|
||||
{
|
||||
# The size is read from the database directory, as the dynamic user the
|
||||
# homeserver runs as, and pushed to the forwarder's OTLP port. Without a
|
||||
# store identity the container has no forwarder, so there is nothing to
|
||||
# push to and neither unit appears; the hive with the identity is the
|
||||
# control that the same lookups find them.
|
||||
name = "the homeserver container pushes its database size through the forwarder, and only with a forwarder";
|
||||
ok =
|
||||
let
|
||||
inner = m: m.containers.hive-matrix.config;
|
||||
here = inner matrixBodyCap;
|
||||
without = inner matrixNoBaoIdentity;
|
||||
svc = here.systemd.services.hive-matrix-database-size;
|
||||
f = here.services.hyperhive.swarmJournalForwarder;
|
||||
in
|
||||
svc.serviceConfig.Type == "oneshot"
|
||||
&& svc.serviceConfig.DynamicUser
|
||||
&& svc.serviceConfig.User == "tuwunel"
|
||||
&& svc.serviceConfig.StateDirectory == here.services.matrix-tuwunel.stateDirectory
|
||||
&& lib.hasInfix "du --summarize --bytes --dereference-args /var/lib/tuwunel" svc.script
|
||||
&& lib.hasInfix "-lt 4096" svc.script
|
||||
&& lib.hasInfix "hyperhive.matrix.database_bytes" svc.script
|
||||
&& lib.hasInfix "127.0.0.1:${toString f.otlpMetricsPort}/v1/metrics" svc.script
|
||||
&& f.otlpMetricsPort != null
|
||||
&& here.systemd.timers.hive-matrix-database-size.timerConfig.OnUnitActiveSec == "5min"
|
||||
&& !(without.systemd.services ? hive-matrix-database-size)
|
||||
&& !(without.systemd.timers ? hive-matrix-database-size)
|
||||
# Presence control: the container's units are found by the same lookup.
|
||||
&& without.systemd.services ? tuwunel;
|
||||
}
|
||||
];
|
||||
in
|
||||
runGroup "matrix-core" cases
|
||||
|
|
|
|||
Loading…
Reference in a new issue