feat: implement centralized alerting with vmalert and Grafana, add alert rules for CPU, disk, inode, RAM usage, and host status
This commit is contained in:
38
hosts/web-arm/modules/vmalert/default.nix
Normal file
38
hosts/web-arm/modules/vmalert/default.nix
Normal file
@@ -0,0 +1,38 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
./rules/cpu_usage.nix
|
||||
./rules/disk_usage.nix
|
||||
./rules/host_down.nix
|
||||
./rules/inode_usage.nix
|
||||
./rules/ram_usage.nix
|
||||
];
|
||||
|
||||
# Standard vmalert service configuration
|
||||
services.vmalert = {
|
||||
enable = true;
|
||||
settings = {
|
||||
"datasource.url" = "http://localhost:8428"; # VictoriaMetrics address
|
||||
"notifier.url" = [ "http://localhost:3001/api/alertmanager/grafana/api/v2/alerts" ]; # Must be a list of strings
|
||||
};
|
||||
# 'rules' is now set by the mkMerge block above.
|
||||
};
|
||||
|
||||
# Override the User and Group for the systemd service managed by the official vmalert module.
|
||||
systemd.services.vmalert = {
|
||||
serviceConfig = {
|
||||
User = "victoriametrics";
|
||||
Group = "victoriametrics";
|
||||
};
|
||||
};
|
||||
|
||||
# Ensure the user/group itself exists on the system.
|
||||
users.users.victoriametrics = lib.mkIf (config.services.victoriametrics.enable || config.services.vmalert.enable) {
|
||||
isSystemUser = true;
|
||||
group = "victoriametrics"; # Primary group for the user
|
||||
home = "/var/lib/victoriametrics"; # Standard home for VictoriaMetrics components
|
||||
};
|
||||
users.groups.victoriametrics = lib.mkIf (config.services.victoriametrics.enable || config.services.vmalert.enable) {
|
||||
# Ensures the group exists.
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user