Added Loki Data collector
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
lib,
|
||||
primaryUser,
|
||||
isServer,
|
||||
isDarwin,
|
||||
...
|
||||
}:
|
||||
{
|
||||
@@ -84,18 +83,41 @@
|
||||
};
|
||||
|
||||
services = {
|
||||
prometheus.exporters.node = lib.mkIf (!isDarwin) {
|
||||
prometheus.exporters.node = {
|
||||
enable = true;
|
||||
port = 9002;
|
||||
};
|
||||
|
||||
alloy = {
|
||||
enable = true;
|
||||
extraFlags = [ "--stability.level=public-preview" ];
|
||||
configPath = pkgs.writeText "config.alloy" ''
|
||||
loki.write "default" {
|
||||
endpoint {
|
||||
url = "http://192.168.2.30:3100/loki/api/v1/push"
|
||||
}
|
||||
}
|
||||
|
||||
loki.source.journal "journal" {
|
||||
forward_to = [loki.write.default.receiver]
|
||||
labels = {
|
||||
job = "systemd-journal",
|
||||
host = sys.env("HOSTNAME"),
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
gnome = lib.mkIf (!isServer) {
|
||||
tinysparql.enable = true;
|
||||
localsearch.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 9002 ];
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
9002
|
||||
3100
|
||||
];
|
||||
|
||||
users.users.${primaryUser} = {
|
||||
home = "/home/${primaryUser}";
|
||||
|
||||
@@ -39,6 +39,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
# TODO: Computers should register themselves
|
||||
prometheus = {
|
||||
enable = true;
|
||||
port = 9001;
|
||||
@@ -61,10 +62,55 @@ in
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
loki = {
|
||||
enable = true;
|
||||
configuration = {
|
||||
auth_enabled = false;
|
||||
server.http_listen_port = 3100;
|
||||
ingester = {
|
||||
lifecycler = {
|
||||
address = "127.0.0.1";
|
||||
ring = {
|
||||
kvstore.store = "inmemory";
|
||||
replication_factor = 1;
|
||||
};
|
||||
};
|
||||
chunk_idle_period = "5m";
|
||||
chunk_retain_period = "30s";
|
||||
};
|
||||
schema_config.configs = [
|
||||
{
|
||||
from = "2024-01-01";
|
||||
store = "tsdb";
|
||||
object_store = "filesystem";
|
||||
schema = "v13";
|
||||
index = {
|
||||
prefix = "index_";
|
||||
period = "24h";
|
||||
};
|
||||
}
|
||||
];
|
||||
storage_config = {
|
||||
tsdb_shipper = {
|
||||
active_index_directory = "/var/lib/loki/tsdb-index";
|
||||
cache_location = "/var/lib/loki/tsdb-cache";
|
||||
};
|
||||
filesystem.directory = "/var/lib/loki/chunks";
|
||||
};
|
||||
limits_config = {
|
||||
reject_old_samples = true;
|
||||
reject_old_samples_max_age = "168h";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
80
|
||||
443
|
||||
# TODO: Remove
|
||||
9001
|
||||
3100
|
||||
];
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
secrets = {
|
||||
grafana_secret_key = {
|
||||
owner = "grafana";
|
||||
group = "grafana";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user