diff options
author | Rory& <root@rory.gay> | 2024-09-02 20:19:00 +0200 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-09-02 20:19:00 +0200 |
commit | a693745b35f7c534248e6ff0b00e9639c04ba39a (patch) | |
tree | 70b5583276729cc851e72bedb1753c1e11a11b8e /modules/monitoring/synapse.nix | |
parent | fix prom (diff) | |
download | Rory-Open-Architecture-a693745b35f7c534248e6ff0b00e9639c04ba39a.tar.xz |
Single scrape interval, add synapse label
Diffstat (limited to 'modules/monitoring/synapse.nix')
-rw-r--r-- | modules/monitoring/synapse.nix | 82 |
1 files changed, 26 insertions, 56 deletions
diff --git a/modules/monitoring/synapse.nix b/modules/monitoring/synapse.nix index a279a3d..385e996 100644 --- a/modules/monitoring/synapse.nix +++ b/modules/monitoring/synapse.nix @@ -14,39 +14,6 @@ in } ]; - #services.matrix-synapse.workers = ( - # let - # workerNames = config.services.matrix-synapse.workers; - - # hasMetricsListener = - # (workerName: - # lib.any ( - # listener: listener.type == "http" && (lib.any (resourceName: resourceName == "metrics") listener.resources) - # ) config.services.matrix-synapse.workers.${workerName}.worker_listeners); - - # workerNamesWithoutMetrics = lib.traceVal lib.filter (workerName: (!hasMetricsListener workerName)) workerNames; - # in - # lib.listToAttrs ( - # lib.imap (index: workerName: { - # name = workerName; - # value = { - # worker_listeners = [ - # { - # type = "http"; - # port = 9200 + index; - # resources = [ - # { - # names = [ "metrics" ]; - # compress = false; - # } - # ]; - # } - # ]; - # }; - # }) workerNamesWithoutMetrics - # ) - #); - services.matrix-synapse.workers = ( lib.listToAttrs ( lib.imap (index: workerName: { @@ -64,30 +31,33 @@ in ) ); - services.prometheus.scrapeConfigs = ( - (lib.map (interval: { - job_name = "synapse-main-${toString interval}s"; - scrape_interval = "${toString interval}s"; - static_configs = [ { targets = [ "localhost:9200" ]; } ]; - metrics_path = "_synapse/metrics"; - }) cfg.prometheusScrapeIntervals) + services.prometheus.scrapeConfigs = + [ + { + job_name = "synapse-main"; + scrape_interval = "${toString cfg.prometheusScrapeInterval}s"; + static_configs = [ + { + targets = [ "localhost:9200" ]; + labels.instance = "synapse"; + } + ]; + metrics_path = "_synapse/metrics"; + } + ] ++ lib.flatten ( - lib.imap ( - index: workerName: - lib.map (interval: { - job_name = "synapse-${workerName}-${toString interval}s"; - scrape_interval = "${toString interval}s"; - static_configs = [ - { - targets = [ "localhost:${toString (9200 + index + 1)}" ]; - - } - ]; - metrics_path = "_synapse/metrics"; - }) cfg.prometheusScrapeIntervals - ) config.monitoring.synapse.workerNames - ) - ); + lib.imap (index: workerName: { + job_name = "synapse-${workerName}s"; + scrape_interval = "${toString cfg.prometheusScrapeInterval}s"; + static_configs = [ + { + targets = [ "localhost:${toString (9200 + index + 1)}" ]; + labels.instance = "synapse"; + } + ]; + metrics_path = "_synapse/metrics"; + }) config.monitoring.synapse.workerNames + ); services.grafana.provision.dashboards.settings = { apiVersion = 1; |