From 7958dbb8a703c14f095376b2fedb822fb4276bbe Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Tue, 29 Dec 2020 13:15:51 -0500 Subject: [PATCH 1/5] nixos/prometheus: add gce_sd_configs scrapeConfig option --- .../monitoring/prometheus/default.nix | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix index 4f9be38f7f14a4..b2df0f5b79a30c 100644 --- a/nixos/modules/services/monitoring/prometheus/default.nix +++ b/nixos/modules/services/monitoring/prometheus/default.nix @@ -370,6 +370,14 @@ let List of file service discovery configurations. ''; + gce_sd_configs = mkOpt (types.listOf promTypes.gce_sd_config) '' + List of Google Compute Engine service discovery configurations. + + See the + relevant Prometheus configuration docs for more detail. + ''; + static_configs = mkOpt (types.listOf promTypes.static_config) '' List of labeled target groups for this job. ''; @@ -555,6 +563,48 @@ let }; }; + promTypes.gce_sd_config = types.submodule { + options = { + # Use `mkOption` instead of `mkOpt` for project and zone because they are + # required configuration values for `gce_sd_config`. + project = mkOption { + type = types.str; + description = '' + The GCP Project. + ''; + }; + + zone = mkOption { + type = types.str; + description = '' + The zone of the scrape targets. If you need multiple zones use multiple + gce_sd_configs. + ''; + }; + + filter = mkOpt types.str '' + Filter can be used optionally to filter the instance list by other + criteria Syntax of this filter string is described here in the filter + query parameter section: . + ''; + + refresh_interval = mkDefOpt types.str "60s" '' + Refresh interval to re-read the instance list. + ''; + + port = mkDefOpt types.int "80" '' + The port to scrape metrics from. If using the public IP address, this + must instead be specified in the relabeling rule. + ''; + + tag_separator = mkDefOpt types.str "," '' + The tag separator is used to separate the tags on concatenation. + ''; + }; + }; + promTypes.relabel_config = types.submodule { options = { source_labels = mkOpt (types.listOf types.str) '' From cad83fc5964ef4fad78cc03a9c61588d1efcd11b Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Sun, 10 Jan 2021 13:08:07 -0500 Subject: [PATCH 2/5] nixos/prometheus: add cloud to refresh_interval description --- nixos/modules/services/monitoring/prometheus/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix index b2df0f5b79a30c..367250e28133ae 100644 --- a/nixos/modules/services/monitoring/prometheus/default.nix +++ b/nixos/modules/services/monitoring/prometheus/default.nix @@ -591,7 +591,7 @@ let ''; refresh_interval = mkDefOpt types.str "60s" '' - Refresh interval to re-read the instance list. + Refresh interval to re-read the cloud instance list. ''; port = mkDefOpt types.int "80" '' From de96ffeb1c264a15635d0bdf4c6120aaa6296c7d Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Sun, 10 Jan 2021 13:08:22 -0500 Subject: [PATCH 3/5] nixos/prometheus: use types.port for metrics port type --- nixos/modules/services/monitoring/prometheus/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix index 367250e28133ae..d46cacec0a7008 100644 --- a/nixos/modules/services/monitoring/prometheus/default.nix +++ b/nixos/modules/services/monitoring/prometheus/default.nix @@ -594,7 +594,7 @@ let Refresh interval to re-read the cloud instance list. ''; - port = mkDefOpt types.int "80" '' + port = mkDefOpt types.port "80" '' The port to scrape metrics from. If using the public IP address, this must instead be specified in the relabeling rule. ''; From 53796fd70f49d7f80194c866d49846468dd48332 Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Sun, 10 Jan 2021 13:08:42 -0500 Subject: [PATCH 4/5] nixos/prometheus: improve the tag_separator description --- nixos/modules/services/monitoring/prometheus/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix index d46cacec0a7008..dc8347fbc97004 100644 --- a/nixos/modules/services/monitoring/prometheus/default.nix +++ b/nixos/modules/services/monitoring/prometheus/default.nix @@ -600,7 +600,11 @@ let ''; tag_separator = mkDefOpt types.str "," '' - The tag separator is used to separate the tags on concatenation. + The tag separator used to separate concatenated GCE instance network tags. + + See the GCP documentation on network tags for more information: ''; }; }; From cbe4de90affd773071d5a517d2a23aea6b7c1810 Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Sun, 10 Jan 2021 13:09:47 -0500 Subject: [PATCH 5/5] nixos/prometheus: remove unnecessary whitespace --- nixos/modules/services/monitoring/prometheus/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix index dc8347fbc97004..9103a6f932dbbe 100644 --- a/nixos/modules/services/monitoring/prometheus/default.nix +++ b/nixos/modules/services/monitoring/prometheus/default.nix @@ -568,7 +568,7 @@ let # Use `mkOption` instead of `mkOpt` for project and zone because they are # required configuration values for `gce_sd_config`. project = mkOption { - type = types.str; + type = types.str; description = '' The GCP Project. '';