mirror of
https://github.com/RGBCube/ncc
synced 2025-07-30 11:37:44 +00:00
Use postgresql instead of sqlite for grafana
This commit is contained in:
parent
f4279be9bc
commit
92e8a6630b
2 changed files with 51 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
{ config, ulib, ... }: with ulib;
|
{ config, pkgs, ulib, ... }: with ulib;
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (config.networking) domain;
|
inherit (config.networking) domain;
|
||||||
|
@ -10,18 +10,31 @@ in serverSystemConfiguration {
|
||||||
group = "grafana";
|
group = "grafana";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.postgresql = {
|
||||||
|
ensureDatabases = [ "grafana" ];
|
||||||
|
initialScript = pkgs.writeText "postgresql-initial-script" ''
|
||||||
|
CREATE ROLE grafana WITH LOGIN PASSWORD NULL CREATEDB;
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE grafana TO grafana;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
services.grafana = enabled {
|
services.grafana = enabled {
|
||||||
domain = fqdn;
|
domain = fqdn;
|
||||||
port = 8999;
|
port = 8999;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
database.host = "/run/postgresql";
|
||||||
|
database.type = "postgres";
|
||||||
|
database.user = "grafana";
|
||||||
|
|
||||||
|
server.http_addr = "::";
|
||||||
|
users.default_theme = "system";
|
||||||
|
};
|
||||||
|
|
||||||
settings.security = {
|
settings.security = {
|
||||||
admin_email = "metrics@${domain}";
|
admin_email = "metrics@${domain}";
|
||||||
admin_password = "$__file{${config.age.secrets."cube.mail.password".path}}";
|
admin_password = "$__file{${config.age.secrets."cube.mail.password".path}}";
|
||||||
};
|
};
|
||||||
|
|
||||||
settings.server.http_addr = "::";
|
|
||||||
|
|
||||||
settings.users.default_theme = "system";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts.${fqdn} = {
|
services.nginx.virtualHosts.${fqdn} = {
|
||||||
|
|
33
hosts/cube/postgresql.nix
Normal file
33
hosts/cube/postgresql.nix
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{ config, lib, ulib, ... }: with ulib;
|
||||||
|
|
||||||
|
serverSystemConfiguration {
|
||||||
|
services.prometheus.exporters.postgres = enabled {
|
||||||
|
port = 9030;
|
||||||
|
runAsLocalSuperUser = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [{
|
||||||
|
job_name = "postgres";
|
||||||
|
|
||||||
|
static_configs = [{
|
||||||
|
labels.job = "postgres";
|
||||||
|
targets = [ "[::]:${toString config.services.prometheus.exporters.postgres.port}" ];
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
|
||||||
|
services.postgresql = enabled {
|
||||||
|
enableTCPIP = true;
|
||||||
|
|
||||||
|
authentication = lib.mkOverride 10 ''
|
||||||
|
# Type Database DBUser Authentication IdentMap
|
||||||
|
local sameuser all peer map=superuser_map
|
||||||
|
'';
|
||||||
|
|
||||||
|
identMap = ''
|
||||||
|
# Map System DBUser
|
||||||
|
superuser_map root postgres
|
||||||
|
superuser_map postgres postgres
|
||||||
|
superuser_map /^(.*)$ \1
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue