feat: cleaning up some metrics & adding labels
This commit is contained in:
@@ -27,16 +27,32 @@
|
|||||||
|
|
||||||
prometheus.relabel "filter_metrics" {
|
prometheus.relabel "filter_metrics" {
|
||||||
rule {
|
rule {
|
||||||
|
source_labels = ["__name__"]
|
||||||
|
regex = ".*_build_info"
|
||||||
action = "drop"
|
action = "drop"
|
||||||
source_labels = [ "env" ]
|
|
||||||
regex = "dev"
|
|
||||||
}
|
}
|
||||||
rule {
|
rule {
|
||||||
action = "replace"
|
source_labels = ["__name__"]
|
||||||
regex = "127\\.0\\.0\\.1"
|
regex = "go_.*"
|
||||||
target_label = "instance"
|
action = "drop"
|
||||||
|
}
|
||||||
|
rule {
|
||||||
|
source_labels = [ "env" ]
|
||||||
|
regex = "dev"
|
||||||
|
action = "drop"
|
||||||
|
}
|
||||||
|
rule {
|
||||||
|
target_label = "host"
|
||||||
|
replacement = "${tools.build_hostname container}"
|
||||||
|
}
|
||||||
|
rule {
|
||||||
|
target_label = "host_ip"
|
||||||
replacement = "${tools.build_ip container}"
|
replacement = "${tools.build_ip container}"
|
||||||
}
|
}
|
||||||
|
rule {
|
||||||
|
target_label = "service"
|
||||||
|
replacement = "alloy"
|
||||||
|
}
|
||||||
forward_to = [prometheus.remote_write.metrics_service.receiver]
|
forward_to = [prometheus.remote_write.metrics_service.receiver]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,14 @@ in
|
|||||||
{
|
{
|
||||||
job_name = "prometheus";
|
job_name = "prometheus";
|
||||||
static_configs = [
|
static_configs = [
|
||||||
{ targets = [ "localhost:9090" ]; }
|
{
|
||||||
|
targets = [ "localhost:9090" ];
|
||||||
|
labels = {
|
||||||
|
host = tools.build_hostname "metrics";
|
||||||
|
host_ip = tools.build_ip "metrics";
|
||||||
|
service = "prometheus";
|
||||||
|
};
|
||||||
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -33,8 +40,13 @@ in
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
job_name = container;
|
job_name = container;
|
||||||
static_configs = map (port: {
|
static_configs = lib.mapAttrsToList (service: port: {
|
||||||
targets = [ "${container_ip}:${toString port}" ];
|
targets = [ "${container_ip}:${toString port}" ];
|
||||||
|
labels = {
|
||||||
|
host = tools.build_hostname container;
|
||||||
|
host_ip = tools.build_ip container;
|
||||||
|
service = service;
|
||||||
|
};
|
||||||
}) def.logging.prometheusPorts;
|
}) def.logging.prometheusPorts;
|
||||||
}
|
}
|
||||||
) config.my-lxc
|
) config.my-lxc
|
||||||
|
|||||||
@@ -16,6 +16,37 @@ let
|
|||||||
];
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
environment.etc."alloy/logs-traefik.alloy".text =
|
||||||
|
(import ./alloy/default-journal-logger.alloy.nix {
|
||||||
|
inherit tools;
|
||||||
|
container = "proxy";
|
||||||
|
service = "traefik";
|
||||||
|
additional_stages = ''
|
||||||
|
stage.regex {
|
||||||
|
expression = "^(?P<client_ip>\\S+) (?P<ident>\\S+) (?P<auth_id>\\S+) \\[(?P<timestamp>[^\\]]+)\\] \"(?P<method>\\S+) (?P<path>\\S+) HTTP/(?P<http_version>\\S+)\" (?P<status>\\d+) (?P<bytes_sent>\\d+) \"(?P<referrer>[^\"]*)\" \"(?P<user_agent>[^\"]*)\" (?P<bytes_received>\\d+) \"(?P<router>[^\"]*)\" \"(?P<upstream>[^\"]*)\" (?P<duration>\\d+)ms$"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage.timestamp {
|
||||||
|
source = "timestamp"
|
||||||
|
format = "02/Jan/2006:15:04:05 -0700"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage.labels {
|
||||||
|
values = {
|
||||||
|
client_ip = "",
|
||||||
|
ident = "",
|
||||||
|
auth_id = "",
|
||||||
|
method = "",
|
||||||
|
status = "",
|
||||||
|
referrer = "",
|
||||||
|
router = "",
|
||||||
|
upstream = "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
'';
|
||||||
|
}).out;
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
traefik = {
|
traefik = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
environment.etc."yarrr.env".source = config.age.secrets.yarrr-env;
|
environment.etc."yarrr.env".source = config.age.secrets.yarrr-env.path;
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
bazarr = {
|
bazarr = {
|
||||||
|
|||||||
@@ -24,7 +24,9 @@
|
|||||||
logging = {
|
logging = {
|
||||||
enable = true;
|
enable = true;
|
||||||
metricsEnable = true;
|
metricsEnable = true;
|
||||||
prometheusPorts = [ 9187 ];
|
prometheusPorts = {
|
||||||
|
postgres = 9187;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
private = true;
|
private = true;
|
||||||
auth = true;
|
auth = true;
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
logging = {
|
logging = {
|
||||||
enable = true;
|
enable = true;
|
||||||
metricsEnable = true;
|
metricsEnable = true;
|
||||||
prometheusPorts = [
|
prometheusPorts = {
|
||||||
9167
|
unbound = 9167;
|
||||||
];
|
};
|
||||||
};
|
};
|
||||||
private = true;
|
private = true;
|
||||||
auth = true;
|
auth = true;
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ in
|
|||||||
logging = {
|
logging = {
|
||||||
enable = true;
|
enable = true;
|
||||||
metricsEnable = true;
|
metricsEnable = true;
|
||||||
prometheusPorts = [
|
prometheusPorts = {
|
||||||
9708
|
yarrr = 9708;
|
||||||
];
|
};
|
||||||
};
|
};
|
||||||
otherDomains = [
|
otherDomains = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -142,9 +142,9 @@ in
|
|||||||
enable = mkEnableOption "Whether to enable default logs collection";
|
enable = mkEnableOption "Whether to enable default logs collection";
|
||||||
metricsEnable = mkEnableOption "Whether to enable default metrics collection";
|
metricsEnable = mkEnableOption "Whether to enable default metrics collection";
|
||||||
prometheusPorts = mkOption {
|
prometheusPorts = mkOption {
|
||||||
type = listOf int;
|
type = attrsOf int;
|
||||||
description = "Ports of Prometheus Exporters";
|
description = "Service => ports of Prometheus Exporters";
|
||||||
default = [ ];
|
default = { };
|
||||||
};
|
};
|
||||||
alloyConfig = mkOption {
|
alloyConfig = mkOption {
|
||||||
type = attrsOf path;
|
type = attrsOf path;
|
||||||
|
|||||||
Reference in New Issue
Block a user