mirror of
https://github.com/RGBCube/ncc
synced 2025-08-01 04:27:46 +00:00
feat: move away from cube host
This commit is contained in:
parent
07537d4889
commit
5125a31e7f
36 changed files with 97 additions and 165 deletions
44
hosts/best/grafana/prometheus.nix
Normal file
44
hosts/best/grafana/prometheus.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{ self, config, lib, ... }: let
|
||||
inherit (lib) enabled filterAttrs flatten mapAttrsToList;
|
||||
in {
|
||||
services.grafana.provision.datasources.settings = {
|
||||
datasources = [{
|
||||
name = "Prometheus";
|
||||
type = "prometheus";
|
||||
url = "http://[::1]:${toString config.services.prometheus.port}";
|
||||
|
||||
orgId = 1;
|
||||
}];
|
||||
|
||||
deleteDatasources = [{
|
||||
name = "Prometheus";
|
||||
orgId = 1;
|
||||
}];
|
||||
};
|
||||
|
||||
services.prometheus = enabled {
|
||||
listenAddress = "[::]";
|
||||
retentionTime = "1w";
|
||||
|
||||
scrapeConfigs = let
|
||||
configToScrapeConfig = hostName: { config, ... }: let
|
||||
hostConfig = config;
|
||||
in hostConfig.services.prometheus.exporters
|
||||
|> filterAttrs (exporterName: exporterConfig:
|
||||
exporterName != "minio" &&
|
||||
exporterName != "unifi-poller" &&
|
||||
exporterName != "tor" &&
|
||||
exporterConfig.enable or false)
|
||||
|> mapAttrsToList (exporterName: exporterConfig: {
|
||||
job_name = "${exporterName}-${hostName}";
|
||||
|
||||
static_configs = [{
|
||||
targets = [ "${hostName}:${toString exporterConfig.port}" ];
|
||||
}];
|
||||
});
|
||||
|
||||
in self.nixosConfigurations
|
||||
|> mapAttrsToList configToScrapeConfig
|
||||
|> flatten;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue