aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-03-02 17:38:34 -0800
committerFranck Cuny <franck@fcuny.net>2022-03-02 17:38:34 -0800
commita70735057e2e5b64e0172d01bf5f74118cd3b346 (patch)
treeb8adfe07a567173a3c05751d585bde3a7c0b627a
parentwireguard: use agenix from the module (diff)
downloadinfra-a70735057e2e5b64e0172d01bf5f74118cd3b346.tar.gz
prometheus: relabel some machines
Don't use the IP from wireguard as the name of the host, let's map to the actual hostname.
-rw-r--r--hosts/common/server/prometheus.nix32
1 files changed, 20 insertions, 12 deletions
diff --git a/hosts/common/server/prometheus.nix b/hosts/common/server/prometheus.nix
index 1c7c906..a27e3cc 100644
--- a/hosts/common/server/prometheus.nix
+++ b/hosts/common/server/prometheus.nix
@@ -1,12 +1,5 @@
{ config, pkgs, lib, ... }:
-let
- # Scrape a list of static targets for a job.
- staticScrape = (job_name: targets: {
- inherit job_name;
- static_configs = [{ inherit targets; }];
- });
-in
{
services.prometheus = {
enable = true;
@@ -15,15 +8,30 @@ in
extraFlags = [
# 3 years of retention
- "--storage.tsdb.retention=1095d"
+ "--storage.tsdb.retention=${toString (365 * 3)}d"
"--web.enable-admin-api"
];
scrapeConfigs = [
- (staticScrape "node" [
- "rtr:9100"
- "tahoe:9100"
- ])
+ {
+ job_name = "node";
+ static_configs = [
+ {targets = ["192.168.6.10:9100" "192.168.6.20:9100"]; }
+ ];
+ relabel_configs = [{
+ source_labels = ["__address__"];
+ target_label = "instance";
+ replacement = "nas";
+ action = "replace";
+ regex = "192\.168\.6\.10:(.*)";
+ } {
+ source_labels = ["__address__"];
+ target_label = "instance";
+ replacement = "tahoe";
+ action = "replace";
+ regex = "192\.168\.6\.20:(.*)";
+ }];
+ }
];
};
}