Extend monitoring-server
This commit is contained in:
parent
6adbbbeaa4
commit
5c3b9fd791
1 changed files with 80 additions and 20 deletions
|
@ -10,60 +10,120 @@ with lib; let
|
||||||
in {
|
in {
|
||||||
options.pub-solar.monitoring-server = {
|
options.pub-solar.monitoring-server = {
|
||||||
enable = mkEnableOption "Install a monitoring server node";
|
enable = mkEnableOption "Install a monitoring server node";
|
||||||
|
listenAddress = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "127.0.0.1";
|
||||||
|
};
|
||||||
|
grafana = {
|
||||||
|
enable = mkEnableOption "Run grafana";
|
||||||
|
port = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 2342;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
node_exporter = {
|
||||||
|
enable = mkEnableOption "prometheus node-exporter support";
|
||||||
|
hosts = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
snmp = {
|
||||||
|
enable = mkEnableOption "prometheus snmp export support";
|
||||||
|
hosts = mkOption {
|
||||||
|
#type = types.Or (types.AttrSet types.listOf types.str);
|
||||||
|
};
|
||||||
|
settings = mkOption {
|
||||||
|
type = types.NullOr types.AttrSet;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
smokeping = {
|
||||||
|
enable = mkEnableOption "prometheus smokeping support";
|
||||||
|
hosts = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
networking.firewall.allowedTCPPorts = [2342 9001];
|
networking.firewall.allowedTCPPorts = [cfg.grafana.port 9001 9374];
|
||||||
|
|
||||||
pub-solar.monitoring-client = {
|
pub-solar.monitoring-client = {
|
||||||
enable = true;
|
enable = true;
|
||||||
listenAddress = "10.0.1.6";
|
listenAddress = cfg.listenAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
services.grafana = {
|
services.grafana = mkIf cfg.grafana.enable {
|
||||||
enable = true;
|
enable = true;
|
||||||
port = 2342;
|
settings = {
|
||||||
addr = "10.0.1.6";
|
server = {
|
||||||
|
http_addr = cfg.listenAddress;
|
||||||
|
http_port = cfg.grafana.port;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.prometheus = {
|
services.prometheus = {
|
||||||
enable = true;
|
enable = true;
|
||||||
listenAddress = "10.0.1.6";
|
listenAddress = cfg.listenAddress;
|
||||||
port = 9001;
|
port = 9001;
|
||||||
scrapeConfigs = [
|
scrapeConfigs = [
|
||||||
{
|
{
|
||||||
job_name = "chonk";
|
job_name = "node_exporters";
|
||||||
static_configs = [
|
static_configs = [
|
||||||
{
|
{
|
||||||
targets = ["10.0.1.6:9002"];
|
targets =
|
||||||
|
["${cfg.listenAddress}:9002"]
|
||||||
|
++ cfg.node_exporter.hosts;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
job_name = "giggles";
|
job_name = "snmp_wohnung_aachen_mikrotik";
|
||||||
|
scrape_interval = "15s";
|
||||||
static_configs = [
|
static_configs = [
|
||||||
{
|
{
|
||||||
targets = ["10.0.1.11:9002"];
|
targets = cfg.snmp.hosts;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
metrics_path = "/snmp";
|
||||||
|
params = {
|
||||||
|
auth = ["public_v2"];
|
||||||
|
module = ["if_mib"];
|
||||||
|
};
|
||||||
|
relabel_configs = [
|
||||||
|
{
|
||||||
|
source_labels = ["__address__"];
|
||||||
|
target_label = "__param_target";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source_labels = ["__param_target"];
|
||||||
|
target_label = "instance";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
target_label = "__address__";
|
||||||
|
replacement = "10.0.1.254:9116";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
job_name = "cox";
|
job_name = "smokeping";
|
||||||
|
scrape_interval = "15s";
|
||||||
static_configs = [
|
static_configs = [
|
||||||
{
|
{
|
||||||
targets = ["10.0.1.12:9002"];
|
targets = [
|
||||||
}
|
"${cfg.listenAddress}:9374"
|
||||||
];
|
];
|
||||||
}
|
|
||||||
{
|
|
||||||
job_name = "companion";
|
|
||||||
static_configs = [
|
|
||||||
{
|
|
||||||
targets = ["10.0.1.13:9002"];
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
exporters.smokeping = mkIf cfg.smokeping.enable {
|
||||||
|
enable = true;
|
||||||
|
listenAddress = cfg.listenAddress;
|
||||||
|
hosts = cfg.smokeping.hosts;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue