NAME
Langertha::Holmgang::Sim::Linux::Monitoring - Monitoring on a simulated Linux server — checks Prometheus/Alertmanager, promtool, amtool
VERSION
version 0.001
SYNOPSIS
# from the Linux simulator
my ( $error, $reloaded ) = Langertha::Holmgang::Sim::Linux::Monitoring::service_check( $dev, $svc, 'prometheus' );
my ( $out, $ok ) = Langertha::Holmgang::Sim::Linux::Monitoring::promtool( $dev, \@argv );
my ( $out, $ok ) = Langertha::Holmgang::Sim::Linux::Monitoring::amtool( $dev, \@argv );
my ( $body, $status ) = Langertha::Holmgang::Sim::Linux::Monitoring::http( $dev, 'GET', 9090, '/api/v1/rules', $run );
DESCRIPTION
Prometheus and Alertmanager on a device of type linux (cai-platform docs/entwurf-evals.md §3.3.1). The services live under services with several files in config (running is then { path = text }>) and config_check: prometheus|alertmanager; config_main names the main file.
Prometheus: The main file must be valid YAML; scrape_configs with job_name (unique) and static_configs.targets (host:port); rule_files (patterns) load rule files: groups with name and rules, each rule alert or record, expr, otherwise only for, labels, annotations, keep_firing_for. An error prevents the start; on reload the old configuration stays and the journal shows Error reloading config. Loaded rule files are part of running.
Alertmanager: route with receiver; every receiver named in route (also in routes) must be listed under receivers.
promtool check config|rules FILE…, amtool check-config FILE — output like the real tools. What Alertmanager has loaded is kept per receiver under the service's _routes (effective repeat_interval, group_wait, group_interval, group_by; subroutes inherit). amtool config routes [show] prints the routing tree and amtool config routes test [--verify.receivers=LIST] LABEL… the receivers an alert reaches, from --config.file or else the running configuration; a config that does not load is an amtool: error. amtool silence add|query|expire and amtool alert query (with --alertmanager.url or /etc/amtool/config.yml; comment required; times RFC 3339, --duration as a Go duration, device clock in tz, default +02:00): silences live under the service's silences, each entry with starts/ends (UTC), state (pending|active|expired) and covers — which of the named label sets from alert_targets they match; alerts names the firing alerts (alertname, target).
logrotate is modelled by Langertha::Holmgang::Sim::Linux::Logrotate.
Pure functions on the state, neutral.
check_prometheus
my ( $error, $rule_files, $rule_count ) = check_prometheus( $dev, $path );
check_alertmanager
my $error = check_alertmanager( $dev, $path );
service_check
my ( $journal_lines, $reloaded ) = service_check( $dev, $svc, 'prometheus'|'alertmanager' );
http
my ( $body, $status ) = http( $dev, 'GET'|'POST', $port, $path, $run );
The HTTP interface of Prometheus (9090) and Alertmanager (9093) on the device, from the running configuration: /-/healthy, /-/ready, /api/v1/status/config, /api/v1/status/flags (from the running start options), /api/v1/rules, /api/v1/alerts (empty: no rule fires), POST /-/reload (only with --web.enable-lifecycle, otherwise 403), Alertmanager /api/v2/status and POST /-/reload. Without a running service $status is 0 (connection refused); anything else is a gap (undef).
promtool
my ( $out, $ok ) = promtool( $dev, \@argv );
amtool
my ( $out, $ok ) = amtool( $dev, \@argv );
now_epoch
my $t = now_epoch($dev);
The device's clock (clock, year 2026, zone tz) as Unix time.
SUPPORT
Issues
Please report bugs and feature requests at https://github.com/Getty/langertha-holmgang/issues.
IRC
Join #langertha on irc.perl.org or message Getty directly.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.