Monitoring stack (almost done)
This commit is contained in:
parent
7d2ce03dc3
commit
b96176958c
4 changed files with 249 additions and 2 deletions
94
modules/monitoring/loki.nix
Normal file
94
modules/monitoring/loki.nix
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.my.monitoring.loki;
|
||||
in
|
||||
{
|
||||
options.my.monitoring.loki = {
|
||||
enable = mkEnableOption "Enable Loki log aggregation module";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.loki = {
|
||||
enable = true;
|
||||
configuration = {
|
||||
auth_enabled = false;
|
||||
|
||||
server.http_listen_port = 3100;
|
||||
server.log_level = "warn";
|
||||
|
||||
common = {
|
||||
ring = {
|
||||
instance_addr = "127.0.0.1";
|
||||
kvstore.store = "inmemory";
|
||||
};
|
||||
replication_factor = 1;
|
||||
path_prefix = config.services.loki.dataDir;
|
||||
};
|
||||
|
||||
schema_config = {
|
||||
configs = [
|
||||
{
|
||||
from = "2024-07-01";
|
||||
store = "tsdb";
|
||||
object_store = "filesystem";
|
||||
schema = "v13";
|
||||
index = {
|
||||
prefix = "index_";
|
||||
period = "24h";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
storage_config = {
|
||||
filesystem.directory = "${config.services.loki.dataDir}/chunks";
|
||||
tsdb_shipper.active_index_directory = "${config.services.loki.dataDir}/tsdb-index";
|
||||
tsdb_shipper.cache_location = "${config.services.loki.dataDir}/tsdb-cache";
|
||||
};
|
||||
|
||||
limits_config = {
|
||||
reject_old_samples = true;
|
||||
reject_old_samples_max_age = "168h";
|
||||
};
|
||||
|
||||
ruler = {
|
||||
storage = {
|
||||
type = "local";
|
||||
local.directory = "/tmp/rules";
|
||||
};
|
||||
rule_path = "/tmp/scratch";
|
||||
alertmanager_url = "http://nuc:9093";
|
||||
ring.kvstore.store = "inmemory";
|
||||
enable_api = true;
|
||||
};
|
||||
|
||||
query_scheduler = {
|
||||
max_outstanding_requests_per_tenant = 2048;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
services.grafana = {
|
||||
provision.datasources.settings = {
|
||||
datasources = [
|
||||
{
|
||||
name = "Loki localhost";
|
||||
url = "http://localhost:3100";
|
||||
type = "loki";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 3100 ];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue