Completed the part with caddy. Problems with exporterr and api keys
This commit is contained in:
parent
58d5c8a812
commit
4e649d4344
6 changed files with 147 additions and 20 deletions
|
|
@ -2,6 +2,7 @@
|
|||
imports = [
|
||||
# Folders
|
||||
./desktop
|
||||
./monitoring
|
||||
./networking
|
||||
./services
|
||||
./systems
|
||||
|
|
|
|||
1
modules/monitoring/default.nix
Normal file
1
modules/monitoring/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ imports = [ ./prometheus.nix ]; }
|
||||
77
modules/monitoring/prometheus.nix
Normal file
77
modules/monitoring/prometheus.nix
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
{ config
|
||||
, pkgs
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.my.monitoring.prometheus;
|
||||
|
||||
in
|
||||
{
|
||||
options.my.monitoring.prometheus = {
|
||||
enable = lib.mkEnableOption "Enable prometheus as a data scraper";
|
||||
|
||||
proxy = {
|
||||
enable = lib.mkEnableOption "Set the proxy entry for this service";
|
||||
|
||||
domain = lib.mkOption {
|
||||
default = "example.com";
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The domain where Caddy is reachable
|
||||
'';
|
||||
};
|
||||
|
||||
host = lib.mkOption {
|
||||
default = "localhost";
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Host name where the download manager stack is running
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf cfg.enable {
|
||||
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "download-mgr-stack";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [
|
||||
"localhost:${toString config.services.prometheus.exporters.exportarr-prowlarr.port}"
|
||||
"localhost:${toString config.services.prometheus.exporters.exportarr-radarr.port}"
|
||||
"localhost:${toString config.services.prometheus.exporters.exportarr-sonarr.port}"
|
||||
"localhost:${toString config.services.prometheus.exporters.exportarr-lidarr.port}"
|
||||
"localhost:${toString config.services.prometheus.exporters.exportarr-readarr.port}"
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 9090 ];
|
||||
|
||||
})
|
||||
|
||||
(lib.mkIf (cfg.proxy != { }) {
|
||||
services.caddy = with cfg.proxy; {
|
||||
virtualHosts."prometheus.${domain}".extraConfig = ''
|
||||
reverse_proxy http://${host}:9090
|
||||
import cloudflare
|
||||
'';
|
||||
};
|
||||
})
|
||||
];
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
{ lib
|
||||
, config
|
||||
, pkgs
|
||||
, ...
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
|
|
@ -26,6 +27,15 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
magicDNSDomain = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
example = "example.ts.net";
|
||||
description = ''
|
||||
This unique name is used when registering DNS entries, sharing your device to other tailnets, and issuing TLS certificates
|
||||
'';
|
||||
};
|
||||
|
||||
exitNode = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
|
|
@ -53,6 +63,12 @@ in
|
|||
useRoutingFeatures = if cfg.exitNode == "" then "none" else "both";
|
||||
extraUpFlags = [ "--exit-node=${cfg.exitNode}" ] ++ cfg.extraUpFlags;
|
||||
};
|
||||
|
||||
networking = {
|
||||
nameservers = [ "100.100.100.100" ];
|
||||
search = [ cfg.magicDNSDomain ];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue