grafana tweaks
This commit is contained in:
parent
3291b8ae04
commit
f1cd1e461f
1 changed files with 23 additions and 23 deletions
|
|
@ -10,13 +10,9 @@ in {
|
|||
type = types.str;
|
||||
default = "grafana.reidlab.pink";
|
||||
};
|
||||
orgId = mkOption {
|
||||
type = types.int;
|
||||
default = 1;
|
||||
};
|
||||
grafanaPort = mkOption {
|
||||
type = types.int;
|
||||
default = 3000;
|
||||
grafanaSocket = mkOption {
|
||||
type = types.str;
|
||||
default = "/run/grafana/grafana.sock";
|
||||
};
|
||||
alloyPort = mkOption {
|
||||
type = types.int;
|
||||
|
|
@ -43,19 +39,19 @@ in {
|
|||
settings = {
|
||||
server = {
|
||||
domain = cfg.domain;
|
||||
http_port = cfg.grafanaPort;
|
||||
http_addr = "127.0.0.1";
|
||||
protocol = "socket";
|
||||
socket = cfg.grafanaSocket;
|
||||
};
|
||||
database.type = "sqlite3"; # TODO: use postgres?
|
||||
# use default secret key
|
||||
# TODO: maybe don't do that idk
|
||||
# TODO: maybe don't do that idk
|
||||
security.secret_key = "SW2YcwTIb9zpOOhoPsMm";
|
||||
};
|
||||
|
||||
provision.datasources.settings = {
|
||||
prune = true; # delete datasources if not in provision file
|
||||
datasources = [
|
||||
{
|
||||
orgId = cfg.orgId;
|
||||
name = "Prometheus";
|
||||
type = "prometheus";
|
||||
url = "http://127.0.0.1:${toString cfg.prometheusPort}";
|
||||
|
|
@ -63,23 +59,12 @@ in {
|
|||
isDefault = true;
|
||||
}
|
||||
{
|
||||
orgId = cfg.orgId;
|
||||
name = "Loki";
|
||||
type = "loki";
|
||||
url = "http://127.0.0.1:${toString cfg.lokiPort}";
|
||||
uid = "loki";
|
||||
}
|
||||
];
|
||||
deleteDatasources = [
|
||||
{
|
||||
orgId = cfg.orgId;
|
||||
name = "Prometheus";
|
||||
}
|
||||
{
|
||||
orgId = cfg.orgId;
|
||||
name = "Loki";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -89,6 +74,7 @@ in {
|
|||
ports = {
|
||||
node = mkPort 0;
|
||||
nginx = mkPort 1;
|
||||
smartctl = mkPort 2;
|
||||
};
|
||||
in {
|
||||
enable = true;
|
||||
|
|
@ -105,6 +91,10 @@ in {
|
|||
enable = true;
|
||||
port = ports.nginx;
|
||||
};
|
||||
smartctl = {
|
||||
enable = true;
|
||||
port = ports.smartctl;
|
||||
};
|
||||
};
|
||||
|
||||
scrapeConfigs = let
|
||||
|
|
@ -126,6 +116,13 @@ in {
|
|||
labels = commonLabels;
|
||||
}];
|
||||
}
|
||||
{
|
||||
job_name = "smartctl";
|
||||
static_configs = [{
|
||||
targets = [ "127.0.0.1:${toString ports.smartctl}" ];
|
||||
labels = commonLabels;
|
||||
}];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
|
|
@ -241,12 +238,15 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
# fix unix sockets
|
||||
systemd.services.nginx.serviceConfig.SupplementaryGroups = [ "grafana" ];
|
||||
|
||||
services.nginx.statusPage = true;
|
||||
services.nginx.virtualHosts."${cfg.domain}" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString cfg.grafanaPort}";
|
||||
proxyPass = "http://unix:${cfg.grafanaSocket}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
locations."= /robots.txt" = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue