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

@ -13,6 +13,8 @@ freshrss:
password: ENC[AES256_GCM,data:dUOKeRxovwIHIchkwMFxsQYEKrU2muY=,iv:OA1zbIiV3NBWIoJLpxpLBEjR/I6m5vzVKvzMEZYYE7Q=,tag:r4PbEbEkSH3bsJMamDuuFw==,type:str] password: ENC[AES256_GCM,data:dUOKeRxovwIHIchkwMFxsQYEKrU2muY=,iv:OA1zbIiV3NBWIoJLpxpLBEjR/I6m5vzVKvzMEZYYE7Q=,tag:r4PbEbEkSH3bsJMamDuuFw==,type:str]
nextcloud: nextcloud:
password: ENC[AES256_GCM,data:uE507Ij34zJVYnd2YkNCGj8hpFpEM5w=,iv:x8BNCUaAas0poQ/Lo0izZApF6l52xal8DDrClIzWjvk=,tag:sA08dmcVQbKswX9hF/txag==,type:str] password: ENC[AES256_GCM,data:uE507Ij34zJVYnd2YkNCGj8hpFpEM5w=,iv:x8BNCUaAas0poQ/Lo0izZApF6l52xal8DDrClIzWjvk=,tag:sA08dmcVQbKswX9hF/txag==,type:str]
nextcloud-exporter:
password: ENC[AES256_GCM,data:ziQ/rVJx9NELSQA6/BeniH7joJPnc6Q=,iv:LtZ2Inm0V4ZRv0blRUNfXJOyFY85NkZo+5r31fs0oXM=,tag:5maJ5fkJU+JnbpLGf/MhOg==,type:str]
photoprism: photoprism:
password: ENC[AES256_GCM,data:FMf/JBsmn4G/EpZQGyEiYivUqw+13Lk=,iv:VEvbbei0Cc8j0J9OH/9cLXNIxvlLF7JsbLRzNVHEAug=,tag:MNHr6TpBsufXc5uGhCIZiw==,type:str] password: ENC[AES256_GCM,data:FMf/JBsmn4G/EpZQGyEiYivUqw+13Lk=,iv:VEvbbei0Cc8j0J9OH/9cLXNIxvlLF7JsbLRzNVHEAug=,tag:MNHr6TpBsufXc5uGhCIZiw==,type:str]
grafana: grafana:
@ -48,8 +50,8 @@ sops:
NmNwT3N5UEVabFdLTDhseFRjeVZaWFkKL3HGFqfttU1tXY4OhnIr1ABFsHB0R0CX NmNwT3N5UEVabFdLTDhseFRjeVZaWFkKL3HGFqfttU1tXY4OhnIr1ABFsHB0R0CX
s6wxb0ilut32ijjtnGXMIIa9y6XsMTpYskTb9FdRP9VnQQGVrMfdew== s6wxb0ilut32ijjtnGXMIIa9y6XsMTpYskTb9FdRP9VnQQGVrMfdew==
-----END AGE ENCRYPTED FILE----- -----END AGE ENCRYPTED FILE-----
lastmodified: "2023-04-07T17:26:03Z" lastmodified: "2023-04-16T15:46:59Z"
mac: ENC[AES256_GCM,data:86u56mQ2MAmP2AsjIxKlTXeKb6U0h41ABBOterlpeiX1K3a/UxUwQP+cw/+h6n+MDv6yvwCboakolhTz+jNoRMZJ9pjmTKi2zm+uqhauMh1Eawx0jgpqofdtVTuyS7QSxLs4ge03dfbybZYq3Pic8ZgfFGlbcYbtOwoJvrXQfnk=,iv:W4fuaT77nwjHBnznIVAiAPazgRW83QmH58i4VS8Ut34=,tag:dWOn4UGqq+s3eKHPz0MHfw==,type:str] mac: ENC[AES256_GCM,data:Kwi+5HbVO63/wROufE0FjnjSJCbnaqwIWR03ru0WAfm9eN9Sfd1bydYqxKMlYNRmfrEpJCOFeSP7inTYbrrC5EaqHog9MGIXti3m7Kk+iLfr/N4PBROivWZzmzyRNnNmTfHG09Ql/QS6vIkN+s027McN9tUAFRSPo/JNIPhYPPs=,iv:F70fsuT8vdQR1tHj3Z/MtFTS8sRSrhDrhGFNWXbrX+g=,tag:Y4kRAJXfzBTgczSHNPHx0Q==,type:str]
pgp: [] pgp: []
unencrypted_suffix: _unencrypted unencrypted_suffix: _unencrypted
version: 3.7.3 version: 3.7.3

View file

@ -14,6 +14,9 @@ in
sops.secrets."nextcloud/password" = { sops.secrets."nextcloud/password" = {
owner = config.users.users.nextcloud.name; owner = config.users.users.nextcloud.name;
}; };
sops.secrets."nextcloud-exporter/password" = {
owner = config.users.users.nextcloud-exporter.name;
};
sops.secrets."freshrss/password" = { sops.secrets."freshrss/password" = {
owner = config.users.users.freshrss.name; owner = config.users.users.freshrss.name;
}; };
@ -59,6 +62,7 @@ in
nextcloud = { nextcloud = {
enable = true; enable = true;
passwordFile = secrets."nextcloud/password".path; passwordFile = secrets."nextcloud/password".path;
exporterPasswordFile = secrets."nextcloud-exporter/password".path;
}; };
# document management system # document management system
paperless = { paperless = {

View file

@ -33,6 +33,21 @@ in
'nextcloud' user. '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 { 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 = { webapps.apps.nextcloud = {
dashboard = { dashboard = {
name = "Cloud"; name = "Cloud";

View file

@ -49,6 +49,15 @@ in
hash = "sha256-T1HqWbwt+i/We+Y2B7hcl3CijGxZF5QI38aPcXjk9y0="; hash = "sha256-T1HqWbwt+i/We+Y2B7hcl3CijGxZF5QI38aPcXjk9y0=";
}; };
nextcloud = (buildGrafanaDashboard {
id = 9632;
pname = "nextcloud";
version = "1";
hash = "sha256-Z28Q/sMg3jxglkszAs83IpL8f4p9loNnTQzjc3S/SAQ=";
}).overrideAttrs (self: super: {
src = ./nextcloud.json; # sadly only imported dashboards work
});
# navidrome = buildGrafanaDashboard { # navidrome = buildGrafanaDashboard {
# id = 18038; # id = 18038;
# pname = "navidrome"; # pname = "navidrome";

View file

@ -0,0 +1,633 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"description": "Export Nextcloud metrics",
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": 9632,
"graphTooltip": 0,
"id": 47,
"links": [],
"liveNow": false,
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 4,
"w": 12,
"x": 0,
"y": 0
},
"hiddenSeries": false,
"id": 4,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": true,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "9.4.7",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"expr": "nextcloud_auth_errors_total",
"format": "time_series",
"instant": false,
"intervalFactor": 1,
"legendFormat": "Auth Errors Total",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"expr": "",
"format": "time_series",
"intervalFactor": 1,
"refId": "B"
}
],
"thresholds": [],
"timeRegions": [],
"title": "Auth Errors",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"logBase": 1,
"min": "0",
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"match": "null",
"result": {
"text": "N/A"
}
},
"type": "special"
}
],
"max": 1,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "#d44a3a",
"value": null
},
{
"color": "rgba(237, 129, 40, 0.89)",
"value": 0.95
},
{
"color": "#299c46",
"value": 0.99
}
]
},
"unit": "percentunit"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 12,
"x": 12,
"y": 0
},
"id": 10,
"links": [],
"maxDataPoints": 100,
"options": {
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true
},
"pluginVersion": "9.4.7",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"expr": "avg(nextcloud_up)",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "",
"refId": "A"
}
],
"title": "Nextcloud Up ?",
"type": "gauge"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 4
},
"hiddenSeries": false,
"id": 8,
"legend": {
"alignAsTable": false,
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "9.4.7",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": true,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"expr": "sum(nextcloud_shares_federated_total)",
"format": "time_series",
"interval": "",
"intervalFactor": 1,
"legendFormat": "Federated Total",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"expr": "sum(nextcloud_shares_total)",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "Total Shares",
"refId": "B"
}
],
"thresholds": [],
"timeRegions": [],
"title": "Shares",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 4
},
"hiddenSeries": false,
"id": 6,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "9.4.7",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"expr": "nextcloud_files_total",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "Files Total",
"refId": "A"
}
],
"thresholds": [],
"timeRegions": [],
"title": "Files Count",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 13
},
"hiddenSeries": false,
"id": 2,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "9.4.7",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"expr": "nextcloud_users_total",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "Users Total",
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"expr": "nextcloud_active_users_total",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "Users Active",
"refId": "B"
}
],
"thresholds": [],
"timeRegions": [],
"title": "User Count",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 13
},
"hiddenSeries": false,
"id": 12,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "9.4.7",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "KNkR71YVk"
},
"expr": "nextcloud_scrape_errors_total",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "Scrape Errors Total",
"refId": "A"
}
],
"thresholds": [],
"timeRegions": [],
"title": "Scrape Errors",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"logBase": 1,
"min": "0",
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
}
],
"refresh": "",
"revision": 1,
"schemaVersion": 38,
"style": "dark",
"tags": [
"cloud",
"storage"
],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "",
"title": "Nextcloud",
"uid": "Hcp20_8mz",
"version": 1,
"weekStart": ""
}