mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-22 00:21:34 +01:00
caddy: Expose metrics without the admin api
This commit is contained in:
parent
c917eed038
commit
3d0d4ea31d
2 changed files with 14 additions and 2 deletions
|
|
@ -126,7 +126,7 @@ in
|
||||||
text = ''
|
text = ''
|
||||||
prometheus.scrape "caddy" {
|
prometheus.scrape "caddy" {
|
||||||
targets = [{
|
targets = [{
|
||||||
__address__ = "localhost:2019",
|
__address__ = "localhost:${builtins.toString config.custom.services.caddy.metrics.port}",
|
||||||
instance = constants.hostname,
|
instance = constants.hostname,
|
||||||
}]
|
}]
|
||||||
forward_to = [prometheus.remote_write.default.receiver]
|
forward_to = [prometheus.remote_write.default.receiver]
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ in
|
||||||
enable = lib.mkEnableOption "" // {
|
enable = lib.mkEnableOption "" // {
|
||||||
default = virtualHosts != { };
|
default = virtualHosts != { };
|
||||||
};
|
};
|
||||||
|
metrics.port = lib.mkOption {
|
||||||
|
type = lib.types.port;
|
||||||
|
default = 49514;
|
||||||
|
};
|
||||||
virtualHosts = lib.mkOption {
|
virtualHosts = lib.mkOption {
|
||||||
type = lib.types.attrsOf (
|
type = lib.types.attrsOf (
|
||||||
lib.types.submodule (
|
lib.types.submodule (
|
||||||
|
|
@ -63,9 +67,11 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf (virtualHosts != { }) (
|
config = lib.mkIf (virtualHosts != [ ]) (
|
||||||
lib.mkMerge [
|
lib.mkMerge [
|
||||||
{
|
{
|
||||||
|
meta.ports.tcp.list = [ cfg.metrics.port ];
|
||||||
|
|
||||||
services.caddy = {
|
services.caddy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.caddy.withPlugins {
|
package = pkgs.caddy.withPlugins {
|
||||||
|
|
@ -75,9 +81,15 @@ in
|
||||||
];
|
];
|
||||||
hash = "sha256-117vurf98sK/4o3JU3rBwNBUjnZZyFRJ1mq5T1S1IxY=";
|
hash = "sha256-117vurf98sK/4o3JU3rBwNBUjnZZyFRJ1mq5T1S1IxY=";
|
||||||
};
|
};
|
||||||
|
enableReload = false;
|
||||||
globalConfig = ''
|
globalConfig = ''
|
||||||
|
admin off
|
||||||
metrics { per_host }
|
metrics { per_host }
|
||||||
'';
|
'';
|
||||||
|
virtualHosts.":${builtins.toString cfg.metrics.port}" = {
|
||||||
|
logFormat = "";
|
||||||
|
extraConfig = "metrics /metrics";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
custom.persist.directories = [ "/var/lib/caddy" ];
|
custom.persist.directories = [ "/var/lib/caddy" ];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue