monitoring: added services
This commit is contained in:
parent
efb17ea7fa
commit
cb121c5369
12 changed files with 228 additions and 0 deletions
|
@ -2,5 +2,16 @@
|
||||||
imports = [
|
imports = [
|
||||||
./grafana.nix
|
./grafana.nix
|
||||||
./prometheus.nix
|
./prometheus.nix
|
||||||
|
|
||||||
|
./mon-postgres.nix
|
||||||
|
./mon-stalwart.nix
|
||||||
|
./mon-authelia.nix
|
||||||
|
./mon-matrix-synapse.nix
|
||||||
|
./mon-zfs.nix
|
||||||
|
./mon-miniflux.nix
|
||||||
|
./mon-hedgedoc.nix
|
||||||
|
./mon-forgejo.nix
|
||||||
|
./mon-uptime-kuma.nix
|
||||||
|
./mon-searx.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
23
machines/gerd/services/monitoring/mon-authelia.nix
Normal file
23
machines/gerd/services/monitoring/mon-authelia.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.authelia.instances.main.settings = {
|
||||||
|
telemetry.metrics = {
|
||||||
|
enabled = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "authelia";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ (lib.removePrefix "tcp://" config.services.authelia.instances.main.settings.telemetry.metrics.address) ];
|
||||||
|
}];
|
||||||
|
metric_relabel_configs = [{
|
||||||
|
source_labels = [ "__name__" ];
|
||||||
|
target_label = "__name__";
|
||||||
|
replacement = "authelia_$1";
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
14
machines/gerd/services/monitoring/mon-forgejo.nix
Normal file
14
machines/gerd/services/monitoring/mon-forgejo.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.forgejo.settings.metrics.ENABLED = true;
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "forgejo";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "localhost:${builtins.toString config.services.forgejo.settings.server.HTTPPORT}" ];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
18
machines/gerd/services/monitoring/mon-hedgedoc.nix
Normal file
18
machines/gerd/services/monitoring/mon-hedgedoc.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.hedgedoc.settings = {
|
||||||
|
# enabled by default anyways
|
||||||
|
# TODO(eyJhb): disable exposing this to the WORLD
|
||||||
|
enableStatsApi = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "hedgedoc";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "localhost:${builtins.toString config.services.hedgedoc.settings.port}"];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
27
machines/gerd/services/monitoring/mon-matrix-synapse.nix
Normal file
27
machines/gerd/services/monitoring/mon-matrix-synapse.nix
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
let
|
||||||
|
metrics_port = 9734;
|
||||||
|
in {
|
||||||
|
services.matrix-synapse = {
|
||||||
|
settings = {
|
||||||
|
enable_metrics = true;
|
||||||
|
listeners = [
|
||||||
|
{
|
||||||
|
port = metrics_port;
|
||||||
|
type = "metrics";
|
||||||
|
bind_addresses = [ "localhost" ];
|
||||||
|
tls = false;
|
||||||
|
resources = [];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "matrix-synapse";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "localhost:${builtins.toString metrics_port}"];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
16
machines/gerd/services/monitoring/mon-miniflux.nix
Normal file
16
machines/gerd/services/monitoring/mon-miniflux.nix
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.miniflux.config = {
|
||||||
|
METRICS_COLLECTOR = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "miniflux";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ config.services.miniflux.config.LISTEN_ADDR ];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
34
machines/gerd/services/monitoring/mon-postgres.nix
Normal file
34
machines/gerd/services/monitoring/mon-postgres.nix
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.prometheus.exporters.postgres = {
|
||||||
|
enable = true;
|
||||||
|
listenAddress = "localhost";
|
||||||
|
runAsLocalSuperUser = true;
|
||||||
|
|
||||||
|
extraFlags = let
|
||||||
|
extraQuery = pkgs.writeText "prometehus-postgres-query.yaml" ''
|
||||||
|
pg_database:
|
||||||
|
query: "SELECT pg_database.datname, pg_database_size(pg_database.datname) as size FROM pg_database"
|
||||||
|
metrics:
|
||||||
|
- datname:
|
||||||
|
usage: "LABEL"
|
||||||
|
description: "Name of the database"
|
||||||
|
- size:
|
||||||
|
usage: "GAUGE"
|
||||||
|
description: "Disk space used by the database"
|
||||||
|
'';
|
||||||
|
in [
|
||||||
|
"--extend.query-path=${extraQuery}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "postgres";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "localhost:${toString config.services.prometheus.exporters.postgres.port}" ];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
16
machines/gerd/services/monitoring/mon-searx.nix
Normal file
16
machines/gerd/services/monitoring/mon-searx.nix
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.searx.settings.general.open_metrics = "thisreallydoesnotmatterasitisnotaccessiblefromoutsideofthisserver";
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "searx";
|
||||||
|
basic_auth.username = "canbeanything";
|
||||||
|
basic_auth.password = config.services.searx.settings.general.open_metrics;
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ config.services.searx.uwsgiConfig.http ];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
22
machines/gerd/services/monitoring/mon-stalwart.nix
Normal file
22
machines/gerd/services/monitoring/mon-stalwart.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.stalwart-mail.settings = {
|
||||||
|
metrics.prometheus.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "stalwart";
|
||||||
|
metrics_path = "/metrics/prometheus";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "localhost:${toString config.mine.shared.settings.mail.ports.http_management}" ];
|
||||||
|
}];
|
||||||
|
metric_relabel_configs = [{
|
||||||
|
source_labels = [ "__name__" ];
|
||||||
|
target_label = "__name__";
|
||||||
|
replacement = "stalwart_$1";
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
12
machines/gerd/services/monitoring/mon-uptime-kuma.nix
Normal file
12
machines/gerd/services/monitoring/mon-uptime-kuma.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "uptime-kuma";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "localhost:${builtins.toString config.services.uptime-kuma.settings.PORT}" ];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
19
machines/gerd/services/monitoring/mon-zfs.nix
Normal file
19
machines/gerd/services/monitoring/mon-zfs.nix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.prometheus.exporters.zfs = {
|
||||||
|
enable = true;
|
||||||
|
listenAddress = "localhost";
|
||||||
|
|
||||||
|
extraFlags = [ "--collector.dataset-snapshot" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus.scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "zfs";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "localhost:${toString config.services.prometheus.exporters.zfs.port}" ];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
|
@ -37,6 +37,22 @@ in {
|
||||||
|
|
||||||
const Dialect = require("knex/lib/dialects/sqlite3/index.js");
|
const Dialect = require("knex/lib/dialects/sqlite3/index.js");
|
||||||
'')
|
'')
|
||||||
|
# TODO(eyJhb): do we really want this?
|
||||||
|
(pkgs.writeText "uptime-kuma-disable-metrics-auth.patch" ''
|
||||||
|
diff --git a/server/server.js b/server/server.js
|
||||||
|
index db58ae82..d650a42a 100644
|
||||||
|
--- a/server/server.js
|
||||||
|
+++ b/server/server.js
|
||||||
|
@@ -292,7 +292,7 @@ let needSetup = false;
|
||||||
|
|
||||||
|
// Prometheus API metrics /metrics
|
||||||
|
// With Basic Auth using the first user's username/password
|
||||||
|
- app.get("/metrics", apiAuth, prometheusAPIMetrics());
|
||||||
|
+ app.use("/metrics", prometheusAPIMetrics());
|
||||||
|
|
||||||
|
app.use("/", expressStaticGzip("dist", {
|
||||||
|
enableBrotli: true,
|
||||||
|
'')
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue