[metrics] Gets Loki and Prometheus set up with Grafana
This commit is contained in:
@@ -103,6 +103,10 @@
|
|||||||
enable = true;
|
enable = true;
|
||||||
enabledCollectors = [ "systemd" ];
|
enabledCollectors = [ "systemd" ];
|
||||||
port = 9002;
|
port = 9002;
|
||||||
|
# Open the firewall, but only listen on the internal address
|
||||||
|
# TODO: Add some form authentication
|
||||||
|
openFirewall = true;
|
||||||
|
listenAddress = "10.88.0.1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ in {
|
|||||||
image = "grafana/grafana-enterprise";
|
image = "grafana/grafana-enterprise";
|
||||||
dependsOn = [
|
dependsOn = [
|
||||||
"db"
|
"db"
|
||||||
|
"loki"
|
||||||
];
|
];
|
||||||
hostName = "grafana";
|
hostName = "grafana";
|
||||||
|
domain = lib.blazestar;
|
||||||
port = 3000;
|
port = 3000;
|
||||||
homepageOpts = {
|
homepageOpts = {
|
||||||
group = "Infra";
|
group = "Infra";
|
||||||
@@ -23,7 +25,42 @@ in {
|
|||||||
"grafana-storage:/var/lib/grafana"
|
"grafana-storage:/var/lib/grafana"
|
||||||
];
|
];
|
||||||
environment = {
|
environment = {
|
||||||
GF_SERVER_ROOT_URL = "https://grafna.havenisms.com";
|
GF_SERVER_ROOT_URL = "https://grafana.${lib.blazestar}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualisation.oci-containers.containers.loki = lib.mkContainer {
|
||||||
|
image = "grafana/loki";
|
||||||
|
hostName = "loki";
|
||||||
|
domain = lib.blazestar;
|
||||||
|
port = 3100;
|
||||||
|
homepageOpts = {
|
||||||
|
group = "Infra";
|
||||||
|
icon = "loki.png";
|
||||||
|
name = "Loki";
|
||||||
|
description = "Log Database";
|
||||||
|
};
|
||||||
|
environment = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.promtail = {
|
||||||
|
enable = true;
|
||||||
|
configuration = {
|
||||||
|
server.http_listen_port = 9080;
|
||||||
|
clients = [
|
||||||
|
{ url = "https://loki.blazestar.net/loki/api/v1/push"; }
|
||||||
|
];
|
||||||
|
scrape_configs = [{
|
||||||
|
job_name = "journal";
|
||||||
|
journal = {
|
||||||
|
max_age = "12h";
|
||||||
|
labels = { job = "systemd-journal"; };
|
||||||
|
};
|
||||||
|
relabel_configs = [{
|
||||||
|
source_labels = ["__journal__systemd_unit"];
|
||||||
|
target_label = "unit";
|
||||||
|
}];
|
||||||
|
}];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ let
|
|||||||
hostRule = host: domain: "Host(`${host}.${domain}`)";
|
hostRule = host: domain: "Host(`${host}.${domain}`)";
|
||||||
hostRuleHavenisms = host: hostRule host havenisms;
|
hostRuleHavenisms = host: hostRule host havenisms;
|
||||||
localNet = "192.168.0.0/16";
|
localNet = "192.168.0.0/16";
|
||||||
localNetRule = "ClientIP(`${localNet}`)";
|
dockerNet = "10.88.0.0/16";
|
||||||
|
localNetRule = "(ClientIP(`${localNet}`) || ClientIP(`${dockerNet}`))";
|
||||||
localHostRule = host: domain: "${localNetRule} && ${hostRule host domain}";
|
localHostRule = host: domain: "${localNetRule} && ${hostRule host domain}";
|
||||||
localHostRuleHavenisms = host: localHostRule host havenisms;
|
localHostRuleHavenisms = host: localHostRule host havenisms;
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, ... }:
|
||||||
let inherit (import ./lib.nix config) mkContainer; in
|
let inherit (import ./lib.nix config) mkContainer blazestar; in
|
||||||
{
|
{
|
||||||
virtualisation.oci-containers.containers.prometheus = mkContainer {
|
virtualisation.oci-containers.containers.prometheus = mkContainer {
|
||||||
image = "prom/prometheus";
|
image = "prom/prometheus";
|
||||||
hostName = "prometheus";
|
hostName = "prometheus";
|
||||||
|
domain = blazestar;
|
||||||
port = 9090;
|
port = 9090;
|
||||||
volumes = [
|
volumes = [
|
||||||
"/tank/config/prometheus:/etc/prometheus"
|
"/tank/config/prometheus:/etc/prometheus"
|
||||||
|
|||||||
Reference in New Issue
Block a user