service/nextcloud: add monitoring

This commit is contained in:
Felix Buehler 2023-04-16 18:15:53 +02:00
parent d28d38bc23
commit 1e5bc4cf7e
5 changed files with 696 additions and 2 deletions

View file

@ -33,6 +33,21 @@ in
'nextcloud' user.
'';
};
exporterPasswordFile = mkOption {
type = types.path;
example = "/var/lib/nextcloud/password.txt";
description = ''
Path to a file containing the admin's password, must be readable by
'nextcloud' user.
'';
};
exporterPort = mkOption {
type = types.port;
default = 9205;
example = 8080;
description = "Internal port for the exporter";
};
};
config = lib.mkIf cfg.enable {
@ -107,6 +122,37 @@ in
];
};
services.prometheus.exporters.nextcloud = {
enable = true;
url = "https://cloud.${domain}";
username = cfg.admin;
passwordFile = cfg.exporterPasswordFile;
port = cfg.exporterPort;
};
services.prometheus.scrapeConfigs = [
{
job_name = "nextcloud";
static_configs = [
{
targets = [ "127.0.0.1:${toString cfg.exporterPort}" ];
labels = {
instance = config.networking.hostName;
};
}
];
}
];
services.grafana.provision = {
dashboards.settings.providers = [
{
name = "Nextcloud";
options.path = pkgs.grafana-dashboards.nextcloud;
disableDeletion = true;
}
];
};
webapps.apps.nextcloud = {
dashboard = {
name = "Cloud";