mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 16:39:07 +01:00
victorialogs: Remove module
This commit is contained in:
parent
9e79934cf2
commit
7a6b17fb36
4 changed files with 12 additions and 152 deletions
|
|
@ -55,11 +55,6 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = "metrics.${privateDomain}";
|
domain = "metrics.${privateDomain}";
|
||||||
};
|
};
|
||||||
|
|
||||||
victorialogs = {
|
|
||||||
enable = true;
|
|
||||||
domain = "logs.${privateDomain}";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,48 +17,25 @@ in
|
||||||
type = lib.types.nonEmptyStr;
|
type = lib.types.nonEmptyStr;
|
||||||
default = "https://metrics.${config.custom.networking.overlay.domain}/prometheus/api/v1/write";
|
default = "https://metrics.${config.custom.networking.overlay.domain}/prometheus/api/v1/write";
|
||||||
};
|
};
|
||||||
logsEndpoint = lib.mkOption {
|
collect.metrics = {
|
||||||
type = lib.types.nonEmptyStr;
|
system = lib.mkEnableOption "" // {
|
||||||
default = "https://logs.${config.custom.networking.overlay.domain}/insert/loki/api/v1/push";
|
default = true;
|
||||||
};
|
|
||||||
collect = {
|
|
||||||
metrics = {
|
|
||||||
system = lib.mkEnableOption "" // {
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
victorialogs = lib.mkEnableOption "" // {
|
|
||||||
default = config.services.victorialogs.enable;
|
|
||||||
};
|
|
||||||
caddy = lib.mkEnableOption "" // {
|
|
||||||
default = config.services.caddy.enable;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
logs.openssh = lib.mkEnableOption "" // {
|
caddy = lib.mkEnableOption "" // {
|
||||||
default = config.services.openssh.enable;
|
default = config.services.caddy.enable;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
assertions =
|
assertions =
|
||||||
let
|
cfg.collect.metrics
|
||||||
metricsAssertions =
|
|> lib.attrNames
|
||||||
cfg.collect.metrics
|
|> lib.filter (name: name != "system")
|
||||||
|> lib.attrNames
|
|> lib.map (name: {
|
||||||
|> lib.filter (name: name != "system")
|
assertion = cfg.collect.metrics.${name} -> config.services.${name}.enable;
|
||||||
|> lib.map (name: {
|
message = "Alloy cannot collect `${name}` metrics without the `${name}` service";
|
||||||
assertion = cfg.collect.metrics.${name} -> config.services.${name}.enable;
|
});
|
||||||
message = "Alloy cannot collect `${name}` metrics without the `${name}` service";
|
|
||||||
});
|
|
||||||
logsAssertions =
|
|
||||||
cfg.collect.logs
|
|
||||||
|> lib.attrNames
|
|
||||||
|> lib.map (name: {
|
|
||||||
assertion = cfg.collect.logs.${name} -> config.services.${name}.enable;
|
|
||||||
message = "Alloy cannot collect '${name}' logs without the '${name}' service";
|
|
||||||
});
|
|
||||||
in
|
|
||||||
metricsAssertions ++ logsAssertions;
|
|
||||||
|
|
||||||
services.alloy = {
|
services.alloy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -84,16 +61,6 @@ in
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
"alloy/logs-endpoint.alloy" = {
|
|
||||||
enable = cfg.collect.logs |> anyIsTrue;
|
|
||||||
text = ''
|
|
||||||
loki.write "default" {
|
|
||||||
endpoint {
|
|
||||||
url = "${cfg.logsEndpoint}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
"alloy/system-metrics.alloy" = {
|
"alloy/system-metrics.alloy" = {
|
||||||
enable = cfg.collect.metrics.system;
|
enable = cfg.collect.metrics.system;
|
||||||
text = ''
|
text = ''
|
||||||
|
|
@ -108,20 +75,6 @@ in
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
"alloy/victorialogs-metrics.alloy" = {
|
|
||||||
enable = cfg.collect.metrics.victorialogs;
|
|
||||||
text = ''
|
|
||||||
prometheus.scrape "victorialogs" {
|
|
||||||
targets = [{
|
|
||||||
__address__ = "localhost:${toString config.custom.web-services.victorialogs.port}",
|
|
||||||
job = "victorialogs",
|
|
||||||
instance = constants.hostname,
|
|
||||||
}]
|
|
||||||
forward_to = [prometheus.remote_write.default.receiver]
|
|
||||||
scrape_interval = "15s"
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
"alloy/caddy-metrics.alloy" = {
|
"alloy/caddy-metrics.alloy" = {
|
||||||
enable = cfg.collect.metrics.caddy;
|
enable = cfg.collect.metrics.caddy;
|
||||||
text = ''
|
text = ''
|
||||||
|
|
@ -136,15 +89,6 @@ in
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
"alloy/sshd-logs.alloy" = {
|
|
||||||
enable = cfg.collect.logs.openssh;
|
|
||||||
text = ''
|
|
||||||
loki.source.journal "sshd" {
|
|
||||||
matches = "_SYSTEMD_UNIT=sshd.service"
|
|
||||||
forward_to = [loki.write.default.receiver]
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
custom.services.caddy.virtualHosts.${cfg.domain}.port = cfg.port;
|
custom.services.caddy.virtualHosts.${cfg.domain}.port = cfg.port;
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,6 @@ in
|
||||||
default = "https://${config.custom.web-services.victoriametrics.domain}";
|
default = "https://${config.custom.web-services.victoriametrics.domain}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
victorialogs = {
|
|
||||||
enable = lib.mkEnableOption "" // {
|
|
||||||
default = config.custom.web-services.victorialogs.enable;
|
|
||||||
};
|
|
||||||
url = lib.mkOption {
|
|
||||||
type = lib.types.nonEmptyStr;
|
|
||||||
default = "https://${config.custom.web-services.victorialogs.domain}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
dashboards = {
|
dashboards = {
|
||||||
nodeExporter.enable = lib.mkEnableOption "" // {
|
nodeExporter.enable = lib.mkEnableOption "" // {
|
||||||
|
|
@ -54,9 +45,6 @@ in
|
||||||
victoriametrics.enable = lib.mkEnableOption "" // {
|
victoriametrics.enable = lib.mkEnableOption "" // {
|
||||||
default = config.custom.web-services.victoriametrics.enable;
|
default = config.custom.web-services.victoriametrics.enable;
|
||||||
};
|
};
|
||||||
victorialogs.enable = lib.mkEnableOption "" // {
|
|
||||||
default = config.custom.web-services.victorialogs.enable;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -110,12 +98,6 @@ in
|
||||||
inherit (cfg.datasources.victoriametrics) url;
|
inherit (cfg.datasources.victoriametrics) url;
|
||||||
isDefault = false;
|
isDefault = false;
|
||||||
})
|
})
|
||||||
(lib.mkIf cfg.datasources.victorialogs.enable {
|
|
||||||
name = "VictoriaLogs";
|
|
||||||
type = "victoriametrics-logs-datasource";
|
|
||||||
inherit (cfg.datasources.victorialogs) url;
|
|
||||||
isDefault = false;
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -126,7 +108,6 @@ in
|
||||||
in
|
in
|
||||||
[
|
[
|
||||||
(lib.optional cfg.datasources.victoriametrics.enable plugins.victoriametrics-metrics-datasource)
|
(lib.optional cfg.datasources.victoriametrics.enable plugins.victoriametrics-metrics-datasource)
|
||||||
(lib.optional cfg.datasources.victorialogs.enable plugins.victoriametrics-logs-datasource)
|
|
||||||
]
|
]
|
||||||
|> lib.concatLists;
|
|> lib.concatLists;
|
||||||
};
|
};
|
||||||
|
|
@ -157,22 +138,6 @@ in
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
# https://grafana.com/grafana/dashboards/22084-victorialogs-single-node/
|
|
||||||
"grafana-dashboards/victorialogs-single-node-patched.json" = {
|
|
||||||
enable = cfg.dashboards.victorialogs.enable;
|
|
||||||
source =
|
|
||||||
pkgs.fetchurl {
|
|
||||||
name = "victorialogs-single-node.json";
|
|
||||||
url = "https://grafana.com/api/dashboards/22084/revisions/8/download";
|
|
||||||
hash = "sha256-/a3Rbp/6oyiLBnQtGupyFZW+fIHQfkyKRRTyfofxVTM=";
|
|
||||||
}
|
|
||||||
|> (
|
|
||||||
src:
|
|
||||||
pkgs.runCommand "victorialogs-single-node-patched.json" { buildInputs = [ pkgs.gnused ]; } ''
|
|
||||||
sed 's/victoria-logs-//g' ${src} > $out
|
|
||||||
''
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
custom.services.caddy.virtualHosts.${cfg.domain}.port = cfg.port;
|
custom.services.caddy.virtualHosts.${cfg.domain}.port = cfg.port;
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
{ config, lib, ... }:
|
|
||||||
let
|
|
||||||
cfg = config.custom.web-services.victorialogs;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.custom.web-services.victorialogs = {
|
|
||||||
enable = lib.mkEnableOption "";
|
|
||||||
domain = lib.mkOption {
|
|
||||||
type = lib.types.nonEmptyStr;
|
|
||||||
default = "";
|
|
||||||
};
|
|
||||||
port = lib.mkOption {
|
|
||||||
type = lib.types.port;
|
|
||||||
default = 9428;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
|
||||||
users = {
|
|
||||||
users.victorialogs = {
|
|
||||||
isSystemUser = true;
|
|
||||||
group = config.users.groups.victoriametrics.name;
|
|
||||||
};
|
|
||||||
groups.victorialogs = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.victorialogs.serviceConfig = {
|
|
||||||
DynamicUser = lib.mkForce false;
|
|
||||||
User = config.users.users.victorialogs.name;
|
|
||||||
Group = config.users.groups.victorialogs.name;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.victorialogs = {
|
|
||||||
enable = true;
|
|
||||||
listenAddress = "localhost:${toString cfg.port}";
|
|
||||||
};
|
|
||||||
|
|
||||||
custom = {
|
|
||||||
services.caddy.virtualHosts.${cfg.domain}.port = cfg.port;
|
|
||||||
|
|
||||||
persistence.directories = [ "/var/lib/${config.services.victorialogs.stateDir}" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue