send logs from servers to loki

This commit is contained in:
Cyryl Płotnicki 2023-10-29 12:21:13 +00:00
parent ec7007844e
commit f55583a23e
5 changed files with 46 additions and 1 deletions

View file

@ -1,6 +1,7 @@
{lib, ...}: { {lib, ...}: {
imports = [ imports = [
../cli.nix ../cli.nix
../send-logs.nix
./bolty-boot.nix ./bolty-boot.nix
./gitea-runner.nix ./gitea-runner.nix
./home-assistant.nix ./home-assistant.nix

View file

@ -4,12 +4,13 @@
... ...
}: let }: let
lokiPort = 3030; lokiPort = 3030;
promtailPort = 3031;
path = "/data/loki"; path = "/data/loki";
in { in {
services.loki = { services.loki = {
enable = true; enable = true;
configuration = { configuration = {
server.http_listen_address = "bolty.raptor-carp.ts.net"; server.http_listen_address = "0.0.0.0";
server.http_listen_port = lokiPort; server.http_listen_port = lokiPort;
auth_enabled = false; auth_enabled = false;

View file

@ -8,6 +8,7 @@
imports = [ imports = [
"${inputs.nixpkgs-stable}/nixos/modules/profiles/qemu-guest.nix" "${inputs.nixpkgs-stable}/nixos/modules/profiles/qemu-guest.nix"
../cli.nix ../cli.nix
../send-logs.nix
./atuin.nix ./atuin.nix
./boot.nix ./boot.nix
./disks.nix ./disks.nix

41
nixos/boxes/send-logs.nix Normal file
View file

@ -0,0 +1,41 @@
{
config,
lib,
...
}: {
services.promtail = {
enable = true;
configuration = {
server = {
http_listen_port = 3031;
grpc_listen_port = 0;
};
positions = {
filename = "/tmp/positions.yaml";
};
clients = [
{
url = "http://bolty.raptor-carp.ts.net:3030/loki/api/v1/push";
}
];
scrape_configs = [
{
job_name = "journal";
journal = {
max_age = "12h";
labels = {
job = "systemd-journal";
host = config.networking.hostName;
};
};
relabel_configs = [
{
source_labels = ["__journal__systemd_unit"];
target_label = "unit";
}
];
}
];
};
};
}

View file

@ -5,6 +5,7 @@
./vpsfree1-vpsadminos.nix ./vpsfree1-vpsadminos.nix
../cli.nix ../cli.nix
../nginx.nix ../nginx.nix
../send-logs.nix
./backups.nix ./backups.nix
./cryptpad.nix ./cryptpad.nix
./foundryvtt.nix ./foundryvtt.nix