Skip to content
Snippets Groups Projects
Commit 787e8537 authored by Florian Sesser's avatar Florian Sesser
Browse files

Monitoring: Add regular scraping for Tahoe OpenMetrics statistics

parent 2aefce56
No related branches found
No related tags found
2 merge requests!228merge develop into production,!216Monitoring: Add regular scraping for Tahoe OpenMetrics statistics
Pipeline #1485 passed
......@@ -43,8 +43,12 @@ in {
../../nixos/modules/monitoring/vpn/client.nix
# Expose base system metrics over the monitoringvpn.
../../nixos/modules/monitoring/exporters/node.nix
# Collect Tahoe OpenMetrics statistics.
../../nixos/modules/monitoring/exporters/tahoe.nix
];
services.private-storage.monitoring.tahoe.enable = true;
# Turn on the Private Storage (Tahoe-LAFS) service.
services.private-storage = {
# Yep. Turn it on.
......
# Tahoe Prometheus metrics collector
#
# Scope: Retrieves OpenMetrics from Tahoe and puts them
# where textfile collector can find them.
#
# Usage: Import this to every server running Tahoe.
#
# See https://nixos.org/manual/nixos/stable/#module-services-prometheus-exporters
{ config, options, lib, ourpkgs, pkgs, ... }:
let
cfg = config.services.private-storage.monitoring.tahoe;
in {
options.services.private-storage.monitoring.tahoe = {
enable = lib.mkEnableOption "Tahoe OpenMetrics collecting service";
scrapeEndpoint = lib.mkOption {
type = lib.types.str;
description = "Where to get our metrics from?";
default = "http://localhost:3456/statistics?t=openmetrics";
};
outFile = lib.mkOption {
type = lib.types.str;
description = "Where to store the temporary file for node exporter to scrape?";
default = "/run/prometheus-node-exporter/tahoe.prom";
};
interval = lib.mkOption {
type = lib.types.str;
description = ''
How often to do it?
See https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events
'';
# Every five minutes.
default = "*:0/5";
};
};
config =
lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.curl ];
systemd.services.tahoe-metrics-collector = {
enable = true;
description = "Tahoe metrics gathering service";
wantedBy = [ "multi-user.target" ];
startAt = cfg.interval;
path = [ pkgs.curl ];
# Curl to a temp file and then move atomically so textfile collector
# won't read a partial file.
# See https://github.com/prometheus/node_exporter#textfile-collector
script = ''
curl --silent --show-error --fail-with-body --output "${cfg.outFile}.tmp" "${cfg.scrapeEndpoint}"
mv "${cfg.outFile}.tmp" "${cfg.outFile}"
'';
};
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment