summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/prometheus/default.nix
diff options
context:
space:
mode:
authorPhillip Cloud <cloud@standard.ai>2020-12-29 13:15:51 -0500
committerPhillip Cloud <cloud@standard.ai>2021-01-10 13:08:47 -0500
commit7958dbb8a703c14f095376b2fedb822fb4276bbe (patch)
tree89c74018cc143f596d721e1bef2f8d9eae386233 /nixos/modules/services/monitoring/prometheus/default.nix
parentfe0ee326e0537c1cc3368fc05884f4918da5c8cd (diff)
downloadnixpkgs-7958dbb8a703c14f095376b2fedb822fb4276bbe.tar
nixpkgs-7958dbb8a703c14f095376b2fedb822fb4276bbe.tar.gz
nixpkgs-7958dbb8a703c14f095376b2fedb822fb4276bbe.tar.bz2
nixpkgs-7958dbb8a703c14f095376b2fedb822fb4276bbe.tar.lz
nixpkgs-7958dbb8a703c14f095376b2fedb822fb4276bbe.tar.xz
nixpkgs-7958dbb8a703c14f095376b2fedb822fb4276bbe.tar.zst
nixpkgs-7958dbb8a703c14f095376b2fedb822fb4276bbe.zip
nixos/prometheus: add gce_sd_configs scrapeConfig option
Diffstat (limited to 'nixos/modules/services/monitoring/prometheus/default.nix')
-rw-r--r--nixos/modules/services/monitoring/prometheus/default.nix50
1 files changed, 50 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/default.nix b/nixos/modules/services/monitoring/prometheus/default.nix
index 4f9be38f7f1..b2df0f5b79a 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 <link
+        xlink:href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#gce_sd_config">the
+        relevant Prometheus configuration docs</link> 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: <link
+        xlink:href="https://cloud.google.com/compute/docs/reference/latest/instances/list"
+        />.
+      '';
+
+      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) ''