···3737 pkgs.runCommandLocal
3838 "${name}-${replaceStrings [" "] [""] what}-checked"
3939 { buildInputs = [ cfg.package ]; } ''
4040- ln -s ${file} $out
4141- promtool ${what} $out
4242- '' else file;
4040+ ln -s ${file} $out
4141+ promtool ${what} $out
4242+ '' else file;
43434444 # Pretty-print JSON to a file
4545 writePrettyJSON = name: x:
4646- pkgs.runCommandLocal name {} ''
4646+ pkgs.runCommandLocal name { } ''
4747 echo '${builtins.toJSON x}' | ${pkgs.jq}/bin/jq . > $out
4848 '';
4949···6363 };
6464 };
65656666- prometheusYml = let
6767- yml = if cfg.configText != null then
6868- pkgs.writeText "prometheus.yml" cfg.configText
6969- else generatedPrometheusYml;
7070- in promtoolCheck "check config" "prometheus.yml" yml;
6666+ prometheusYml =
6767+ let
6868+ yml =
6969+ if cfg.configText != null then
7070+ pkgs.writeText "prometheus.yml" cfg.configText
7171+ else generatedPrometheusYml;
7272+ in
7373+ promtoolCheck "check config" "prometheus.yml" yml;
71747275 cmdlineArgs = cfg.extraFlags ++ [
7376 "--storage.tsdb.path=${workingDir}/data/"
···8083 "--alertmanager.notification-queue-capacity=${toString cfg.alertmanagerNotificationQueueCapacity}"
8184 "--alertmanager.timeout=${toString cfg.alertmanagerTimeout}s"
8285 ] ++ optional (cfg.webExternalUrl != null) "--web.external-url=${cfg.webExternalUrl}"
8383- ++ optional (cfg.retentionTime != null) "--storage.tsdb.retention.time=${cfg.retentionTime}";
8686+ ++ optional (cfg.retentionTime != null) "--storage.tsdb.retention.time=${cfg.retentionTime}";
84878588 filterValidPrometheus = filterAttrsListRecursive (n: v: !(n == "_module" || v == null));
8689 filterAttrsListRecursive = pred: x:
8790 if isAttrs x then
8888- listToAttrs (
8989- concatMap (name:
9090- let v = x.${name}; in
9191- if pred name v then [
9292- (nameValuePair name (filterAttrsListRecursive pred v))
9393- ] else []
9494- ) (attrNames x)
9595- )
9191+ listToAttrs
9292+ (
9393+ concatMap
9494+ (name:
9595+ let v = x.${name}; in
9696+ if pred name v then [
9797+ (nameValuePair name (filterAttrsListRecursive pred v))
9898+ ] else [ ]
9999+ )
100100+ (attrNames x)
101101+ )
96102 else if isList x then
97103 map (filterAttrsListRecursive pred) x
98104 else x;
99105100100- mkDefOpt = type : defaultStr : description : mkOpt type (description + ''
106106+ #
107107+ # Config types: helper functions
108108+ #
109109+110110+ mkDefOpt = type: defaultStr: description: mkOpt type (description + ''
101111102112 Defaults to <literal>${defaultStr}</literal> in prometheus
103113 when set to <literal>null</literal>.
104114 '');
105115106106- mkOpt = type : description : mkOption {
116116+ mkOpt = type: description: mkOption {
107117 type = types.nullOr type;
108118 default = null;
109119 inherit description;
110120 };
111121122122+ mkSdConfigModule = extraOptions: types.submodule {
123123+ options = {
124124+ basic_auth = mkOpt promTypes.basic_auth ''
125125+ Optional HTTP basic authentication information.
126126+ '';
127127+128128+ authorization = mkOpt
129129+ (types.submodule {
130130+ options = {
131131+ type = mkDefOpt types.str "Bearer" ''
132132+ Sets the authentication type.
133133+ '';
134134+135135+ credentials = mkOpt types.str ''
136136+ Sets the credentials. It is mutually exclusive with `credentials_file`.
137137+ '';
138138+139139+ credentials_file = mkOpt types.str ''
140140+ Sets the credentials to the credentials read from the configured file.
141141+ It is mutually exclusive with `credentials`.
142142+ '';
143143+ };
144144+ }) ''
145145+ Optional `Authorization` header configuration.
146146+ '';
147147+148148+ oauth2 = mkOpt promtypes.oauth2 ''
149149+ Optional OAuth 2.0 configuration.
150150+ Cannot be used at the same time as basic_auth or authorization.
151151+ '';
152152+153153+ proxy_url = mkOpt types.str ''
154154+ Optional proxy URL.
155155+ '';
156156+157157+ follow_redirects = mkDefOpt types.bool "true" ''
158158+ Configure whether HTTP requests follow HTTP 3xx redirects.
159159+ '';
160160+161161+ tls_config = mkOpt promTypes.tls_config ''
162162+ TLS configuration.
163163+ '';
164164+ } // extraOptions;
165165+ };
166166+167167+ #
168168+ # Config types: general
169169+ #
170170+112171 promTypes.globalConfig = types.submodule {
113172 options = {
114173 scrape_interval = mkDefOpt types.str "1m" ''
···131190 };
132191 };
133192134134- promTypes.remote_read = types.submodule {
193193+ promTypes.basic_auth = types.submodule {
135194 options = {
136136- url = mkOption {
195195+ username = mkOption {
137196 type = types.str;
138197 description = ''
139139- ServerName extension to indicate the name of the server.
140140- http://tools.ietf.org/html/rfc4366#section-3.1
198198+ HTTP username
141199 '';
142200 };
143143- name = mkOpt types.str ''
144144- Name of the remote read config, which if specified must be unique among remote read configs.
145145- The name will be used in metrics and logging in place of a generated value to help users distinguish between
146146- remote read configs.
201201+ password = mkOpt types.str "HTTP password";
202202+ password_file = mkOpt types.str "HTTP password file";
203203+ };
204204+ };
205205+206206+ promTypes.tls_config = types.submodule {
207207+ options = {
208208+ ca_file = mkOpt types.str ''
209209+ CA certificate to validate API server certificate with.
147210 '';
148148- required_matchers = mkOpt (types.attrsOf types.str) ''
149149- An optional list of equality matchers which have to be
150150- present in a selector to query the remote read endpoint.
211211+212212+ cert_file = mkOpt types.str ''
213213+ Certificate file for client cert authentication to the server.
151214 '';
152152- remote_timeout = mkOpt types.str ''
153153- Timeout for requests to the remote read endpoint.
215215+216216+ key_file = mkOpt types.str ''
217217+ Key file for client cert authentication to the server.
154218 '';
155155- read_recent = mkOpt types.bool ''
156156- Whether reads should be made for queries for time ranges that
157157- the local storage should have complete data for.
219219+220220+ server_name = mkOpt types.str ''
221221+ ServerName extension to indicate the name of the server.
222222+ http://tools.ietf.org/html/rfc4366#section-3.1
158223 '';
159159- basic_auth = mkOpt (types.submodule {
160160- options = {
161161- username = mkOption {
162162- type = types.str;
163163- description = ''
164164- HTTP username
165165- '';
166166- };
167167- password = mkOpt types.str "HTTP password";
168168- password_file = mkOpt types.str "HTTP password file";
169169- };
170170- }) ''
171171- Sets the `Authorization` header on every remote read request with the
172172- configured username and password.
173173- password and password_file are mutually exclusive.
174174- '';
175175- bearer_token = mkOpt types.str ''
176176- Sets the `Authorization` header on every remote read request with
177177- the configured bearer token. It is mutually exclusive with `bearer_token_file`.
224224+225225+ insecure_skip_verify = mkOpt types.bool ''
226226+ Disable validation of the server certificate.
178227 '';
179179- bearer_token_file = mkOpt types.str ''
180180- Sets the `Authorization` header on every remote read request with the bearer token
181181- read from the configured file. It is mutually exclusive with `bearer_token`.
182182- '';
183183- tls_config = mkOpt promTypes.tls_config ''
184184- Configures the remote read request's TLS settings.
185185- '';
186186- proxy_url = mkOpt types.str "Optional Proxy URL.";
187228 };
188229 };
189230190190- promTypes.remote_write = types.submodule {
231231+ promtypes.oauth2 = types.submodule {
191232 options = {
192192- url = mkOption {
193193- type = types.str;
194194- description = ''
195195- ServerName extension to indicate the name of the server.
196196- http://tools.ietf.org/html/rfc4366#section-3.1
197197- '';
198198- };
199199- remote_timeout = mkOpt types.str ''
200200- Timeout for requests to the remote write endpoint.
233233+ client_id = mkOpt types.str ''
234234+ OAuth client ID.
201235 '';
202202- write_relabel_configs = mkOpt (types.listOf promTypes.relabel_config) ''
203203- List of remote write relabel configurations.
236236+237237+ client_secret = mkOpt types.str ''
238238+ OAuth client secret.
204239 '';
205205- name = mkOpt types.str ''
206206- Name of the remote write config, which if specified must be unique among remote write configs.
207207- The name will be used in metrics and logging in place of a generated value to help users distinguish between
208208- remote write configs.
240240+241241+ client_secret_file = mkOpt types.str ''
242242+ Read the client secret from a file. It is mutually exclusive with `client_secret`.
209243 '';
210210- basic_auth = mkOpt (types.submodule {
211211- options = {
212212- username = mkOption {
213213- type = types.str;
214214- description = ''
215215- HTTP username
216216- '';
217217- };
218218- password = mkOpt types.str "HTTP password";
219219- password_file = mkOpt types.str "HTTP password file";
220220- };
221221- }) ''
222222- Sets the `Authorization` header on every remote write request with the
223223- configured username and password.
224224- password and password_file are mutually exclusive.
244244+245245+ scopes = mkOpt (types.listOf types.str) ''
246246+ Scopes for the token request.
225247 '';
226226- bearer_token = mkOpt types.str ''
227227- Sets the `Authorization` header on every remote write request with
228228- the configured bearer token. It is mutually exclusive with `bearer_token_file`.
248248+249249+ token_url = mkOpt types.str ''
250250+ The URL to fetch the token from.
229251 '';
230230- bearer_token_file = mkOpt types.str ''
231231- Sets the `Authorization` header on every remote write request with the bearer token
232232- read from the configured file. It is mutually exclusive with `bearer_token`.
233233- '';
234234- tls_config = mkOpt promTypes.tls_config ''
235235- Configures the remote write request's TLS settings.
236236- '';
237237- proxy_url = mkOpt types.str "Optional Proxy URL.";
238238- queue_config = mkOpt (types.submodule {
239239- options = {
240240- capacity = mkOpt types.int ''
241241- Number of samples to buffer per shard before we block reading of more
242242- samples from the WAL. It is recommended to have enough capacity in each
243243- shard to buffer several requests to keep throughput up while processing
244244- occasional slow remote requests.
245245- '';
246246- max_shards = mkOpt types.int ''
247247- Maximum number of shards, i.e. amount of concurrency.
248248- '';
249249- min_shards = mkOpt types.int ''
250250- Minimum number of shards, i.e. amount of concurrency.
251251- '';
252252- max_samples_per_send = mkOpt types.int ''
253253- Maximum number of samples per send.
254254- '';
255255- batch_send_deadline = mkOpt types.str ''
256256- Maximum time a sample will wait in buffer.
257257- '';
258258- min_backoff = mkOpt types.str ''
259259- Initial retry delay. Gets doubled for every retry.
260260- '';
261261- max_backoff = mkOpt types.str ''
262262- Maximum retry delay.
263263- '';
264264- };
265265- }) ''
266266- Configures the queue used to write to remote storage.
267267- '';
268268- metadata_config = mkOpt (types.submodule {
269269- options = {
270270- send = mkOpt types.bool ''
271271- Whether metric metadata is sent to remote storage or not.
272272- '';
273273- send_interval = mkOpt types.str ''
274274- How frequently metric metadata is sent to remote storage.
275275- '';
276276- };
277277- }) ''
278278- Configures the sending of series metadata to remote storage.
279279- Metadata configuration is subject to change at any point
280280- or be removed in future releases.
252252+253253+ endpoint_params = mkOpt (types.attrsOf types.str) ''
254254+ Optional parameters to append to the token URL.
281255 '';
282256 };
283257 };
···335309 by the target will be ignored.
336310 '';
337311338338- scheme = mkDefOpt (types.enum ["http" "https"]) "http" ''
312312+ scheme = mkDefOpt (types.enum [ "http" "https" ]) "http" ''
339313 The URL scheme with which to fetch metrics from targets.
340314 '';
341315···343317 Optional HTTP URL parameters.
344318 '';
345319346346- basic_auth = mkOpt (types.submodule {
347347- options = {
348348- username = mkOption {
349349- type = types.str;
350350- description = ''
351351- HTTP username
352352- '';
353353- };
354354- password = mkOpt types.str "HTTP password";
355355- password_file = mkOpt types.str "HTTP password file";
356356- };
357357- }) ''
320320+ basic_auth = mkOpt promTypes.basic_auth ''
358321 Sets the `Authorization` header on every scrape request with the
359322 configured username and password.
360323 password and password_file are mutually exclusive.
···380343 Optional proxy URL.
381344 '';
382345383383- ec2_sd_configs = mkOpt (types.listOf promTypes.ec2_sd_config) ''
384384- List of EC2 service discovery configurations.
346346+ azure_sd_configs = mkOpt (types.listOf promTypes.azure_sd_config) ''
347347+ List of Azure service discovery configurations.
348348+ '';
349349+350350+ consul_sd_configs = mkOpt (types.listOf promTypes.consul_sd_config) ''
351351+ List of Consul service discovery configurations.
352352+ '';
353353+354354+ digitalocean_sd_configs = mkOpt (types.listOf promTypes.digitalocean_sd_config) ''
355355+ List of DigitalOcean service discovery configurations.
356356+ '';
357357+358358+ docker_sd_configs = mkOpt (types.listOf promTypes.docker_sd_config) ''
359359+ List of Docker service discovery configurations.
360360+ '';
361361+362362+ dockerswarm_sd_configs = mkOpt (types.listOf promTypes.dockerswarm_sd_config) ''
363363+ List of Docker Swarm service discovery configurations.
385364 '';
386365387366 dns_sd_configs = mkOpt (types.listOf promTypes.dns_sd_config) ''
388367 List of DNS service discovery configurations.
389368 '';
390369391391- consul_sd_configs = mkOpt (types.listOf promTypes.consul_sd_config) ''
392392- List of Consul service discovery configurations.
370370+ ec2_sd_configs = mkOpt (types.listOf promTypes.ec2_sd_config) ''
371371+ List of EC2 service discovery configurations.
372372+ '';
373373+374374+ eureka_sd_configs = mkOpt (types.listOf promTypes.eureka_sd_config) ''
375375+ List of Eureka service discovery configurations.
393376 '';
394377395378 file_sd_configs = mkOpt (types.listOf promTypes.file_sd_config) ''
···404387 relevant Prometheus configuration docs</link> for more detail.
405388 '';
406389390390+ hetzner_sd_configs = mkOpt (types.listOf promTypes.hetzner_sd_config) ''
391391+ List of Hetzner service discovery configurations.
392392+ '';
393393+394394+ http_sd_configs = mkOpt (types.listOf promTypes.http_sd_config) ''
395395+ List of HTTP service discovery configurations.
396396+ '';
397397+398398+ kubernetes_sd_configs = mkOpt (types.listOf promTypes.kubernetes_sd_config) ''
399399+ List of Kubernetes service discovery configurations.
400400+ '';
401401+402402+ kuma_sd_configs = mkOpt (types.listOf promTypes.kuma_sd_config) ''
403403+ List of Kuma service discovery configurations.
404404+ '';
405405+406406+ lightsail_sd_configs = mkOpt (types.listOf promTypes.lightsail_sd_config) ''
407407+ List of Lightsail service discovery configurations.
408408+ '';
409409+410410+ linode_sd_configs = mkOpt (types.listOf promTypes.linode_sd_config) ''
411411+ List of Linode service discovery configurations.
412412+ '';
413413+414414+ marathon_sd_configs = mkOpt (types.listOf promTypes.marathon_sd_config) ''
415415+ List of Marathon service discovery configurations.
416416+ '';
417417+418418+ nerve_sd_configs = mkOpt (types.listOf promTypes.nerve_sd_config) ''
419419+ List of AirBnB's Nerve service discovery configurations.
420420+ '';
421421+422422+ openstack_sd_configs = mkOpt (types.listOf promTypes.openstack_sd_config) ''
423423+ List of OpenStack service discovery configurations.
424424+ '';
425425+426426+ puppetdb_sd_configs = mkOpt (types.listOf promTypes.puppetdb_sd_config) ''
427427+ List of PuppetDB service discovery configurations.
428428+ '';
429429+430430+ scaleway_sd_configs = mkOpt (types.listOf promTypes.scaleway_sd_config) ''
431431+ List of Scaleway service discovery configurations.
432432+ '';
433433+434434+ serverset_sd_configs = mkOpt (types.listOf promTypes.serverset_sd_config) ''
435435+ List of Zookeeper Serverset service discovery configurations.
436436+ '';
437437+438438+ triton_sd_configs = mkOpt (types.listOf promTypes.triton_sd_config) ''
439439+ List of Triton Serverset service discovery configurations.
440440+ '';
441441+442442+ uyuni_sd_configs = mkOpt (types.listOf promTypes.uyuni_sd_config) ''
443443+ List of Uyuni Serverset service discovery configurations.
444444+ '';
445445+407446 static_configs = mkOpt (types.listOf promTypes.static_config) ''
408447 List of labeled target groups for this job.
409448 '';
···416455 List of metric relabel configurations.
417456 '';
418457458458+ body_size_limit = mkDefOpt types.str "0" ''
459459+ An uncompressed response body larger than this many bytes will cause the
460460+ scrape to fail. 0 means no limit. Example: 100MB.
461461+ This is an experimental feature, this behaviour could
462462+ change or be removed in the future.
463463+ '';
464464+419465 sample_limit = mkDefOpt types.int "0" ''
420466 Per-scrape limit on number of scraped samples that will be accepted.
421467 If more than this number of samples are present after metric relabelling
422468 the entire scrape will be treated as failed. 0 means no limit.
423469 '';
470470+471471+ label_limit = mkDefOpt types.int "0" ''
472472+ Per-scrape limit on number of labels that will be accepted for a sample. If
473473+ more than this number of labels are present post metric-relabeling, the
474474+ entire scrape will be treated as failed. 0 means no limit.
475475+ '';
476476+477477+ label_name_length_limit = mkDefOpt types.int "0" ''
478478+ Per-scrape limit on length of labels name that will be accepted for a sample.
479479+ If a label name is longer than this number post metric-relabeling, the entire
480480+ scrape will be treated as failed. 0 means no limit.
481481+ '';
482482+483483+ label_value_length_limit = mkDefOpt types.int "0" ''
484484+ Per-scrape limit on length of labels value that will be accepted for a sample.
485485+ If a label value is longer than this number post metric-relabeling, the
486486+ entire scrape will be treated as failed. 0 means no limit.
487487+ '';
488488+489489+ target_limit = mkDefOpt types.int "0" ''
490490+ Per-scrape config limit on number of unique targets that will be
491491+ accepted. If more than this number of targets are present after target
492492+ relabeling, Prometheus will mark the targets as failed without scraping them.
493493+ 0 means no limit. This is an experimental feature, this behaviour could
494494+ change in the future.
495495+ '';
424496 };
425497 };
426498427427- promTypes.static_config = types.submodule {
499499+ #
500500+ # Config types: service discovery
501501+ #
502502+503503+ # For this one, the docs actually define all types needed to use mkSdConfigModule, but a bunch
504504+ # of them are marked with 'currently not support by Azure' so we don't bother adding them in
505505+ # here.
506506+ promTypes.azure_sd_config = types.submodule {
428507 options = {
429429- targets = mkOption {
430430- type = types.listOf types.str;
508508+ environment = mkDefOpt types.str "AzurePublicCloud" ''
509509+ The Azure environment.
510510+ '';
511511+512512+ authentication_method = mkDefOpt (types.enum [ "OAuth" "ManagedIdentity" ]) "OAuth" ''
513513+ The authentication method, either OAuth or ManagedIdentity.
514514+ See https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
515515+ '';
516516+517517+ subscription_id = mkOption {
518518+ type = types.str;
431519 description = ''
432432- The targets specified by the target group.
520520+ The subscription ID.
433521 '';
434522 };
435435- labels = mkOption {
436436- type = types.attrsOf types.str;
437437- default = {};
523523+524524+ tenant_id = mkOpt types.str ''
525525+ Optional tenant ID. Only required with authentication_method OAuth.
526526+ '';
527527+528528+ client_id = mkOpt types.str ''
529529+ Optional client ID. Only required with authentication_method OAuth.
530530+ '';
531531+532532+ client_secret = mkOpt types.str ''
533533+ Optional client secret. Only required with authentication_method OAuth.
534534+ '';
535535+536536+ refresh_interval = mkDefOpt types.str "300s" ''
537537+ Refresh interval to re-read the instance list.
538538+ '';
539539+540540+ port = mkDefOpt types.int "80" ''
541541+ The port to scrape metrics from. If using the public IP
542542+ address, this must instead be specified in the relabeling
543543+ rule.
544544+ '';
545545+546546+ proxy_url = mkOpt types.str ''
547547+ Optional proxy URL.
548548+ '';
549549+550550+ follow_redirects = mkDefOpt types.bool "true" ''
551551+ Configure whether HTTP requests follow HTTP 3xx redirects.
552552+ '';
553553+554554+ tls_config = mkOpt promTypes.tls_config ''
555555+ TLS configuration.
556556+ '';
557557+ };
558558+ };
559559+560560+ promTypes.consul_sd_config = mkSdConfigModule {
561561+ server = mkDefOpt types.str "localhost:8500" ''
562562+ Consul server to query.
563563+ '';
564564+565565+ token = mkOpt types.str "Consul token";
566566+567567+ datacenter = mkOpt types.str "Consul datacenter";
568568+569569+ scheme = mkDefOpt types.str "http" "Consul scheme";
570570+571571+ username = mkOpt types.str "Consul username";
572572+573573+ password = mkOpt types.str "Consul password";
574574+575575+ tls_config = mkOpt promTypes.tls_config ''
576576+ Configures the Consul request's TLS settings.
577577+ '';
578578+579579+ services = mkOpt (types.listOf types.str) ''
580580+ A list of services for which targets are retrieved.
581581+ '';
582582+583583+ tags = mkOpt (types.listOf types.str) ''
584584+ An optional list of tags used to filter nodes for a given
585585+ service. Services must contain all tags in the list.
586586+ '';
587587+588588+ node_meta = mkOpt (types.attrsOf types.str) ''
589589+ Node metadata used to filter nodes for a given service.
590590+ '';
591591+592592+ tag_separator = mkDefOpt types.str "," ''
593593+ The string by which Consul tags are joined into the tag label.
594594+ '';
595595+596596+ allow_stale = mkOpt types.bool ''
597597+ Allow stale Consul results
598598+ (see <link xlink:href="https://www.consul.io/api/index.html#consistency-modes"/>).
599599+600600+ Will reduce load on Consul.
601601+ '';
602602+603603+ refresh_interval = mkDefOpt types.str "30s" ''
604604+ The time after which the provided names are refreshed.
605605+606606+ On large setup it might be a good idea to increase this value
607607+ because the catalog will change all the time.
608608+ '';
609609+ };
610610+611611+ promTypes.digitalocean_sd_config = mkSdConfigModule {
612612+ port = mkDefOpt types.int "80" ''
613613+ The port to scrape metrics from.
614614+ '';
615615+616616+ refresh_interval = mkDefOpt types.str "60s" ''
617617+ The time after which the droplets are refreshed.
618618+ '';
619619+ };
620620+621621+ mkDockerSdConfigModule = extraOptions: mkSdConfigModule ({
622622+ host = mkOption {
623623+ type = types.str;
624624+ description = ''
625625+ Address of the Docker daemon.
626626+ '';
627627+ };
628628+629629+ port = mkDefOpt types.int "80" ''
630630+ The port to scrape metrics from, when `role` is nodes, and for discovered
631631+ tasks and services that don't have published ports.
632632+ '';
633633+634634+ filters = mkOpt
635635+ (types.listOf (types.submodule {
636636+ options = {
637637+ name = mkOption {
638638+ type = types.str;
639639+ description = ''
640640+ Name of the filter. The available filters are listed in the upstream documentation:
641641+ Services: <link xlink:href="https://docs.docker.com/engine/api/v1.40/#operation/ServiceList"/>
642642+ Tasks: <link xlink:href="https://docs.docker.com/engine/api/v1.40/#operation/TaskList"/>
643643+ Nodes: <link xlink:href="https://docs.docker.com/engine/api/v1.40/#operation/NodeList"/>
644644+ '';
645645+ };
646646+ values = mkOption {
647647+ type = types.str;
648648+ description = ''
649649+ Value for the filter.
650650+ '';
651651+ };
652652+ };
653653+ })) ''
654654+ Optional filters to limit the discovery process to a subset of available resources.
655655+ '';
656656+657657+ refresh_interval = mkDefOpt types.str "60s" ''
658658+ The time after which the containers are refreshed.
659659+ '';
660660+ } // extraOptions);
661661+662662+ promTypes.docker_sd_config = mkDockerSdConfigModule {
663663+ host_networking_host = mkDefOpt types.str "localhost" ''
664664+ The host to use if the container is in host networking mode.
665665+ '';
666666+ };
667667+668668+ promTypes.dockerswarm_sd_config = mkDockerSdConfigModule {
669669+ role = mkOption {
670670+ type = types.enum [ "services" "tasks" "nodes" ];
671671+ description = ''
672672+ Role of the targets to retrieve. Must be `services`, `tasks`, or `nodes`.
673673+ '';
674674+ };
675675+ };
676676+677677+ promTypes.dns_sd_config = types.submodule {
678678+ options = {
679679+ names = mkOption {
680680+ type = types.listOf types.str;
438681 description = ''
439439- Labels assigned to all metrics scraped from the targets.
682682+ A list of DNS SRV record names to be queried.
440683 '';
441684 };
685685+686686+ type = mkDefOpt (types.enum [ "SRV" "A" "AAAA" ]) "SRV" ''
687687+ The type of DNS query to perform. One of SRV, A, or AAAA.
688688+ '';
689689+690690+ port = mkOpt types.int ''
691691+ The port number used if the query type is not SRV.
692692+ '';
693693+694694+ refresh_interval = mkDefOpt types.str "30s" ''
695695+ The time after which the provided names are refreshed.
696696+ '';
442697 };
443698 };
444699···447702 region = mkOption {
448703 type = types.str;
449704 description = ''
450450- The AWS Region.
705705+ The AWS Region. If blank, the region from the instance metadata is used.
451706 '';
452707 };
453708 endpoint = mkOpt types.str ''
···464719 <literal>AWS_SECRET_ACCESS_KEY</literal> is used.
465720 '';
466721467467- profile = mkOpt types.str ''
722722+ profile = mkOpt types.str ''
468723 Named AWS profile used to connect to the API.
469724 '';
470725···482737 rule.
483738 '';
484739485485- filters = mkOpt (types.listOf promTypes.filter) ''
740740+ filters = mkOpt
741741+ (types.listOf (types.submodule {
742742+ options = {
743743+ name = mkOption {
744744+ type = types.str;
745745+ description = ''
746746+ See <link xlink:href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html">this list</link>
747747+ for the available filters.
748748+ '';
749749+ };
750750+751751+ values = mkOption {
752752+ type = types.listOf types.str;
753753+ default = [ ];
754754+ description = ''
755755+ Value of the filter.
756756+ '';
757757+ };
758758+ };
759759+ })) ''
486760 Filters can be used optionally to filter the instance list by other criteria.
487761 '';
488762 };
489763 };
490764491491- promTypes.filter = types.submodule {
765765+ promTypes.eureka_sd_config = mkSdConfigModule {
766766+ server = mkOption {
767767+ type = types.str;
768768+ description = ''
769769+ The URL to connect to the Eureka server.
770770+ '';
771771+ };
772772+ };
773773+774774+ promTypes.file_sd_config = types.submodule {
492775 options = {
493493- name = mkOption {
776776+ files = mkOption {
777777+ type = types.listOf types.str;
778778+ description = ''
779779+ Patterns for files from which target groups are extracted. Refer
780780+ to the Prometheus documentation for permitted filename patterns
781781+ and formats.
782782+ '';
783783+ };
784784+785785+ refresh_interval = mkDefOpt types.str "5m" ''
786786+ Refresh interval to re-read the files.
787787+ '';
788788+ };
789789+ };
790790+791791+ promTypes.gce_sd_config = types.submodule {
792792+ options = {
793793+ # Use `mkOption` instead of `mkOpt` for project and zone because they are
794794+ # required configuration values for `gce_sd_config`.
795795+ project = mkOption {
494796 type = types.str;
495797 description = ''
496496- See <link xlink:href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html">this list</link>
497497- for the available filters.
798798+ The GCP Project.
498799 '';
499800 };
500801501501- values = mkOption {
502502- type = types.listOf types.str;
503503- default = [];
802802+ zone = mkOption {
803803+ type = types.str;
504804 description = ''
505505- Value of the filter.
805805+ The zone of the scrape targets. If you need multiple zones use multiple
806806+ gce_sd_configs.
506807 '';
507808 };
809809+810810+ filter = mkOpt types.str ''
811811+ Filter can be used optionally to filter the instance list by other
812812+ criteria Syntax of this filter string is described here in the filter
813813+ query parameter section: <link
814814+ xlink:href="https://cloud.google.com/compute/docs/reference/latest/instances/list"
815815+ />.
816816+ '';
817817+818818+ refresh_interval = mkDefOpt types.str "60s" ''
819819+ Refresh interval to re-read the cloud instance list.
820820+ '';
821821+822822+ port = mkDefOpt types.port "80" ''
823823+ The port to scrape metrics from. If using the public IP address, this
824824+ must instead be specified in the relabeling rule.
825825+ '';
826826+827827+ tag_separator = mkDefOpt types.str "," ''
828828+ The tag separator used to separate concatenated GCE instance network tags.
829829+830830+ See the GCP documentation on network tags for more information:
831831+ <link xlink:href="https://cloud.google.com/vpc/docs/add-remove-network-tags" />
832832+ '';
508833 };
509834 };
510835511511- promTypes.dns_sd_config = types.submodule {
836836+ promTypes.hetzner_sd_config = mkSdConfigModule {
837837+ role = mkOption {
838838+ type = types.enum [ "robot" "hcloud" ];
839839+ description = ''
840840+ The Hetzner role of entities that should be discovered.
841841+ One of <literal>robot</literal> or <literal>hcloud</literal>.
842842+ '';
843843+ };
844844+845845+ port = mkDefOpt types.int "80" ''
846846+ The port to scrape metrics from.
847847+ '';
848848+849849+ refresh_interval = mkDefOpt types.str "60s" ''
850850+ The time after which the servers are refreshed.
851851+ '';
852852+ };
853853+854854+ promTypes.http_sd_config = types.submodule {
512855 options = {
513513- names = mkOption {
514514- type = types.listOf types.str;
856856+ url = mkOption {
857857+ type = types.str;
515858 description = ''
516516- A list of DNS SRV record names to be queried.
859859+ URL from which the targets are fetched.
517860 '';
518861 };
519862520520- refresh_interval = mkDefOpt types.str "30s" ''
521521- The time after which the provided names are refreshed.
863863+ refresh_interval = mkDefOpt types.str "60s" ''
864864+ Refresh interval to re-query the endpoint.
865865+ '';
866866+867867+ basic_auth = mkOpt promTypes.basic_auth ''
868868+ Authentication information used to authenticate to the API server.
869869+ password and password_file are mutually exclusive.
870870+ '';
871871+872872+ proxy_url = mkOpt types.str ''
873873+ Optional proxy URL.
874874+ '';
875875+876876+ follow_redirects = mkDefOpt types.bool "true" ''
877877+ Configure whether HTTP requests follow HTTP 3xx redirects.
878878+ '';
879879+880880+ tls_config = mkOpt promTypes.tls_config ''
881881+ Configures the scrape request's TLS settings.
522882 '';
523883 };
524884 };
525885526526- promTypes.consul_sd_config = types.submodule {
527527- options = {
528528- server = mkDefOpt types.str "localhost:8500" ''
529529- Consul server to query.
886886+ promTypes.kubernetes_sd_config = mkSdConfigModule {
887887+ api_server = mkOpt types.str ''
888888+ The API server addresses. If left empty, Prometheus is assumed to run inside
889889+ of the cluster and will discover API servers automatically and use the pod's
890890+ CA certificate and bearer token file at /var/run/secrets/kubernetes.io/serviceaccount/.
891891+ '';
892892+893893+ role = mkOption {
894894+ type = types.enum [ "endpoints" "service" "pod" "node" "ingress" ];
895895+ description = ''
896896+ The Kubernetes role of entities that should be discovered.
897897+ One of endpoints, service, pod, node, or ingress.
530898 '';
899899+ };
531900532532- token = mkOpt types.str "Consul token";
901901+ kubeconfig_file = mkOpt types.str ''
902902+ Optional path to a kubeconfig file.
903903+ Note that api_server and kube_config are mutually exclusive.
904904+ '';
533905534534- datacenter = mkOpt types.str "Consul datacenter";
906906+ namespaces = mkOpt
907907+ (
908908+ types.submodule {
909909+ options = {
910910+ names = mkOpt (types.listOf types.str) ''
911911+ Namespace name.
912912+ '';
913913+ };
914914+ }
915915+ ) ''
916916+ Optional namespace discovery. If omitted, all namespaces are used.
917917+ '';
535918536536- scheme = mkDefOpt types.str "http" "Consul scheme";
919919+ selectors = mkOpt
920920+ (
921921+ types.listOf (
922922+ types.submodule {
923923+ options = {
924924+ role = mkOption {
925925+ type = types.str;
926926+ description = ''
927927+ Selector role
928928+ '';
929929+ };
537930538538- username = mkOpt types.str "Consul username";
931931+ label = mkOpt types.str ''
932932+ Selector label
933933+ '';
539934540540- password = mkOpt types.str "Consul password";
935935+ field = mkOpt types.str ''
936936+ Selector field
937937+ '';
938938+ };
939939+ }
940940+ )
941941+ ) ''
942942+ Optional label and field selectors to limit the discovery process to a subset of available resources.
943943+ See https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/
944944+ and https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ to learn more about the possible
945945+ filters that can be used. Endpoints role supports pod, service and endpoints selectors, other roles
946946+ only support selectors matching the role itself (e.g. node role can only contain node selectors).
541947542542- tls_config = mkOpt promTypes.tls_config ''
543543- Configures the Consul request's TLS settings.
948948+ Note: When making decision about using field/label selector make sure that this
949949+ is the best approach - it will prevent Prometheus from reusing single list/watch
950950+ for all scrape configs. This might result in a bigger load on the Kubernetes API,
951951+ because per each selector combination there will be additional LIST/WATCH. On the other hand,
952952+ if you just want to monitor small subset of pods in large cluster it's recommended to use selectors.
953953+ Decision, if selectors should be used or not depends on the particular situation.
954954+ '';
955955+ };
956956+957957+ promTypes.kuma_sd_config = mkSdConfigModule {
958958+ server = mkOption {
959959+ type = types.str;
960960+ description = ''
961961+ Address of the Kuma Control Plane's MADS xDS server.
962962+ '';
963963+ };
964964+965965+ refresh_interval = mkDefOpt types.str "30s" ''
966966+ The time to wait between polling update requests.
967967+ '';
968968+969969+ fetch_timeout = mkDefOpt types.str "2m" ''
970970+ The time after which the monitoring assignments are refreshed.
971971+ '';
972972+ };
973973+974974+ promTypes.lightsail_sd_config = types.submodule {
975975+ options = {
976976+ region = mkOpt types.str ''
977977+ The AWS region. If blank, the region from the instance metadata is used.
544978 '';
545979546546- services = mkOpt (types.listOf types.str) ''
547547- A list of services for which targets are retrieved.
980980+ endpoint = mkOpt types.str ''
981981+ Custom endpoint to be used.
982982+ '';
983983+984984+ access_key = mkOpt types.str ''
985985+ The AWS API keys. If blank, the environment variable <literal>AWS_ACCESS_KEY_ID</literal> is used.
548986 '';
549987550550- tags = mkOpt (types.listOf types.str) ''
551551- An optional list of tags used to filter nodes for a given
552552- service. Services must contain all tags in the list.
988988+ secret_key = mkOpt types.str ''
989989+ The AWS API keys. If blank, the environment variable <literal>AWS_SECRET_ACCESS_KEY</literal> is used.
553990 '';
554991555555- node_meta = mkOpt (types.attrsOf types.str) ''
556556- Node metadata used to filter nodes for a given service.
992992+ profile = mkOpt types.str ''
993993+ Named AWS profile used to connect to the API.
557994 '';
558995559559- tag_separator = mkDefOpt types.str "," ''
560560- The string by which Consul tags are joined into the tag label.
996996+ role_arn = mkOpt types.str ''
997997+ AWS Role ARN, an alternative to using AWS API keys.
561998 '';
562999563563- allow_stale = mkOpt types.bool ''
564564- Allow stale Consul results
565565- (see <link xlink:href="https://www.consul.io/api/index.html#consistency-modes"/>).
10001000+ refresh_interval = mkDefOpt types.str "60s" ''
10011001+ Refresh interval to re-read the instance list.
10021002+ '';
5661003567567- Will reduce load on Consul.
10041004+ port = mkDefOpt types.int "80" ''
10051005+ The port to scrape metrics from. If using the public IP address, this must
10061006+ instead be specified in the relabeling rule.
5681007 '';
10081008+ };
10091009+ };
5691010570570- refresh_interval = mkDefOpt types.str "30s" ''
571571- The time after which the provided names are refreshed.
10111011+ promTypes.linode_sd_config = mkSdConfigModule {
10121012+ port = mkDefOpt types.int "80" ''
10131013+ The port to scrape metrics from.
10141014+ '';
5721015573573- On large setup it might be a good idea to increase this value
574574- because the catalog will change all the time.
10161016+ tag_separator = mkDefOpt types.str "," ''
10171017+ The string by which Linode Instance tags are joined into the tag label.
10181018+ '';
10191019+10201020+ refresh_interval = mkDefOpt types.str "60s" ''
10211021+ The time after which the linode instances are refreshed.
10221022+ '';
10231023+ };
10241024+10251025+ promTypes.marathon_sd_config = mkSdConfigModule {
10261026+ servers = mkOption {
10271027+ type = types.listOf types.str;
10281028+ description = ''
10291029+ List of URLs to be used to contact Marathon servers. You need to provide at least one server URL.
5751030 '';
5761031 };
10321032+10331033+ refresh_interval = mkDefOpt types.str "30s" ''
10341034+ Polling interval.
10351035+ '';
10361036+10371037+ auth_token = mkOpt types.str ''
10381038+ Optional authentication information for token-based authentication:
10391039+ <link xlink:href="https://docs.mesosphere.com/1.11/security/ent/iam-api/#passing-an-authentication-token" />
10401040+ It is mutually exclusive with <literal>auth_token_file</literal> and other authentication mechanisms.
10411041+ '';
10421042+10431043+ auth_token_file = mkOpt types.str ''
10441044+ Optional authentication information for token-based authentication:
10451045+ <link xlink:href="https://docs.mesosphere.com/1.11/security/ent/iam-api/#passing-an-authentication-token" />
10461046+ It is mutually exclusive with <literal>auth_token</literal> and other authentication mechanisms.
10471047+ '';
5771048 };
5781049579579- promTypes.file_sd_config = types.submodule {
10501050+ promTypes.nerve_sd_config = types.submodule {
5801051 options = {
581581- files = mkOption {
10521052+ servers = mkOption {
10531053+ type = types.listOf types.str;
10541054+ description = ''
10551055+ The Zookeeper servers.
10561056+ '';
10571057+ };
10581058+10591059+ paths = mkOption {
5821060 type = types.listOf types.str;
5831061 description = ''
584584- Patterns for files from which target groups are extracted. Refer
585585- to the Prometheus documentation for permitted filename patterns
586586- and formats.
10621062+ Paths can point to a single service, or the root of a tree of services.
10631063+ '';
10641064+ };
10651065+10661066+ timeout = mkDefOpt types.str "10s" ''
10671067+ Timeout value.
10681068+ '';
10691069+ };
10701070+ };
10711071+10721072+ promTypes.openstack_sd_config = types.submodule {
10731073+ options =
10741074+ let
10751075+ userDescription = ''
10761076+ username is required if using Identity V2 API. Consult with your provider's
10771077+ control panel to discover your account's username. In Identity V3, either
10781078+ userid or a combination of username and domain_id or domain_name are needed.
10791079+ '';
10801080+10811081+ domainDescription = ''
10821082+ At most one of domain_id and domain_name must be provided if using username
10831083+ with Identity V3. Otherwise, either are optional.
10841084+ '';
10851085+10861086+ projectDescription = ''
10871087+ The project_id and project_name fields are optional for the Identity V2 API.
10881088+ Some providers allow you to specify a project_name instead of the project_id.
10891089+ Some require both. Your provider's authentication policies will determine
10901090+ how these fields influence authentication.
10911091+ '';
10921092+10931093+ applicationDescription = ''
10941094+ The application_credential_id or application_credential_name fields are
10951095+ required if using an application credential to authenticate. Some providers
10961096+ allow you to create an application credential to authenticate rather than a
10971097+ password.
10981098+ '';
10991099+ in
11001100+ {
11011101+ role = mkOption {
11021102+ type = types.str;
11031103+ description = ''
11041104+ The OpenStack role of entities that should be discovered.
11051105+ '';
11061106+ };
11071107+11081108+ region = mkOption {
11091109+ type = types.str;
11101110+ description = ''
11111111+ The OpenStack Region.
11121112+ '';
11131113+ };
11141114+11151115+ identity_endpoint = mkOpt types.str ''
11161116+ identity_endpoint specifies the HTTP endpoint that is required to work with
11171117+ the Identity API of the appropriate version. While it's ultimately needed by
11181118+ all of the identity services, it will often be populated by a provider-level
11191119+ function.
11201120+ '';
11211121+11221122+ username = mkOpt types.str userDescription;
11231123+ userid = mkOpt types.str userDescription;
11241124+11251125+ password = mkOpt types.str ''
11261126+ password for the Identity V2 and V3 APIs. Consult with your provider's
11271127+ control panel to discover your account's preferred method of authentication.
11281128+ '';
11291129+11301130+ domain_name = mkOpt types.str domainDescription;
11311131+ domain_id = mkOpt types.str domainDescription;
11321132+11331133+ project_name = mkOpt types.str projectDescription;
11341134+ project_id = mkOpt types.str projectDescription;
11351135+11361136+ application_credential_name = mkOpt types.str applicationDescription;
11371137+ application_credential_id = mkOpt types.str applicationDescription;
11381138+11391139+ application_credential_secret = mkOpt types.str ''
11401140+ The application_credential_secret field is required if using an application
11411141+ credential to authenticate.
11421142+ '';
11431143+11441144+ all_tenants = mkDefOpt types.bool "false" ''
11451145+ Whether the service discovery should list all instances for all projects.
11461146+ It is only relevant for the 'instance' role and usually requires admin permissions.
11471147+ '';
11481148+11491149+ refresh_interval = mkDefOpt types.str "60s" ''
11501150+ Refresh interval to re-read the instance list.
11511151+ '';
11521152+11531153+ port = mkDefOpt types.int "80" ''
11541154+ The port to scrape metrics from. If using the public IP address, this must
11551155+ instead be specified in the relabeling rule.
11561156+ '';
11571157+11581158+ availability = mkDefOpt (types.enum [ "public" "admin" "internal" ]) "public" ''
11591159+ The availability of the endpoint to connect to. Must be one of public, admin or internal.
11601160+ '';
11611161+11621162+ tls_config = mkOpt promTypes.tls_config ''
11631163+ TLS configuration.
5871164 '';
5881165 };
11661166+ };
5891167590590- refresh_interval = mkDefOpt types.str "5m" ''
591591- Refresh interval to re-read the files.
11681168+ promTypes.puppetdb_sd_config = mkSdConfigModule {
11691169+ url = mkOption {
11701170+ type = types.str;
11711171+ description = ''
11721172+ The URL of the PuppetDB root query endpoint.
5921173 '';
5931174 };
11751175+11761176+ query = mkOption {
11771177+ type = types.str;
11781178+ description = ''
11791179+ Puppet Query Language (PQL) query. Only resources are supported.
11801180+ https://puppet.com/docs/puppetdb/latest/api/query/v4/pql.html
11811181+ '';
11821182+ };
11831183+11841184+ include_parameters = mkDefOpt types.bool "false" ''
11851185+ Whether to include the parameters as meta labels.
11861186+ Due to the differences between parameter types and Prometheus labels,
11871187+ some parameters might not be rendered. The format of the parameters might
11881188+ also change in future releases.
11891189+11901190+ Note: Enabling this exposes parameters in the Prometheus UI and API. Make sure
11911191+ that you don't have secrets exposed as parameters if you enable this.
11921192+ '';
11931193+11941194+ refresh_interval = mkDefOpt types.str "60s" ''
11951195+ Refresh interval to re-read the resources list.
11961196+ '';
11971197+11981198+ port = mkDefOpt types.int "80" ''
11991199+ The port to scrape metrics from.
12001200+ '';
5941201 };
5951202596596- promTypes.gce_sd_config = types.submodule {
12031203+ promTypes.scaleway_sd_config = types.submodule {
5971204 options = {
598598- # Use `mkOption` instead of `mkOpt` for project and zone because they are
599599- # required configuration values for `gce_sd_config`.
600600- project = mkOption {
12051205+ access_key = mkOption {
6011206 type = types.str;
6021207 description = ''
603603- The GCP Project.
12081208+ Access key to use. https://console.scaleway.com/project/credentials
6041209 '';
6051210 };
6061211607607- zone = mkOption {
12121212+ secret_key = mkOpt types.str ''
12131213+ Secret key to use when listing targets. https://console.scaleway.com/project/credentials
12141214+ It is mutually exclusive with `secret_key_file`.
12151215+ '';
12161216+12171217+ secret_key_file = mkOpt types.str ''
12181218+ Sets the secret key with the credentials read from the configured file.
12191219+ It is mutually exclusive with `secret_key`.
12201220+ '';
12211221+12221222+ project_id = mkOption {
6081223 type = types.str;
6091224 description = ''
610610- The zone of the scrape targets. If you need multiple zones use multiple
611611- gce_sd_configs.
12251225+ Project ID of the targets.
12261226+ '';
12271227+ };
12281228+12291229+ role = mkOption {
12301230+ type = types.enum [ "instance" "baremetal" ];
12311231+ description = ''
12321232+ Role of the targets to retrieve. Must be `instance` or `baremetal`.
6121233 '';
6131234 };
6141235615615- filter = mkOpt types.str ''
616616- Filter can be used optionally to filter the instance list by other
617617- criteria Syntax of this filter string is described here in the filter
618618- query parameter section: <link
619619- xlink:href="https://cloud.google.com/compute/docs/reference/latest/instances/list"
620620- />.
12361236+ port = mkDefOpt types.int "80" ''
12371237+ The port to scrape metrics from.
12381238+ '';
12391239+12401240+ api_url = mkDefOpt types.str "https://api.scaleway.com" ''
12411241+ API URL to use when doing the server listing requests.
12421242+ '';
12431243+12441244+ zone = mkDefOpt types.str "fr-par-1" ''
12451245+ Zone is the availability zone of your targets (e.g. fr-par-1).
12461246+ '';
12471247+12481248+ name_filter = mkOpt types.str ''
12491249+ Specify a name filter (works as a LIKE) to apply on the server listing request.
12501250+ '';
12511251+12521252+ tags_filter = mkOpt (types.listOf types.str) ''
12531253+ Specify a tag filter (a server needs to have all defined tags to be listed) to apply on the server listing request.
6211254 '';
62212556231256 refresh_interval = mkDefOpt types.str "60s" ''
624624- Refresh interval to re-read the cloud instance list.
12571257+ Refresh interval to re-read the managed targets list.
6251258 '';
6261259627627- port = mkDefOpt types.port "80" ''
628628- The port to scrape metrics from. If using the public IP address, this
629629- must instead be specified in the relabeling rule.
12601260+ proxy_url = mkOpt types.str ''
12611261+ Optional proxy URL.
6301262 '';
6311263632632- tag_separator = mkDefOpt types.str "," ''
633633- The tag separator used to separate concatenated GCE instance network tags.
12641264+ follow_redirects = mkDefOpt types.bool "true" ''
12651265+ Configure whether HTTP requests follow HTTP 3xx redirects.
12661266+ '';
6341267635635- See the GCP documentation on network tags for more information: <link
636636- xlink:href="https://cloud.google.com/vpc/docs/add-remove-network-tags"
637637- />
12681268+ tls_config = mkOpt promTypes.tls_config ''
12691269+ TLS configuration.
6381270 '';
6391271 };
6401272 };
641127312741274+ # These are exactly the same.
12751275+ promTypes.serverset_sd_config = promTypes.nerve_sd_config;
12761276+12771277+ promTypes.triton_sd_config = types.submodule {
12781278+ options = {
12791279+ account = mkOption {
12801280+ type = types.str;
12811281+ description = ''
12821282+ The account to use for discovering new targets.
12831283+ '';
12841284+ };
12851285+12861286+ role = mkDefOpt (types.enum [ "container" "cn" ]) "container" ''
12871287+ The type of targets to discover, can be set to:
12881288+ - "container" to discover virtual machines (SmartOS zones, lx/KVM/bhyve branded zones) running on Triton
12891289+ - "cn" to discover compute nodes (servers/global zones) making up the Triton infrastructure
12901290+ '';
12911291+12921292+ dns_suffix = mkOption {
12931293+ type = types.str;
12941294+ description = ''
12951295+ The DNS suffix which should be applied to target.
12961296+ '';
12971297+ };
12981298+12991299+ endpoint = mkOption {
13001300+ type = types.str;
13011301+ description = ''
13021302+ The Triton discovery endpoint (e.g. <literal>cmon.us-east-3b.triton.zone</literal>). This is
13031303+ often the same value as dns_suffix.
13041304+ '';
13051305+ };
13061306+13071307+ groups = mkOpt (types.listOf types.str) ''
13081308+ A list of groups for which targets are retrieved, only supported when targeting the <literal>container</literal> role.
13091309+ If omitted all containers owned by the requesting account are scraped.
13101310+ '';
13111311+13121312+ port = mkDefOpt types.int "9163" ''
13131313+ The port to use for discovery and metric scraping.
13141314+ '';
13151315+13161316+ refresh_interval = mkDefOpt types.str "60s" ''
13171317+ The interval which should be used for refreshing targets.
13181318+ '';
13191319+13201320+ version = mkDefOpt types.int "1" ''
13211321+ The Triton discovery API version.
13221322+ '';
13231323+13241324+ tls_config = mkOpt promTypes.tls_config ''
13251325+ TLS configuration.
13261326+ '';
13271327+ };
13281328+ };
13291329+13301330+ promTypes.uyuni_sd_config = mkSdConfigModule {
13311331+ server = mkOption {
13321332+ type = types.str;
13331333+ description = ''
13341334+ The URL to connect to the Uyuni server.
13351335+ '';
13361336+ };
13371337+13381338+ username = mkOption {
13391339+ type = types.str;
13401340+ description = ''
13411341+ Credentials are used to authenticate the requests to Uyuni API.
13421342+ '';
13431343+ };
13441344+13451345+ password = mkOption {
13461346+ type = types.str;
13471347+ description = ''
13481348+ Credentials are used to authenticate the requests to Uyuni API.
13491349+ '';
13501350+ };
13511351+13521352+ entitlement = mkDefOpt types.str "monitoring_entitled" ''
13531353+ The entitlement string to filter eligible systems.
13541354+ '';
13551355+13561356+ separator = mkDefOpt types.str "," ''
13571357+ The string by which Uyuni group names are joined into the groups label
13581358+ '';
13591359+13601360+ refresh_interval = mkDefOpt types.str "60s" ''
13611361+ Refresh interval to re-read the managed targets list.
13621362+ '';
13631363+ };
13641364+13651365+ promTypes.static_config = types.submodule {
13661366+ options = {
13671367+ targets = mkOption {
13681368+ type = types.listOf types.str;
13691369+ description = ''
13701370+ The targets specified by the target group.
13711371+ '';
13721372+ };
13731373+ labels = mkOption {
13741374+ type = types.attrsOf types.str;
13751375+ default = { };
13761376+ description = ''
13771377+ Labels assigned to all metrics scraped from the targets.
13781378+ '';
13791379+ };
13801380+ };
13811381+ };
13821382+13831383+ #
13841384+ # Config types: relabling
13851385+ #
13861386+6421387 promTypes.relabel_config = types.submodule {
6431388 options = {
6441389 source_labels = mkOpt (types.listOf types.str) ''
···6701415 '';
67114166721417 action =
673673- mkDefOpt (types.enum ["replace" "keep" "drop" "hashmod" "labelmap" "labeldrop" "labelkeep"]) "replace" ''
674674- Action to perform based on regex matching.
14181418+ mkDefOpt (types.enum [ "replace" "keep" "drop" "hashmod" "labelmap" "labeldrop" "labelkeep" ]) "replace" ''
14191419+ Action to perform based on regex matching.
14201420+ '';
14211421+ };
14221422+ };
14231423+14241424+ #
14251425+ # Config types : remote read / write
14261426+ #
14271427+14281428+ promTypes.remote_write = types.submodule {
14291429+ options = {
14301430+ url = mkOption {
14311431+ type = types.str;
14321432+ description = ''
14331433+ ServerName extension to indicate the name of the server.
14341434+ http://tools.ietf.org/html/rfc4366#section-3.1
14351435+ '';
14361436+ };
14371437+ remote_timeout = mkOpt types.str ''
14381438+ Timeout for requests to the remote write endpoint.
14391439+ '';
14401440+ write_relabel_configs = mkOpt (types.listOf promTypes.relabel_config) ''
14411441+ List of remote write relabel configurations.
14421442+ '';
14431443+ name = mkOpt types.str ''
14441444+ Name of the remote write config, which if specified must be unique among remote write configs.
14451445+ The name will be used in metrics and logging in place of a generated value to help users distinguish between
14461446+ remote write configs.
14471447+ '';
14481448+ basic_auth = mkOpt promTypes.basic_auth ''
14491449+ Sets the `Authorization` header on every remote write request with the
14501450+ configured username and password.
14511451+ password and password_file are mutually exclusive.
14521452+ '';
14531453+ bearer_token = mkOpt types.str ''
14541454+ Sets the `Authorization` header on every remote write request with
14551455+ the configured bearer token. It is mutually exclusive with `bearer_token_file`.
14561456+ '';
14571457+ bearer_token_file = mkOpt types.str ''
14581458+ Sets the `Authorization` header on every remote write request with the bearer token
14591459+ read from the configured file. It is mutually exclusive with `bearer_token`.
14601460+ '';
14611461+ tls_config = mkOpt promTypes.tls_config ''
14621462+ Configures the remote write request's TLS settings.
14631463+ '';
14641464+ proxy_url = mkOpt types.str "Optional Proxy URL.";
14651465+ queue_config = mkOpt
14661466+ (types.submodule {
14671467+ options = {
14681468+ capacity = mkOpt types.int ''
14691469+ Number of samples to buffer per shard before we block reading of more
14701470+ samples from the WAL. It is recommended to have enough capacity in each
14711471+ shard to buffer several requests to keep throughput up while processing
14721472+ occasional slow remote requests.
14731473+ '';
14741474+ max_shards = mkOpt types.int ''
14751475+ Maximum number of shards, i.e. amount of concurrency.
14761476+ '';
14771477+ min_shards = mkOpt types.int ''
14781478+ Minimum number of shards, i.e. amount of concurrency.
14791479+ '';
14801480+ max_samples_per_send = mkOpt types.int ''
14811481+ Maximum number of samples per send.
14821482+ '';
14831483+ batch_send_deadline = mkOpt types.str ''
14841484+ Maximum time a sample will wait in buffer.
14851485+ '';
14861486+ min_backoff = mkOpt types.str ''
14871487+ Initial retry delay. Gets doubled for every retry.
14881488+ '';
14891489+ max_backoff = mkOpt types.str ''
14901490+ Maximum retry delay.
14911491+ '';
14921492+ };
14931493+ }) ''
14941494+ Configures the queue used to write to remote storage.
14951495+ '';
14961496+ metadata_config = mkOpt
14971497+ (types.submodule {
14981498+ options = {
14991499+ send = mkOpt types.bool ''
15001500+ Whether metric metadata is sent to remote storage or not.
15011501+ '';
15021502+ send_interval = mkOpt types.str ''
15031503+ How frequently metric metadata is sent to remote storage.
15041504+ '';
15051505+ };
15061506+ }) ''
15071507+ Configures the sending of series metadata to remote storage.
15081508+ Metadata configuration is subject to change at any point
15091509+ or be removed in future releases.
6751510 '';
6761511 };
6771512 };
6781513679679- promTypes.tls_config = types.submodule {
15141514+ promTypes.remote_read = types.submodule {
6801515 options = {
681681- ca_file = mkOpt types.str ''
682682- CA certificate to validate API server certificate with.
15161516+ url = mkOption {
15171517+ type = types.str;
15181518+ description = ''
15191519+ ServerName extension to indicate the name of the server.
15201520+ http://tools.ietf.org/html/rfc4366#section-3.1
15211521+ '';
15221522+ };
15231523+ name = mkOpt types.str ''
15241524+ Name of the remote read config, which if specified must be unique among remote read configs.
15251525+ The name will be used in metrics and logging in place of a generated value to help users distinguish between
15261526+ remote read configs.
6831527 '';
684684-685685- cert_file = mkOpt types.str ''
686686- Certificate file for client cert authentication to the server.
15281528+ required_matchers = mkOpt (types.attrsOf types.str) ''
15291529+ An optional list of equality matchers which have to be
15301530+ present in a selector to query the remote read endpoint.
6871531 '';
688688-689689- key_file = mkOpt types.str ''
690690- Key file for client cert authentication to the server.
15321532+ remote_timeout = mkOpt types.str ''
15331533+ Timeout for requests to the remote read endpoint.
6911534 '';
692692-693693- server_name = mkOpt types.str ''
694694- ServerName extension to indicate the name of the server.
695695- http://tools.ietf.org/html/rfc4366#section-3.1
15351535+ read_recent = mkOpt types.bool ''
15361536+ Whether reads should be made for queries for time ranges that
15371537+ the local storage should have complete data for.
6961538 '';
697697-698698- insecure_skip_verify = mkOpt types.bool ''
699699- Disable validation of the server certificate.
15391539+ basic_auth = mkOpt promTypes.basic_auth ''
15401540+ Sets the `Authorization` header on every remote read request with the
15411541+ configured username and password.
15421542+ password and password_file are mutually exclusive.
7001543 '';
15441544+ bearer_token = mkOpt types.str ''
15451545+ Sets the `Authorization` header on every remote read request with
15461546+ the configured bearer token. It is mutually exclusive with `bearer_token_file`.
15471547+ '';
15481548+ bearer_token_file = mkOpt types.str ''
15491549+ Sets the `Authorization` header on every remote read request with the bearer token
15501550+ read from the configured file. It is mutually exclusive with `bearer_token`.
15511551+ '';
15521552+ tls_config = mkOpt promTypes.tls_config ''
15531553+ Configures the remote read request's TLS settings.
15541554+ '';
15551555+ proxy_url = mkOpt types.str "Optional Proxy URL.";
7011556 };
7021557 };
7031558704704-in {
15591559+in
15601560+{
70515617061562 imports = [
7071563 (mkRenamedOptionModule [ "services" "prometheus2" ] [ "services" "prometheus" ])
···75316097541610 extraFlags = mkOption {
7551611 type = types.listOf types.str;
756756- default = [];
16121612+ default = [ ];
7571613 description = ''
7581614 Extra commandline options when launching Prometheus.
7591615 '';
···82916858301686 globalConfig = mkOption {
8311687 type = promTypes.globalConfig;
832832- default = {};
16881688+ default = { };
8331689 description = ''
8341690 Parameters that are valid in all configuration contexts. They
8351691 also serve as defaults for other configuration sections
···83816948391695 remoteRead = mkOption {
8401696 type = types.listOf promTypes.remote_read;
841841- default = [];
16971697+ default = [ ];
8421698 description = ''
8431699 Parameters of the endpoints to query from.
8441700 See <link xlink:href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_read">the official documentation</link> for more information.
···84717038481704 remoteWrite = mkOption {
8491705 type = types.listOf promTypes.remote_write;
850850- default = [];
17061706+ default = [ ];
8511707 description = ''
8521708 Parameters of the endpoints to send samples to.
8531709 See <link xlink:href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write">the official documentation</link> for more information.
···85617128571713 rules = mkOption {
8581714 type = types.listOf types.str;
859859- default = [];
17151715+ default = [ ];
8601716 description = ''
8611717 Alerting and/or Recording rules to evaluate at runtime.
8621718 '';
···86417208651721 ruleFiles = mkOption {
8661722 type = types.listOf types.path;
867867- default = [];
17231723+ default = [ ];
8681724 description = ''
8691725 Any additional rules files to include in this configuration.
8701726 '';
···87217288731729 scrapeConfigs = mkOption {
8741730 type = types.listOf promTypes.scrape_config;
875875- default = [];
17311731+ default = [ ];
8761732 description = ''
8771733 A list of scrape configurations.
8781734 '';
···8911747 } ];
8921748 } ]
8931749 '';
894894- default = [];
17501750+ default = [ ];
8951751 description = ''
8961752 A list of alertmanagers to send alerts to.
8971753 See <link xlink:href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alertmanager_config">the official documentation</link> for more information.
···95018069511807 config = mkIf cfg.enable {
9521808 assertions = [
953953- ( let
18091809+ (
18101810+ let
9541811 # Match something with dots (an IPv4 address) or something ending in
9551812 # a square bracket (an IPv6 addresses) followed by a port number.
9561813 legacy = builtins.match "(.*\\..*|.*]):([[:digit:]]+)" cfg.listenAddress;
957957- in {
18141814+ in
18151815+ {
9581816 assertion = legacy == null;
9591817 message = ''
9601818 Do not specify the port for Prometheus to listen on in the
···9741832 };
9751833 systemd.services.prometheus = {
9761834 wantedBy = [ "multi-user.target" ];
977977- after = [ "network.target" ];
18351835+ after = [ "network.target" ];
9781836 preStart = mkIf (!cfg.enableReload) ''
979979- ${lib.getBin pkgs.envsubst}/bin/envsubst -o "/run/prometheus/prometheus-substituted.yaml" \
980980- -i "${prometheusYml}"
18371837+ ${lib.getBin pkgs.envsubst}/bin/envsubst -o "/run/prometheus/prometheus-substituted.yaml" \
18381838+ -i "${prometheusYml}"
9811839 '';
9821840 serviceConfig = {
9831841 ExecStart = "${cfg.package}/bin/prometheus" +
···9851843 concatStringsSep " \\\n " cmdlineArgs);
9861844 ExecReload = mkIf cfg.enableReload "+${reload}/bin/reload-prometheus";
9871845 User = "prometheus";
988988- Restart = "always";
18461846+ Restart = "always";
9891847 EnvironmentFile = mkIf (cfg.environmentFile != null && !cfg.enableReload) [ cfg.environmentFile ];
9901848 RuntimeDirectory = "prometheus";
9911849 RuntimeDirectoryMode = "0700";