Grafana Alloy and Loki Additions.
This commit is contained in:
parent
f771863d97
commit
c65057ded3
1 changed files with 70 additions and 11 deletions
|
|
@ -13,6 +13,38 @@
|
|||
fsType = "ext4";
|
||||
};
|
||||
};
|
||||
|
||||
environment.etc."alloy/config.alloy" = {
|
||||
text = ''
|
||||
server:
|
||||
http_listen_port: 28183
|
||||
grpc_listen_port: 0
|
||||
|
||||
logs:
|
||||
# keep positions persistent on disk (don't use /tmp in production)
|
||||
positions:
|
||||
filename: /var/lib/grafana-agent/positions.yaml
|
||||
|
||||
configs:
|
||||
- name: journal
|
||||
journal:
|
||||
# keep similar rotation / lookback to your promtail config
|
||||
max_age: 12h
|
||||
labels:
|
||||
job: systemd-journal
|
||||
host: chrysalis
|
||||
|
||||
clients:
|
||||
- url: http://127.0.0.1:3100/loki/api/v1/push
|
||||
|
||||
relabel_configs:
|
||||
- source_labels: ["__journal__systemd_unit"]
|
||||
target_label: "unit"
|
||||
'';
|
||||
owner = "root";
|
||||
group = "root";
|
||||
mode = "0644";
|
||||
};
|
||||
in {
|
||||
options.local = {
|
||||
hostname = lib.mkOption {
|
||||
|
|
@ -105,15 +137,42 @@ in {
|
|||
];
|
||||
};
|
||||
|
||||
#services.loki = {
|
||||
# enable = true;
|
||||
#
|
||||
# configuration = {
|
||||
# auth_enabled = false;
|
||||
# server.http_listen_port = 3100;
|
||||
#
|
||||
# # etc.
|
||||
# };
|
||||
services.loki = {
|
||||
enable = true;
|
||||
|
||||
configuration = {
|
||||
auth_enabled = false;
|
||||
server.http_listen_port = 3100;
|
||||
|
||||
# etc.
|
||||
};
|
||||
};
|
||||
|
||||
services.alloy = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
# Add a simple systemd service to run the Grafana Agent (Alloy)
|
||||
systemd.services.grafana-agent = {
|
||||
description = "Grafana Alloy - journal -> loki";
|
||||
wantedBy = ["multi-user.target"];
|
||||
|
||||
serviceConfig = {
|
||||
# Ensure persistent dir for positions exists
|
||||
ExecStartPre = ''
|
||||
mkdir -p /var/lib/grafana-agent
|
||||
chown root:root /var/lib/grafana-agent
|
||||
'';
|
||||
|
||||
# The grafana-agent binary provided by nixpkgs
|
||||
ExecStart = ''
|
||||
${pkgs.grafana-alloy}/bin/grafana-alloy --config.file /etc/alloy/config.alloy
|
||||
'';
|
||||
|
||||
Restart = "on-failure";
|
||||
RestartSec = "5s";
|
||||
};
|
||||
};
|
||||
|
||||
# or alternatively
|
||||
#configFile = ./loki-config.yaml;
|
||||
|
|
@ -122,7 +181,7 @@ in {
|
|||
# Enable Tailscale for remote access to Traefik dashboard and configuration
|
||||
services.tailscale.enable = true;
|
||||
|
||||
networking.firewall.allowedTCPPorts = [3005];
|
||||
networking.firewall.allowedUDPPorts = [3005];
|
||||
networking.firewall.allowedTCPPorts = [3000];
|
||||
networking.firewall.allowedUDPPorts = [3000];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue