Upload voyager host
This commit is contained in:
23147
hosts/voyager/services/metrics/dashboards/node-exporter-full.json
Normal file
23147
hosts/voyager/services/metrics/dashboards/node-exporter-full.json
Normal file
File diff suppressed because it is too large
Load Diff
7019
hosts/voyager/services/metrics/dashboards/openwrt.json
Normal file
7019
hosts/voyager/services/metrics/dashboards/openwrt.json
Normal file
File diff suppressed because it is too large
Load Diff
7114
hosts/voyager/services/metrics/dashboards/synology-nas-details.json
Normal file
7114
hosts/voyager/services/metrics/dashboards/synology-nas-details.json
Normal file
File diff suppressed because it is too large
Load Diff
10
hosts/voyager/services/metrics/default.nix
Normal file
10
hosts/voyager/services/metrics/default.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./prometheus.nix
|
||||
./grafana.nix
|
||||
./loki.nix
|
||||
./snmp-exporter.nix
|
||||
];
|
||||
}
|
||||
64
hosts/voyager/services/metrics/grafana.nix
Normal file
64
hosts/voyager/services/metrics/grafana.nix
Normal file
@@ -0,0 +1,64 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.grafana;
|
||||
in {
|
||||
services.grafana = {
|
||||
enable = true;
|
||||
settings.server = {
|
||||
domain = "grafana.feal.no";
|
||||
http_port = 2342;
|
||||
http_addr = "127.0.0.1";
|
||||
};
|
||||
|
||||
provision = {
|
||||
enable = true;
|
||||
datasources.settings.datasources = [
|
||||
{
|
||||
name = "Prometheus";
|
||||
type = "prometheus";
|
||||
url = ("http://${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}");
|
||||
isDefault = true;
|
||||
}
|
||||
{
|
||||
name = "Loki";
|
||||
type = "loki";
|
||||
url = ("http://${config.services.loki.configuration.server.http_listen_address}:${toString config.services.loki.configuration.server.http_listen_port}");
|
||||
}
|
||||
];
|
||||
dashboards.settings.providers = [
|
||||
{
|
||||
name = "Node Exporter Full";
|
||||
type = "file";
|
||||
url = "https://grafana.com/api/dashboards/1860/revisions/29/download";
|
||||
options.path = dashboards/node-exporter-full.json;
|
||||
}
|
||||
{
|
||||
name = "Synology NAS Details";
|
||||
type = "file";
|
||||
url = "https://grafana.com/api/dashboards/14284/revisions/9/download";
|
||||
options.path = dashboards/synology-nas-details.json;
|
||||
}
|
||||
{
|
||||
name = "OpenWRT";
|
||||
type = "file";
|
||||
url = "https://grafana.com/api/dashboards/11147/revisions/1/download";
|
||||
options.path = dashboards/openwrt.json;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts.${cfg.settings.server.domain} = {
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString cfg.settings.server.http_port}";
|
||||
proxyWebsockets = true;
|
||||
extraConfig = ''
|
||||
proxy_buffers 8 1024k;
|
||||
proxy_buffer_size 1024k;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
75
hosts/voyager/services/metrics/loki.nix
Normal file
75
hosts/voyager/services/metrics/loki.nix
Normal file
@@ -0,0 +1,75 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.loki;
|
||||
in {
|
||||
services.loki = {
|
||||
enable = true;
|
||||
configuration = {
|
||||
auth_enabled = false;
|
||||
server = {
|
||||
http_listen_port = 3100;
|
||||
http_listen_address = "0.0.0.0";
|
||||
grpc_listen_port = 9096;
|
||||
};
|
||||
|
||||
ingester = {
|
||||
wal = {
|
||||
enabled = true;
|
||||
dir = "/var/lib/loki/wal";
|
||||
};
|
||||
lifecycler = {
|
||||
address = "127.0.0.1";
|
||||
ring = {
|
||||
kvstore = {
|
||||
store = "inmemory";
|
||||
};
|
||||
replication_factor = 1;
|
||||
};
|
||||
final_sleep = "0s";
|
||||
};
|
||||
chunk_idle_period = "1h";
|
||||
};
|
||||
|
||||
schema_config = {
|
||||
configs = [
|
||||
{
|
||||
from = "2022-12-01";
|
||||
store = "boltdb-shipper";
|
||||
object_store = "filesystem";
|
||||
schema = "v11";
|
||||
index = {
|
||||
prefix = "index_";
|
||||
period = "24h";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
storage_config = {
|
||||
boltdb_shipper = {
|
||||
active_index_directory = "/var/lib/loki/boltdb-shipper-index";
|
||||
cache_location = "/var/lib/loki/boltdb-shipper-cache";
|
||||
shared_store = "filesystem";
|
||||
cache_ttl = "24h";
|
||||
};
|
||||
filesystem = {
|
||||
directory = "/var/lib/loki/chunks";
|
||||
};
|
||||
};
|
||||
|
||||
limits_config = {
|
||||
enforce_metric_name = false;
|
||||
reject_old_samples = true;
|
||||
reject_old_samples_max_age = "72h";
|
||||
};
|
||||
|
||||
compactor = {
|
||||
working_directory = "/var/lib/loki/compactor";
|
||||
shared_store = "filesystem";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ cfg.configuration.server.http_listen_port ];
|
||||
}
|
||||
60
hosts/voyager/services/metrics/prometheus.nix
Normal file
60
hosts/voyager/services/metrics/prometheus.nix
Normal file
@@ -0,0 +1,60 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.prometheus;
|
||||
in {
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
listenAddress = "127.0.0.1";
|
||||
port = 9001;
|
||||
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "node";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [
|
||||
"voyager.home.feal.no:${toString cfg.exporters.node.port}"
|
||||
"sulu.home.feal.no:9100"
|
||||
"mccoy.home.feal.no:9100"
|
||||
"borg.home.feal.no:9100"
|
||||
"troi.home.feal.no:9100"
|
||||
"dlink-feal.home.feal.no:9100"
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
job_name = "openwrt";
|
||||
static_configs = [
|
||||
{ targets = ["dlink-feal.home.feal.no:9100"]; }
|
||||
];
|
||||
}
|
||||
{
|
||||
job_name = "snmp";
|
||||
static_configs = [{
|
||||
targets = [
|
||||
"feal-syn1.home.feal.no"
|
||||
"feal-syn2.home.feal.no"
|
||||
];
|
||||
}];
|
||||
metrics_path = "/snmp";
|
||||
params.module = ["synology"];
|
||||
relabel_configs = [
|
||||
{
|
||||
source_labels = ["__address__"];
|
||||
target_label = "__param_target";
|
||||
}
|
||||
{
|
||||
source_labels = ["__param_target"];
|
||||
target_label = "instance";
|
||||
}
|
||||
{
|
||||
target_label = "__address__";
|
||||
replacement = "127.0.0.1:9116";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
20
hosts/voyager/services/metrics/snmp-exporter.nix
Normal file
20
hosts/voyager/services/metrics/snmp-exporter.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = [
|
||||
pkgs.prometheus-snmp-exporter
|
||||
];
|
||||
|
||||
systemd.services.prometheus-snmp-exporter = {
|
||||
enable = true;
|
||||
description = "Gather data from SNMP devices and expose them as Prometheus metrics";
|
||||
unitConfig = {
|
||||
Type = "simple";
|
||||
};
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.prometheus-snmp-exporter}/bin/snmp_exporter --config.file='/var/prometheus/snmp.yml'";
|
||||
# TODO: Fix this conf file!
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user