Merge pull request #142654 from yrd/prometheus-config-modules

nixos/prometheus: add new configuration options

authored by Bas van Dijk and committed by GitHub dd1edacb faf28d50

+1139 -281
+1139 -281
nixos/modules/services/monitoring/prometheus/default.nix
··· 37 37 pkgs.runCommandLocal 38 38 "${name}-${replaceStrings [" "] [""] what}-checked" 39 39 { buildInputs = [ cfg.package ]; } '' 40 - ln -s ${file} $out 41 - promtool ${what} $out 42 - '' else file; 40 + ln -s ${file} $out 41 + promtool ${what} $out 42 + '' else file; 43 43 44 44 # Pretty-print JSON to a file 45 45 writePrettyJSON = name: x: 46 - pkgs.runCommandLocal name {} '' 46 + pkgs.runCommandLocal name { } '' 47 47 echo '${builtins.toJSON x}' | ${pkgs.jq}/bin/jq . > $out 48 48 ''; 49 49 ··· 63 63 }; 64 64 }; 65 65 66 - prometheusYml = let 67 - yml = if cfg.configText != null then 68 - pkgs.writeText "prometheus.yml" cfg.configText 69 - else generatedPrometheusYml; 70 - in promtoolCheck "check config" "prometheus.yml" yml; 66 + prometheusYml = 67 + let 68 + yml = 69 + if cfg.configText != null then 70 + pkgs.writeText "prometheus.yml" cfg.configText 71 + else generatedPrometheusYml; 72 + in 73 + promtoolCheck "check config" "prometheus.yml" yml; 71 74 72 75 cmdlineArgs = cfg.extraFlags ++ [ 73 76 "--storage.tsdb.path=${workingDir}/data/" ··· 80 83 "--alertmanager.notification-queue-capacity=${toString cfg.alertmanagerNotificationQueueCapacity}" 81 84 "--alertmanager.timeout=${toString cfg.alertmanagerTimeout}s" 82 85 ] ++ optional (cfg.webExternalUrl != null) "--web.external-url=${cfg.webExternalUrl}" 83 - ++ optional (cfg.retentionTime != null) "--storage.tsdb.retention.time=${cfg.retentionTime}"; 86 + ++ optional (cfg.retentionTime != null) "--storage.tsdb.retention.time=${cfg.retentionTime}"; 84 87 85 88 filterValidPrometheus = filterAttrsListRecursive (n: v: !(n == "_module" || v == null)); 86 89 filterAttrsListRecursive = pred: x: 87 90 if isAttrs x then 88 - listToAttrs ( 89 - concatMap (name: 90 - let v = x.${name}; in 91 - if pred name v then [ 92 - (nameValuePair name (filterAttrsListRecursive pred v)) 93 - ] else [] 94 - ) (attrNames x) 95 - ) 91 + listToAttrs 92 + ( 93 + concatMap 94 + (name: 95 + let v = x.${name}; in 96 + if pred name v then [ 97 + (nameValuePair name (filterAttrsListRecursive pred v)) 98 + ] else [ ] 99 + ) 100 + (attrNames x) 101 + ) 96 102 else if isList x then 97 103 map (filterAttrsListRecursive pred) x 98 104 else x; 99 105 100 - mkDefOpt = type : defaultStr : description : mkOpt type (description + '' 106 + # 107 + # Config types: helper functions 108 + # 109 + 110 + mkDefOpt = type: defaultStr: description: mkOpt type (description + '' 101 111 102 112 Defaults to <literal>${defaultStr}</literal> in prometheus 103 113 when set to <literal>null</literal>. 104 114 ''); 105 115 106 - mkOpt = type : description : mkOption { 116 + mkOpt = type: description: mkOption { 107 117 type = types.nullOr type; 108 118 default = null; 109 119 inherit description; 110 120 }; 111 121 122 + mkSdConfigModule = extraOptions: types.submodule { 123 + options = { 124 + basic_auth = mkOpt promTypes.basic_auth '' 125 + Optional HTTP basic authentication information. 126 + ''; 127 + 128 + authorization = mkOpt 129 + (types.submodule { 130 + options = { 131 + type = mkDefOpt types.str "Bearer" '' 132 + Sets the authentication type. 133 + ''; 134 + 135 + credentials = mkOpt types.str '' 136 + Sets the credentials. It is mutually exclusive with `credentials_file`. 137 + ''; 138 + 139 + credentials_file = mkOpt types.str '' 140 + Sets the credentials to the credentials read from the configured file. 141 + It is mutually exclusive with `credentials`. 142 + ''; 143 + }; 144 + }) '' 145 + Optional `Authorization` header configuration. 146 + ''; 147 + 148 + oauth2 = mkOpt promtypes.oauth2 '' 149 + Optional OAuth 2.0 configuration. 150 + Cannot be used at the same time as basic_auth or authorization. 151 + ''; 152 + 153 + proxy_url = mkOpt types.str '' 154 + Optional proxy URL. 155 + ''; 156 + 157 + follow_redirects = mkDefOpt types.bool "true" '' 158 + Configure whether HTTP requests follow HTTP 3xx redirects. 159 + ''; 160 + 161 + tls_config = mkOpt promTypes.tls_config '' 162 + TLS configuration. 163 + ''; 164 + } // extraOptions; 165 + }; 166 + 167 + # 168 + # Config types: general 169 + # 170 + 112 171 promTypes.globalConfig = types.submodule { 113 172 options = { 114 173 scrape_interval = mkDefOpt types.str "1m" '' ··· 131 190 }; 132 191 }; 133 192 134 - promTypes.remote_read = types.submodule { 193 + promTypes.basic_auth = types.submodule { 135 194 options = { 136 - url = mkOption { 195 + username = mkOption { 137 196 type = types.str; 138 197 description = '' 139 - ServerName extension to indicate the name of the server. 140 - http://tools.ietf.org/html/rfc4366#section-3.1 198 + HTTP username 141 199 ''; 142 200 }; 143 - name = mkOpt types.str '' 144 - Name of the remote read config, which if specified must be unique among remote read configs. 145 - The name will be used in metrics and logging in place of a generated value to help users distinguish between 146 - remote read configs. 201 + password = mkOpt types.str "HTTP password"; 202 + password_file = mkOpt types.str "HTTP password file"; 203 + }; 204 + }; 205 + 206 + promTypes.tls_config = types.submodule { 207 + options = { 208 + ca_file = mkOpt types.str '' 209 + CA certificate to validate API server certificate with. 147 210 ''; 148 - required_matchers = mkOpt (types.attrsOf types.str) '' 149 - An optional list of equality matchers which have to be 150 - present in a selector to query the remote read endpoint. 211 + 212 + cert_file = mkOpt types.str '' 213 + Certificate file for client cert authentication to the server. 151 214 ''; 152 - remote_timeout = mkOpt types.str '' 153 - Timeout for requests to the remote read endpoint. 215 + 216 + key_file = mkOpt types.str '' 217 + Key file for client cert authentication to the server. 154 218 ''; 155 - read_recent = mkOpt types.bool '' 156 - Whether reads should be made for queries for time ranges that 157 - the local storage should have complete data for. 219 + 220 + server_name = mkOpt types.str '' 221 + ServerName extension to indicate the name of the server. 222 + http://tools.ietf.org/html/rfc4366#section-3.1 158 223 ''; 159 - basic_auth = mkOpt (types.submodule { 160 - options = { 161 - username = mkOption { 162 - type = types.str; 163 - description = '' 164 - HTTP username 165 - ''; 166 - }; 167 - password = mkOpt types.str "HTTP password"; 168 - password_file = mkOpt types.str "HTTP password file"; 169 - }; 170 - }) '' 171 - Sets the `Authorization` header on every remote read request with the 172 - configured username and password. 173 - password and password_file are mutually exclusive. 174 - ''; 175 - bearer_token = mkOpt types.str '' 176 - Sets the `Authorization` header on every remote read request with 177 - the configured bearer token. It is mutually exclusive with `bearer_token_file`. 224 + 225 + insecure_skip_verify = mkOpt types.bool '' 226 + Disable validation of the server certificate. 178 227 ''; 179 - bearer_token_file = mkOpt types.str '' 180 - Sets the `Authorization` header on every remote read request with the bearer token 181 - read from the configured file. It is mutually exclusive with `bearer_token`. 182 - ''; 183 - tls_config = mkOpt promTypes.tls_config '' 184 - Configures the remote read request's TLS settings. 185 - ''; 186 - proxy_url = mkOpt types.str "Optional Proxy URL."; 187 228 }; 188 229 }; 189 230 190 - promTypes.remote_write = types.submodule { 231 + promtypes.oauth2 = types.submodule { 191 232 options = { 192 - url = mkOption { 193 - type = types.str; 194 - description = '' 195 - ServerName extension to indicate the name of the server. 196 - http://tools.ietf.org/html/rfc4366#section-3.1 197 - ''; 198 - }; 199 - remote_timeout = mkOpt types.str '' 200 - Timeout for requests to the remote write endpoint. 233 + client_id = mkOpt types.str '' 234 + OAuth client ID. 201 235 ''; 202 - write_relabel_configs = mkOpt (types.listOf promTypes.relabel_config) '' 203 - List of remote write relabel configurations. 236 + 237 + client_secret = mkOpt types.str '' 238 + OAuth client secret. 204 239 ''; 205 - name = mkOpt types.str '' 206 - Name of the remote write config, which if specified must be unique among remote write configs. 207 - The name will be used in metrics and logging in place of a generated value to help users distinguish between 208 - remote write configs. 240 + 241 + client_secret_file = mkOpt types.str '' 242 + Read the client secret from a file. It is mutually exclusive with `client_secret`. 209 243 ''; 210 - basic_auth = mkOpt (types.submodule { 211 - options = { 212 - username = mkOption { 213 - type = types.str; 214 - description = '' 215 - HTTP username 216 - ''; 217 - }; 218 - password = mkOpt types.str "HTTP password"; 219 - password_file = mkOpt types.str "HTTP password file"; 220 - }; 221 - }) '' 222 - Sets the `Authorization` header on every remote write request with the 223 - configured username and password. 224 - password and password_file are mutually exclusive. 244 + 245 + scopes = mkOpt (types.listOf types.str) '' 246 + Scopes for the token request. 225 247 ''; 226 - bearer_token = mkOpt types.str '' 227 - Sets the `Authorization` header on every remote write request with 228 - the configured bearer token. It is mutually exclusive with `bearer_token_file`. 248 + 249 + token_url = mkOpt types.str '' 250 + The URL to fetch the token from. 229 251 ''; 230 - bearer_token_file = mkOpt types.str '' 231 - Sets the `Authorization` header on every remote write request with the bearer token 232 - read from the configured file. It is mutually exclusive with `bearer_token`. 233 - ''; 234 - tls_config = mkOpt promTypes.tls_config '' 235 - Configures the remote write request's TLS settings. 236 - ''; 237 - proxy_url = mkOpt types.str "Optional Proxy URL."; 238 - queue_config = mkOpt (types.submodule { 239 - options = { 240 - capacity = mkOpt types.int '' 241 - Number of samples to buffer per shard before we block reading of more 242 - samples from the WAL. It is recommended to have enough capacity in each 243 - shard to buffer several requests to keep throughput up while processing 244 - occasional slow remote requests. 245 - ''; 246 - max_shards = mkOpt types.int '' 247 - Maximum number of shards, i.e. amount of concurrency. 248 - ''; 249 - min_shards = mkOpt types.int '' 250 - Minimum number of shards, i.e. amount of concurrency. 251 - ''; 252 - max_samples_per_send = mkOpt types.int '' 253 - Maximum number of samples per send. 254 - ''; 255 - batch_send_deadline = mkOpt types.str '' 256 - Maximum time a sample will wait in buffer. 257 - ''; 258 - min_backoff = mkOpt types.str '' 259 - Initial retry delay. Gets doubled for every retry. 260 - ''; 261 - max_backoff = mkOpt types.str '' 262 - Maximum retry delay. 263 - ''; 264 - }; 265 - }) '' 266 - Configures the queue used to write to remote storage. 267 - ''; 268 - metadata_config = mkOpt (types.submodule { 269 - options = { 270 - send = mkOpt types.bool '' 271 - Whether metric metadata is sent to remote storage or not. 272 - ''; 273 - send_interval = mkOpt types.str '' 274 - How frequently metric metadata is sent to remote storage. 275 - ''; 276 - }; 277 - }) '' 278 - Configures the sending of series metadata to remote storage. 279 - Metadata configuration is subject to change at any point 280 - or be removed in future releases. 252 + 253 + endpoint_params = mkOpt (types.attrsOf types.str) '' 254 + Optional parameters to append to the token URL. 281 255 ''; 282 256 }; 283 257 }; ··· 335 309 by the target will be ignored. 336 310 ''; 337 311 338 - scheme = mkDefOpt (types.enum ["http" "https"]) "http" '' 312 + scheme = mkDefOpt (types.enum [ "http" "https" ]) "http" '' 339 313 The URL scheme with which to fetch metrics from targets. 340 314 ''; 341 315 ··· 343 317 Optional HTTP URL parameters. 344 318 ''; 345 319 346 - basic_auth = mkOpt (types.submodule { 347 - options = { 348 - username = mkOption { 349 - type = types.str; 350 - description = '' 351 - HTTP username 352 - ''; 353 - }; 354 - password = mkOpt types.str "HTTP password"; 355 - password_file = mkOpt types.str "HTTP password file"; 356 - }; 357 - }) '' 320 + basic_auth = mkOpt promTypes.basic_auth '' 358 321 Sets the `Authorization` header on every scrape request with the 359 322 configured username and password. 360 323 password and password_file are mutually exclusive. ··· 380 343 Optional proxy URL. 381 344 ''; 382 345 383 - ec2_sd_configs = mkOpt (types.listOf promTypes.ec2_sd_config) '' 384 - List of EC2 service discovery configurations. 346 + azure_sd_configs = mkOpt (types.listOf promTypes.azure_sd_config) '' 347 + List of Azure service discovery configurations. 348 + ''; 349 + 350 + consul_sd_configs = mkOpt (types.listOf promTypes.consul_sd_config) '' 351 + List of Consul service discovery configurations. 352 + ''; 353 + 354 + digitalocean_sd_configs = mkOpt (types.listOf promTypes.digitalocean_sd_config) '' 355 + List of DigitalOcean service discovery configurations. 356 + ''; 357 + 358 + docker_sd_configs = mkOpt (types.listOf promTypes.docker_sd_config) '' 359 + List of Docker service discovery configurations. 360 + ''; 361 + 362 + dockerswarm_sd_configs = mkOpt (types.listOf promTypes.dockerswarm_sd_config) '' 363 + List of Docker Swarm service discovery configurations. 385 364 ''; 386 365 387 366 dns_sd_configs = mkOpt (types.listOf promTypes.dns_sd_config) '' 388 367 List of DNS service discovery configurations. 389 368 ''; 390 369 391 - consul_sd_configs = mkOpt (types.listOf promTypes.consul_sd_config) '' 392 - List of Consul service discovery configurations. 370 + ec2_sd_configs = mkOpt (types.listOf promTypes.ec2_sd_config) '' 371 + List of EC2 service discovery configurations. 372 + ''; 373 + 374 + eureka_sd_configs = mkOpt (types.listOf promTypes.eureka_sd_config) '' 375 + List of Eureka service discovery configurations. 393 376 ''; 394 377 395 378 file_sd_configs = mkOpt (types.listOf promTypes.file_sd_config) '' ··· 404 387 relevant Prometheus configuration docs</link> for more detail. 405 388 ''; 406 389 390 + hetzner_sd_configs = mkOpt (types.listOf promTypes.hetzner_sd_config) '' 391 + List of Hetzner service discovery configurations. 392 + ''; 393 + 394 + http_sd_configs = mkOpt (types.listOf promTypes.http_sd_config) '' 395 + List of HTTP service discovery configurations. 396 + ''; 397 + 398 + kubernetes_sd_configs = mkOpt (types.listOf promTypes.kubernetes_sd_config) '' 399 + List of Kubernetes service discovery configurations. 400 + ''; 401 + 402 + kuma_sd_configs = mkOpt (types.listOf promTypes.kuma_sd_config) '' 403 + List of Kuma service discovery configurations. 404 + ''; 405 + 406 + lightsail_sd_configs = mkOpt (types.listOf promTypes.lightsail_sd_config) '' 407 + List of Lightsail service discovery configurations. 408 + ''; 409 + 410 + linode_sd_configs = mkOpt (types.listOf promTypes.linode_sd_config) '' 411 + List of Linode service discovery configurations. 412 + ''; 413 + 414 + marathon_sd_configs = mkOpt (types.listOf promTypes.marathon_sd_config) '' 415 + List of Marathon service discovery configurations. 416 + ''; 417 + 418 + nerve_sd_configs = mkOpt (types.listOf promTypes.nerve_sd_config) '' 419 + List of AirBnB's Nerve service discovery configurations. 420 + ''; 421 + 422 + openstack_sd_configs = mkOpt (types.listOf promTypes.openstack_sd_config) '' 423 + List of OpenStack service discovery configurations. 424 + ''; 425 + 426 + puppetdb_sd_configs = mkOpt (types.listOf promTypes.puppetdb_sd_config) '' 427 + List of PuppetDB service discovery configurations. 428 + ''; 429 + 430 + scaleway_sd_configs = mkOpt (types.listOf promTypes.scaleway_sd_config) '' 431 + List of Scaleway service discovery configurations. 432 + ''; 433 + 434 + serverset_sd_configs = mkOpt (types.listOf promTypes.serverset_sd_config) '' 435 + List of Zookeeper Serverset service discovery configurations. 436 + ''; 437 + 438 + triton_sd_configs = mkOpt (types.listOf promTypes.triton_sd_config) '' 439 + List of Triton Serverset service discovery configurations. 440 + ''; 441 + 442 + uyuni_sd_configs = mkOpt (types.listOf promTypes.uyuni_sd_config) '' 443 + List of Uyuni Serverset service discovery configurations. 444 + ''; 445 + 407 446 static_configs = mkOpt (types.listOf promTypes.static_config) '' 408 447 List of labeled target groups for this job. 409 448 ''; ··· 416 455 List of metric relabel configurations. 417 456 ''; 418 457 458 + body_size_limit = mkDefOpt types.str "0" '' 459 + An uncompressed response body larger than this many bytes will cause the 460 + scrape to fail. 0 means no limit. Example: 100MB. 461 + This is an experimental feature, this behaviour could 462 + change or be removed in the future. 463 + ''; 464 + 419 465 sample_limit = mkDefOpt types.int "0" '' 420 466 Per-scrape limit on number of scraped samples that will be accepted. 421 467 If more than this number of samples are present after metric relabelling 422 468 the entire scrape will be treated as failed. 0 means no limit. 423 469 ''; 470 + 471 + label_limit = mkDefOpt types.int "0" '' 472 + Per-scrape limit on number of labels that will be accepted for a sample. If 473 + more than this number of labels are present post metric-relabeling, the 474 + entire scrape will be treated as failed. 0 means no limit. 475 + ''; 476 + 477 + label_name_length_limit = mkDefOpt types.int "0" '' 478 + Per-scrape limit on length of labels name that will be accepted for a sample. 479 + If a label name is longer than this number post metric-relabeling, the entire 480 + scrape will be treated as failed. 0 means no limit. 481 + ''; 482 + 483 + label_value_length_limit = mkDefOpt types.int "0" '' 484 + Per-scrape limit on length of labels value that will be accepted for a sample. 485 + If a label value is longer than this number post metric-relabeling, the 486 + entire scrape will be treated as failed. 0 means no limit. 487 + ''; 488 + 489 + target_limit = mkDefOpt types.int "0" '' 490 + Per-scrape config limit on number of unique targets that will be 491 + accepted. If more than this number of targets are present after target 492 + relabeling, Prometheus will mark the targets as failed without scraping them. 493 + 0 means no limit. This is an experimental feature, this behaviour could 494 + change in the future. 495 + ''; 424 496 }; 425 497 }; 426 498 427 - promTypes.static_config = types.submodule { 499 + # 500 + # Config types: service discovery 501 + # 502 + 503 + # For this one, the docs actually define all types needed to use mkSdConfigModule, but a bunch 504 + # of them are marked with 'currently not support by Azure' so we don't bother adding them in 505 + # here. 506 + promTypes.azure_sd_config = types.submodule { 428 507 options = { 429 - targets = mkOption { 430 - type = types.listOf types.str; 508 + environment = mkDefOpt types.str "AzurePublicCloud" '' 509 + The Azure environment. 510 + ''; 511 + 512 + authentication_method = mkDefOpt (types.enum [ "OAuth" "ManagedIdentity" ]) "OAuth" '' 513 + The authentication method, either OAuth or ManagedIdentity. 514 + See https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview 515 + ''; 516 + 517 + subscription_id = mkOption { 518 + type = types.str; 431 519 description = '' 432 - The targets specified by the target group. 520 + The subscription ID. 433 521 ''; 434 522 }; 435 - labels = mkOption { 436 - type = types.attrsOf types.str; 437 - default = {}; 523 + 524 + tenant_id = mkOpt types.str '' 525 + Optional tenant ID. Only required with authentication_method OAuth. 526 + ''; 527 + 528 + client_id = mkOpt types.str '' 529 + Optional client ID. Only required with authentication_method OAuth. 530 + ''; 531 + 532 + client_secret = mkOpt types.str '' 533 + Optional client secret. Only required with authentication_method OAuth. 534 + ''; 535 + 536 + refresh_interval = mkDefOpt types.str "300s" '' 537 + Refresh interval to re-read the instance list. 538 + ''; 539 + 540 + port = mkDefOpt types.int "80" '' 541 + The port to scrape metrics from. If using the public IP 542 + address, this must instead be specified in the relabeling 543 + rule. 544 + ''; 545 + 546 + proxy_url = mkOpt types.str '' 547 + Optional proxy URL. 548 + ''; 549 + 550 + follow_redirects = mkDefOpt types.bool "true" '' 551 + Configure whether HTTP requests follow HTTP 3xx redirects. 552 + ''; 553 + 554 + tls_config = mkOpt promTypes.tls_config '' 555 + TLS configuration. 556 + ''; 557 + }; 558 + }; 559 + 560 + promTypes.consul_sd_config = mkSdConfigModule { 561 + server = mkDefOpt types.str "localhost:8500" '' 562 + Consul server to query. 563 + ''; 564 + 565 + token = mkOpt types.str "Consul token"; 566 + 567 + datacenter = mkOpt types.str "Consul datacenter"; 568 + 569 + scheme = mkDefOpt types.str "http" "Consul scheme"; 570 + 571 + username = mkOpt types.str "Consul username"; 572 + 573 + password = mkOpt types.str "Consul password"; 574 + 575 + tls_config = mkOpt promTypes.tls_config '' 576 + Configures the Consul request's TLS settings. 577 + ''; 578 + 579 + services = mkOpt (types.listOf types.str) '' 580 + A list of services for which targets are retrieved. 581 + ''; 582 + 583 + tags = mkOpt (types.listOf types.str) '' 584 + An optional list of tags used to filter nodes for a given 585 + service. Services must contain all tags in the list. 586 + ''; 587 + 588 + node_meta = mkOpt (types.attrsOf types.str) '' 589 + Node metadata used to filter nodes for a given service. 590 + ''; 591 + 592 + tag_separator = mkDefOpt types.str "," '' 593 + The string by which Consul tags are joined into the tag label. 594 + ''; 595 + 596 + allow_stale = mkOpt types.bool '' 597 + Allow stale Consul results 598 + (see <link xlink:href="https://www.consul.io/api/index.html#consistency-modes"/>). 599 + 600 + Will reduce load on Consul. 601 + ''; 602 + 603 + refresh_interval = mkDefOpt types.str "30s" '' 604 + The time after which the provided names are refreshed. 605 + 606 + On large setup it might be a good idea to increase this value 607 + because the catalog will change all the time. 608 + ''; 609 + }; 610 + 611 + promTypes.digitalocean_sd_config = mkSdConfigModule { 612 + port = mkDefOpt types.int "80" '' 613 + The port to scrape metrics from. 614 + ''; 615 + 616 + refresh_interval = mkDefOpt types.str "60s" '' 617 + The time after which the droplets are refreshed. 618 + ''; 619 + }; 620 + 621 + mkDockerSdConfigModule = extraOptions: mkSdConfigModule ({ 622 + host = mkOption { 623 + type = types.str; 624 + description = '' 625 + Address of the Docker daemon. 626 + ''; 627 + }; 628 + 629 + port = mkDefOpt types.int "80" '' 630 + The port to scrape metrics from, when `role` is nodes, and for discovered 631 + tasks and services that don't have published ports. 632 + ''; 633 + 634 + filters = mkOpt 635 + (types.listOf (types.submodule { 636 + options = { 637 + name = mkOption { 638 + type = types.str; 639 + description = '' 640 + Name of the filter. The available filters are listed in the upstream documentation: 641 + Services: <link xlink:href="https://docs.docker.com/engine/api/v1.40/#operation/ServiceList"/> 642 + Tasks: <link xlink:href="https://docs.docker.com/engine/api/v1.40/#operation/TaskList"/> 643 + Nodes: <link xlink:href="https://docs.docker.com/engine/api/v1.40/#operation/NodeList"/> 644 + ''; 645 + }; 646 + values = mkOption { 647 + type = types.str; 648 + description = '' 649 + Value for the filter. 650 + ''; 651 + }; 652 + }; 653 + })) '' 654 + Optional filters to limit the discovery process to a subset of available resources. 655 + ''; 656 + 657 + refresh_interval = mkDefOpt types.str "60s" '' 658 + The time after which the containers are refreshed. 659 + ''; 660 + } // extraOptions); 661 + 662 + promTypes.docker_sd_config = mkDockerSdConfigModule { 663 + host_networking_host = mkDefOpt types.str "localhost" '' 664 + The host to use if the container is in host networking mode. 665 + ''; 666 + }; 667 + 668 + promTypes.dockerswarm_sd_config = mkDockerSdConfigModule { 669 + role = mkOption { 670 + type = types.enum [ "services" "tasks" "nodes" ]; 671 + description = '' 672 + Role of the targets to retrieve. Must be `services`, `tasks`, or `nodes`. 673 + ''; 674 + }; 675 + }; 676 + 677 + promTypes.dns_sd_config = types.submodule { 678 + options = { 679 + names = mkOption { 680 + type = types.listOf types.str; 438 681 description = '' 439 - Labels assigned to all metrics scraped from the targets. 682 + A list of DNS SRV record names to be queried. 440 683 ''; 441 684 }; 685 + 686 + type = mkDefOpt (types.enum [ "SRV" "A" "AAAA" ]) "SRV" '' 687 + The type of DNS query to perform. One of SRV, A, or AAAA. 688 + ''; 689 + 690 + port = mkOpt types.int '' 691 + The port number used if the query type is not SRV. 692 + ''; 693 + 694 + refresh_interval = mkDefOpt types.str "30s" '' 695 + The time after which the provided names are refreshed. 696 + ''; 442 697 }; 443 698 }; 444 699 ··· 447 702 region = mkOption { 448 703 type = types.str; 449 704 description = '' 450 - The AWS Region. 705 + The AWS Region. If blank, the region from the instance metadata is used. 451 706 ''; 452 707 }; 453 708 endpoint = mkOpt types.str '' ··· 464 719 <literal>AWS_SECRET_ACCESS_KEY</literal> is used. 465 720 ''; 466 721 467 - profile = mkOpt types.str '' 722 + profile = mkOpt types.str '' 468 723 Named AWS profile used to connect to the API. 469 724 ''; 470 725 ··· 482 737 rule. 483 738 ''; 484 739 485 - filters = mkOpt (types.listOf promTypes.filter) '' 740 + filters = mkOpt 741 + (types.listOf (types.submodule { 742 + options = { 743 + name = mkOption { 744 + type = types.str; 745 + description = '' 746 + See <link xlink:href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html">this list</link> 747 + for the available filters. 748 + ''; 749 + }; 750 + 751 + values = mkOption { 752 + type = types.listOf types.str; 753 + default = [ ]; 754 + description = '' 755 + Value of the filter. 756 + ''; 757 + }; 758 + }; 759 + })) '' 486 760 Filters can be used optionally to filter the instance list by other criteria. 487 761 ''; 488 762 }; 489 763 }; 490 764 491 - promTypes.filter = types.submodule { 765 + promTypes.eureka_sd_config = mkSdConfigModule { 766 + server = mkOption { 767 + type = types.str; 768 + description = '' 769 + The URL to connect to the Eureka server. 770 + ''; 771 + }; 772 + }; 773 + 774 + promTypes.file_sd_config = types.submodule { 492 775 options = { 493 - name = mkOption { 776 + files = mkOption { 777 + type = types.listOf types.str; 778 + description = '' 779 + Patterns for files from which target groups are extracted. Refer 780 + to the Prometheus documentation for permitted filename patterns 781 + and formats. 782 + ''; 783 + }; 784 + 785 + refresh_interval = mkDefOpt types.str "5m" '' 786 + Refresh interval to re-read the files. 787 + ''; 788 + }; 789 + }; 790 + 791 + promTypes.gce_sd_config = types.submodule { 792 + options = { 793 + # Use `mkOption` instead of `mkOpt` for project and zone because they are 794 + # required configuration values for `gce_sd_config`. 795 + project = mkOption { 494 796 type = types.str; 495 797 description = '' 496 - See <link xlink:href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html">this list</link> 497 - for the available filters. 798 + The GCP Project. 498 799 ''; 499 800 }; 500 801 501 - values = mkOption { 502 - type = types.listOf types.str; 503 - default = []; 802 + zone = mkOption { 803 + type = types.str; 504 804 description = '' 505 - Value of the filter. 805 + The zone of the scrape targets. If you need multiple zones use multiple 806 + gce_sd_configs. 506 807 ''; 507 808 }; 809 + 810 + filter = mkOpt types.str '' 811 + Filter can be used optionally to filter the instance list by other 812 + criteria Syntax of this filter string is described here in the filter 813 + query parameter section: <link 814 + xlink:href="https://cloud.google.com/compute/docs/reference/latest/instances/list" 815 + />. 816 + ''; 817 + 818 + refresh_interval = mkDefOpt types.str "60s" '' 819 + Refresh interval to re-read the cloud instance list. 820 + ''; 821 + 822 + port = mkDefOpt types.port "80" '' 823 + The port to scrape metrics from. If using the public IP address, this 824 + must instead be specified in the relabeling rule. 825 + ''; 826 + 827 + tag_separator = mkDefOpt types.str "," '' 828 + The tag separator used to separate concatenated GCE instance network tags. 829 + 830 + See the GCP documentation on network tags for more information: 831 + <link xlink:href="https://cloud.google.com/vpc/docs/add-remove-network-tags" /> 832 + ''; 508 833 }; 509 834 }; 510 835 511 - promTypes.dns_sd_config = types.submodule { 836 + promTypes.hetzner_sd_config = mkSdConfigModule { 837 + role = mkOption { 838 + type = types.enum [ "robot" "hcloud" ]; 839 + description = '' 840 + The Hetzner role of entities that should be discovered. 841 + One of <literal>robot</literal> or <literal>hcloud</literal>. 842 + ''; 843 + }; 844 + 845 + port = mkDefOpt types.int "80" '' 846 + The port to scrape metrics from. 847 + ''; 848 + 849 + refresh_interval = mkDefOpt types.str "60s" '' 850 + The time after which the servers are refreshed. 851 + ''; 852 + }; 853 + 854 + promTypes.http_sd_config = types.submodule { 512 855 options = { 513 - names = mkOption { 514 - type = types.listOf types.str; 856 + url = mkOption { 857 + type = types.str; 515 858 description = '' 516 - A list of DNS SRV record names to be queried. 859 + URL from which the targets are fetched. 517 860 ''; 518 861 }; 519 862 520 - refresh_interval = mkDefOpt types.str "30s" '' 521 - The time after which the provided names are refreshed. 863 + refresh_interval = mkDefOpt types.str "60s" '' 864 + Refresh interval to re-query the endpoint. 865 + ''; 866 + 867 + basic_auth = mkOpt promTypes.basic_auth '' 868 + Authentication information used to authenticate to the API server. 869 + password and password_file are mutually exclusive. 870 + ''; 871 + 872 + proxy_url = mkOpt types.str '' 873 + Optional proxy URL. 874 + ''; 875 + 876 + follow_redirects = mkDefOpt types.bool "true" '' 877 + Configure whether HTTP requests follow HTTP 3xx redirects. 878 + ''; 879 + 880 + tls_config = mkOpt promTypes.tls_config '' 881 + Configures the scrape request's TLS settings. 522 882 ''; 523 883 }; 524 884 }; 525 885 526 - promTypes.consul_sd_config = types.submodule { 527 - options = { 528 - server = mkDefOpt types.str "localhost:8500" '' 529 - Consul server to query. 886 + promTypes.kubernetes_sd_config = mkSdConfigModule { 887 + api_server = mkOpt types.str '' 888 + The API server addresses. If left empty, Prometheus is assumed to run inside 889 + of the cluster and will discover API servers automatically and use the pod's 890 + CA certificate and bearer token file at /var/run/secrets/kubernetes.io/serviceaccount/. 891 + ''; 892 + 893 + role = mkOption { 894 + type = types.enum [ "endpoints" "service" "pod" "node" "ingress" ]; 895 + description = '' 896 + The Kubernetes role of entities that should be discovered. 897 + One of endpoints, service, pod, node, or ingress. 530 898 ''; 899 + }; 531 900 532 - token = mkOpt types.str "Consul token"; 901 + kubeconfig_file = mkOpt types.str '' 902 + Optional path to a kubeconfig file. 903 + Note that api_server and kube_config are mutually exclusive. 904 + ''; 533 905 534 - datacenter = mkOpt types.str "Consul datacenter"; 906 + namespaces = mkOpt 907 + ( 908 + types.submodule { 909 + options = { 910 + names = mkOpt (types.listOf types.str) '' 911 + Namespace name. 912 + ''; 913 + }; 914 + } 915 + ) '' 916 + Optional namespace discovery. If omitted, all namespaces are used. 917 + ''; 535 918 536 - scheme = mkDefOpt types.str "http" "Consul scheme"; 919 + selectors = mkOpt 920 + ( 921 + types.listOf ( 922 + types.submodule { 923 + options = { 924 + role = mkOption { 925 + type = types.str; 926 + description = '' 927 + Selector role 928 + ''; 929 + }; 537 930 538 - username = mkOpt types.str "Consul username"; 931 + label = mkOpt types.str '' 932 + Selector label 933 + ''; 539 934 540 - password = mkOpt types.str "Consul password"; 935 + field = mkOpt types.str '' 936 + Selector field 937 + ''; 938 + }; 939 + } 940 + ) 941 + ) '' 942 + Optional label and field selectors to limit the discovery process to a subset of available resources. 943 + See https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/ 944 + and https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ to learn more about the possible 945 + filters that can be used. Endpoints role supports pod, service and endpoints selectors, other roles 946 + only support selectors matching the role itself (e.g. node role can only contain node selectors). 541 947 542 - tls_config = mkOpt promTypes.tls_config '' 543 - Configures the Consul request's TLS settings. 948 + Note: When making decision about using field/label selector make sure that this 949 + is the best approach - it will prevent Prometheus from reusing single list/watch 950 + for all scrape configs. This might result in a bigger load on the Kubernetes API, 951 + because per each selector combination there will be additional LIST/WATCH. On the other hand, 952 + if you just want to monitor small subset of pods in large cluster it's recommended to use selectors. 953 + Decision, if selectors should be used or not depends on the particular situation. 954 + ''; 955 + }; 956 + 957 + promTypes.kuma_sd_config = mkSdConfigModule { 958 + server = mkOption { 959 + type = types.str; 960 + description = '' 961 + Address of the Kuma Control Plane's MADS xDS server. 962 + ''; 963 + }; 964 + 965 + refresh_interval = mkDefOpt types.str "30s" '' 966 + The time to wait between polling update requests. 967 + ''; 968 + 969 + fetch_timeout = mkDefOpt types.str "2m" '' 970 + The time after which the monitoring assignments are refreshed. 971 + ''; 972 + }; 973 + 974 + promTypes.lightsail_sd_config = types.submodule { 975 + options = { 976 + region = mkOpt types.str '' 977 + The AWS region. If blank, the region from the instance metadata is used. 544 978 ''; 545 979 546 - services = mkOpt (types.listOf types.str) '' 547 - A list of services for which targets are retrieved. 980 + endpoint = mkOpt types.str '' 981 + Custom endpoint to be used. 982 + ''; 983 + 984 + access_key = mkOpt types.str '' 985 + The AWS API keys. If blank, the environment variable <literal>AWS_ACCESS_KEY_ID</literal> is used. 548 986 ''; 549 987 550 - tags = mkOpt (types.listOf types.str) '' 551 - An optional list of tags used to filter nodes for a given 552 - service. Services must contain all tags in the list. 988 + secret_key = mkOpt types.str '' 989 + The AWS API keys. If blank, the environment variable <literal>AWS_SECRET_ACCESS_KEY</literal> is used. 553 990 ''; 554 991 555 - node_meta = mkOpt (types.attrsOf types.str) '' 556 - Node metadata used to filter nodes for a given service. 992 + profile = mkOpt types.str '' 993 + Named AWS profile used to connect to the API. 557 994 ''; 558 995 559 - tag_separator = mkDefOpt types.str "," '' 560 - The string by which Consul tags are joined into the tag label. 996 + role_arn = mkOpt types.str '' 997 + AWS Role ARN, an alternative to using AWS API keys. 561 998 ''; 562 999 563 - allow_stale = mkOpt types.bool '' 564 - Allow stale Consul results 565 - (see <link xlink:href="https://www.consul.io/api/index.html#consistency-modes"/>). 1000 + refresh_interval = mkDefOpt types.str "60s" '' 1001 + Refresh interval to re-read the instance list. 1002 + ''; 566 1003 567 - Will reduce load on Consul. 1004 + port = mkDefOpt types.int "80" '' 1005 + The port to scrape metrics from. If using the public IP address, this must 1006 + instead be specified in the relabeling rule. 568 1007 ''; 1008 + }; 1009 + }; 569 1010 570 - refresh_interval = mkDefOpt types.str "30s" '' 571 - The time after which the provided names are refreshed. 1011 + promTypes.linode_sd_config = mkSdConfigModule { 1012 + port = mkDefOpt types.int "80" '' 1013 + The port to scrape metrics from. 1014 + ''; 572 1015 573 - On large setup it might be a good idea to increase this value 574 - because the catalog will change all the time. 1016 + tag_separator = mkDefOpt types.str "," '' 1017 + The string by which Linode Instance tags are joined into the tag label. 1018 + ''; 1019 + 1020 + refresh_interval = mkDefOpt types.str "60s" '' 1021 + The time after which the linode instances are refreshed. 1022 + ''; 1023 + }; 1024 + 1025 + promTypes.marathon_sd_config = mkSdConfigModule { 1026 + servers = mkOption { 1027 + type = types.listOf types.str; 1028 + description = '' 1029 + List of URLs to be used to contact Marathon servers. You need to provide at least one server URL. 575 1030 ''; 576 1031 }; 1032 + 1033 + refresh_interval = mkDefOpt types.str "30s" '' 1034 + Polling interval. 1035 + ''; 1036 + 1037 + auth_token = mkOpt types.str '' 1038 + Optional authentication information for token-based authentication: 1039 + <link xlink:href="https://docs.mesosphere.com/1.11/security/ent/iam-api/#passing-an-authentication-token" /> 1040 + It is mutually exclusive with <literal>auth_token_file</literal> and other authentication mechanisms. 1041 + ''; 1042 + 1043 + auth_token_file = mkOpt types.str '' 1044 + Optional authentication information for token-based authentication: 1045 + <link xlink:href="https://docs.mesosphere.com/1.11/security/ent/iam-api/#passing-an-authentication-token" /> 1046 + It is mutually exclusive with <literal>auth_token</literal> and other authentication mechanisms. 1047 + ''; 577 1048 }; 578 1049 579 - promTypes.file_sd_config = types.submodule { 1050 + promTypes.nerve_sd_config = types.submodule { 580 1051 options = { 581 - files = mkOption { 1052 + servers = mkOption { 1053 + type = types.listOf types.str; 1054 + description = '' 1055 + The Zookeeper servers. 1056 + ''; 1057 + }; 1058 + 1059 + paths = mkOption { 582 1060 type = types.listOf types.str; 583 1061 description = '' 584 - Patterns for files from which target groups are extracted. Refer 585 - to the Prometheus documentation for permitted filename patterns 586 - and formats. 1062 + Paths can point to a single service, or the root of a tree of services. 1063 + ''; 1064 + }; 1065 + 1066 + timeout = mkDefOpt types.str "10s" '' 1067 + Timeout value. 1068 + ''; 1069 + }; 1070 + }; 1071 + 1072 + promTypes.openstack_sd_config = types.submodule { 1073 + options = 1074 + let 1075 + userDescription = '' 1076 + username is required if using Identity V2 API. Consult with your provider's 1077 + control panel to discover your account's username. In Identity V3, either 1078 + userid or a combination of username and domain_id or domain_name are needed. 1079 + ''; 1080 + 1081 + domainDescription = '' 1082 + At most one of domain_id and domain_name must be provided if using username 1083 + with Identity V3. Otherwise, either are optional. 1084 + ''; 1085 + 1086 + projectDescription = '' 1087 + The project_id and project_name fields are optional for the Identity V2 API. 1088 + Some providers allow you to specify a project_name instead of the project_id. 1089 + Some require both. Your provider's authentication policies will determine 1090 + how these fields influence authentication. 1091 + ''; 1092 + 1093 + applicationDescription = '' 1094 + The application_credential_id or application_credential_name fields are 1095 + required if using an application credential to authenticate. Some providers 1096 + allow you to create an application credential to authenticate rather than a 1097 + password. 1098 + ''; 1099 + in 1100 + { 1101 + role = mkOption { 1102 + type = types.str; 1103 + description = '' 1104 + The OpenStack role of entities that should be discovered. 1105 + ''; 1106 + }; 1107 + 1108 + region = mkOption { 1109 + type = types.str; 1110 + description = '' 1111 + The OpenStack Region. 1112 + ''; 1113 + }; 1114 + 1115 + identity_endpoint = mkOpt types.str '' 1116 + identity_endpoint specifies the HTTP endpoint that is required to work with 1117 + the Identity API of the appropriate version. While it's ultimately needed by 1118 + all of the identity services, it will often be populated by a provider-level 1119 + function. 1120 + ''; 1121 + 1122 + username = mkOpt types.str userDescription; 1123 + userid = mkOpt types.str userDescription; 1124 + 1125 + password = mkOpt types.str '' 1126 + password for the Identity V2 and V3 APIs. Consult with your provider's 1127 + control panel to discover your account's preferred method of authentication. 1128 + ''; 1129 + 1130 + domain_name = mkOpt types.str domainDescription; 1131 + domain_id = mkOpt types.str domainDescription; 1132 + 1133 + project_name = mkOpt types.str projectDescription; 1134 + project_id = mkOpt types.str projectDescription; 1135 + 1136 + application_credential_name = mkOpt types.str applicationDescription; 1137 + application_credential_id = mkOpt types.str applicationDescription; 1138 + 1139 + application_credential_secret = mkOpt types.str '' 1140 + The application_credential_secret field is required if using an application 1141 + credential to authenticate. 1142 + ''; 1143 + 1144 + all_tenants = mkDefOpt types.bool "false" '' 1145 + Whether the service discovery should list all instances for all projects. 1146 + It is only relevant for the 'instance' role and usually requires admin permissions. 1147 + ''; 1148 + 1149 + refresh_interval = mkDefOpt types.str "60s" '' 1150 + Refresh interval to re-read the instance list. 1151 + ''; 1152 + 1153 + port = mkDefOpt types.int "80" '' 1154 + The port to scrape metrics from. If using the public IP address, this must 1155 + instead be specified in the relabeling rule. 1156 + ''; 1157 + 1158 + availability = mkDefOpt (types.enum [ "public" "admin" "internal" ]) "public" '' 1159 + The availability of the endpoint to connect to. Must be one of public, admin or internal. 1160 + ''; 1161 + 1162 + tls_config = mkOpt promTypes.tls_config '' 1163 + TLS configuration. 587 1164 ''; 588 1165 }; 1166 + }; 589 1167 590 - refresh_interval = mkDefOpt types.str "5m" '' 591 - Refresh interval to re-read the files. 1168 + promTypes.puppetdb_sd_config = mkSdConfigModule { 1169 + url = mkOption { 1170 + type = types.str; 1171 + description = '' 1172 + The URL of the PuppetDB root query endpoint. 592 1173 ''; 593 1174 }; 1175 + 1176 + query = mkOption { 1177 + type = types.str; 1178 + description = '' 1179 + Puppet Query Language (PQL) query. Only resources are supported. 1180 + https://puppet.com/docs/puppetdb/latest/api/query/v4/pql.html 1181 + ''; 1182 + }; 1183 + 1184 + include_parameters = mkDefOpt types.bool "false" '' 1185 + Whether to include the parameters as meta labels. 1186 + Due to the differences between parameter types and Prometheus labels, 1187 + some parameters might not be rendered. The format of the parameters might 1188 + also change in future releases. 1189 + 1190 + Note: Enabling this exposes parameters in the Prometheus UI and API. Make sure 1191 + that you don't have secrets exposed as parameters if you enable this. 1192 + ''; 1193 + 1194 + refresh_interval = mkDefOpt types.str "60s" '' 1195 + Refresh interval to re-read the resources list. 1196 + ''; 1197 + 1198 + port = mkDefOpt types.int "80" '' 1199 + The port to scrape metrics from. 1200 + ''; 594 1201 }; 595 1202 596 - promTypes.gce_sd_config = types.submodule { 1203 + promTypes.scaleway_sd_config = types.submodule { 597 1204 options = { 598 - # Use `mkOption` instead of `mkOpt` for project and zone because they are 599 - # required configuration values for `gce_sd_config`. 600 - project = mkOption { 1205 + access_key = mkOption { 601 1206 type = types.str; 602 1207 description = '' 603 - The GCP Project. 1208 + Access key to use. https://console.scaleway.com/project/credentials 604 1209 ''; 605 1210 }; 606 1211 607 - zone = mkOption { 1212 + secret_key = mkOpt types.str '' 1213 + Secret key to use when listing targets. https://console.scaleway.com/project/credentials 1214 + It is mutually exclusive with `secret_key_file`. 1215 + ''; 1216 + 1217 + secret_key_file = mkOpt types.str '' 1218 + Sets the secret key with the credentials read from the configured file. 1219 + It is mutually exclusive with `secret_key`. 1220 + ''; 1221 + 1222 + project_id = mkOption { 608 1223 type = types.str; 609 1224 description = '' 610 - The zone of the scrape targets. If you need multiple zones use multiple 611 - gce_sd_configs. 1225 + Project ID of the targets. 1226 + ''; 1227 + }; 1228 + 1229 + role = mkOption { 1230 + type = types.enum [ "instance" "baremetal" ]; 1231 + description = '' 1232 + Role of the targets to retrieve. Must be `instance` or `baremetal`. 612 1233 ''; 613 1234 }; 614 1235 615 - filter = mkOpt types.str '' 616 - Filter can be used optionally to filter the instance list by other 617 - criteria Syntax of this filter string is described here in the filter 618 - query parameter section: <link 619 - xlink:href="https://cloud.google.com/compute/docs/reference/latest/instances/list" 620 - />. 1236 + port = mkDefOpt types.int "80" '' 1237 + The port to scrape metrics from. 1238 + ''; 1239 + 1240 + api_url = mkDefOpt types.str "https://api.scaleway.com" '' 1241 + API URL to use when doing the server listing requests. 1242 + ''; 1243 + 1244 + zone = mkDefOpt types.str "fr-par-1" '' 1245 + Zone is the availability zone of your targets (e.g. fr-par-1). 1246 + ''; 1247 + 1248 + name_filter = mkOpt types.str '' 1249 + Specify a name filter (works as a LIKE) to apply on the server listing request. 1250 + ''; 1251 + 1252 + tags_filter = mkOpt (types.listOf types.str) '' 1253 + Specify a tag filter (a server needs to have all defined tags to be listed) to apply on the server listing request. 621 1254 ''; 622 1255 623 1256 refresh_interval = mkDefOpt types.str "60s" '' 624 - Refresh interval to re-read the cloud instance list. 1257 + Refresh interval to re-read the managed targets list. 625 1258 ''; 626 1259 627 - port = mkDefOpt types.port "80" '' 628 - The port to scrape metrics from. If using the public IP address, this 629 - must instead be specified in the relabeling rule. 1260 + proxy_url = mkOpt types.str '' 1261 + Optional proxy URL. 630 1262 ''; 631 1263 632 - tag_separator = mkDefOpt types.str "," '' 633 - The tag separator used to separate concatenated GCE instance network tags. 1264 + follow_redirects = mkDefOpt types.bool "true" '' 1265 + Configure whether HTTP requests follow HTTP 3xx redirects. 1266 + ''; 634 1267 635 - See the GCP documentation on network tags for more information: <link 636 - xlink:href="https://cloud.google.com/vpc/docs/add-remove-network-tags" 637 - /> 1268 + tls_config = mkOpt promTypes.tls_config '' 1269 + TLS configuration. 638 1270 ''; 639 1271 }; 640 1272 }; 641 1273 1274 + # These are exactly the same. 1275 + promTypes.serverset_sd_config = promTypes.nerve_sd_config; 1276 + 1277 + promTypes.triton_sd_config = types.submodule { 1278 + options = { 1279 + account = mkOption { 1280 + type = types.str; 1281 + description = '' 1282 + The account to use for discovering new targets. 1283 + ''; 1284 + }; 1285 + 1286 + role = mkDefOpt (types.enum [ "container" "cn" ]) "container" '' 1287 + The type of targets to discover, can be set to: 1288 + - "container" to discover virtual machines (SmartOS zones, lx/KVM/bhyve branded zones) running on Triton 1289 + - "cn" to discover compute nodes (servers/global zones) making up the Triton infrastructure 1290 + ''; 1291 + 1292 + dns_suffix = mkOption { 1293 + type = types.str; 1294 + description = '' 1295 + The DNS suffix which should be applied to target. 1296 + ''; 1297 + }; 1298 + 1299 + endpoint = mkOption { 1300 + type = types.str; 1301 + description = '' 1302 + The Triton discovery endpoint (e.g. <literal>cmon.us-east-3b.triton.zone</literal>). This is 1303 + often the same value as dns_suffix. 1304 + ''; 1305 + }; 1306 + 1307 + groups = mkOpt (types.listOf types.str) '' 1308 + A list of groups for which targets are retrieved, only supported when targeting the <literal>container</literal> role. 1309 + If omitted all containers owned by the requesting account are scraped. 1310 + ''; 1311 + 1312 + port = mkDefOpt types.int "9163" '' 1313 + The port to use for discovery and metric scraping. 1314 + ''; 1315 + 1316 + refresh_interval = mkDefOpt types.str "60s" '' 1317 + The interval which should be used for refreshing targets. 1318 + ''; 1319 + 1320 + version = mkDefOpt types.int "1" '' 1321 + The Triton discovery API version. 1322 + ''; 1323 + 1324 + tls_config = mkOpt promTypes.tls_config '' 1325 + TLS configuration. 1326 + ''; 1327 + }; 1328 + }; 1329 + 1330 + promTypes.uyuni_sd_config = mkSdConfigModule { 1331 + server = mkOption { 1332 + type = types.str; 1333 + description = '' 1334 + The URL to connect to the Uyuni server. 1335 + ''; 1336 + }; 1337 + 1338 + username = mkOption { 1339 + type = types.str; 1340 + description = '' 1341 + Credentials are used to authenticate the requests to Uyuni API. 1342 + ''; 1343 + }; 1344 + 1345 + password = mkOption { 1346 + type = types.str; 1347 + description = '' 1348 + Credentials are used to authenticate the requests to Uyuni API. 1349 + ''; 1350 + }; 1351 + 1352 + entitlement = mkDefOpt types.str "monitoring_entitled" '' 1353 + The entitlement string to filter eligible systems. 1354 + ''; 1355 + 1356 + separator = mkDefOpt types.str "," '' 1357 + The string by which Uyuni group names are joined into the groups label 1358 + ''; 1359 + 1360 + refresh_interval = mkDefOpt types.str "60s" '' 1361 + Refresh interval to re-read the managed targets list. 1362 + ''; 1363 + }; 1364 + 1365 + promTypes.static_config = types.submodule { 1366 + options = { 1367 + targets = mkOption { 1368 + type = types.listOf types.str; 1369 + description = '' 1370 + The targets specified by the target group. 1371 + ''; 1372 + }; 1373 + labels = mkOption { 1374 + type = types.attrsOf types.str; 1375 + default = { }; 1376 + description = '' 1377 + Labels assigned to all metrics scraped from the targets. 1378 + ''; 1379 + }; 1380 + }; 1381 + }; 1382 + 1383 + # 1384 + # Config types: relabling 1385 + # 1386 + 642 1387 promTypes.relabel_config = types.submodule { 643 1388 options = { 644 1389 source_labels = mkOpt (types.listOf types.str) '' ··· 670 1415 ''; 671 1416 672 1417 action = 673 - mkDefOpt (types.enum ["replace" "keep" "drop" "hashmod" "labelmap" "labeldrop" "labelkeep"]) "replace" '' 674 - Action to perform based on regex matching. 1418 + mkDefOpt (types.enum [ "replace" "keep" "drop" "hashmod" "labelmap" "labeldrop" "labelkeep" ]) "replace" '' 1419 + Action to perform based on regex matching. 1420 + ''; 1421 + }; 1422 + }; 1423 + 1424 + # 1425 + # Config types : remote read / write 1426 + # 1427 + 1428 + promTypes.remote_write = types.submodule { 1429 + options = { 1430 + url = mkOption { 1431 + type = types.str; 1432 + description = '' 1433 + ServerName extension to indicate the name of the server. 1434 + http://tools.ietf.org/html/rfc4366#section-3.1 1435 + ''; 1436 + }; 1437 + remote_timeout = mkOpt types.str '' 1438 + Timeout for requests to the remote write endpoint. 1439 + ''; 1440 + write_relabel_configs = mkOpt (types.listOf promTypes.relabel_config) '' 1441 + List of remote write relabel configurations. 1442 + ''; 1443 + name = mkOpt types.str '' 1444 + Name of the remote write config, which if specified must be unique among remote write configs. 1445 + The name will be used in metrics and logging in place of a generated value to help users distinguish between 1446 + remote write configs. 1447 + ''; 1448 + basic_auth = mkOpt promTypes.basic_auth '' 1449 + Sets the `Authorization` header on every remote write request with the 1450 + configured username and password. 1451 + password and password_file are mutually exclusive. 1452 + ''; 1453 + bearer_token = mkOpt types.str '' 1454 + Sets the `Authorization` header on every remote write request with 1455 + the configured bearer token. It is mutually exclusive with `bearer_token_file`. 1456 + ''; 1457 + bearer_token_file = mkOpt types.str '' 1458 + Sets the `Authorization` header on every remote write request with the bearer token 1459 + read from the configured file. It is mutually exclusive with `bearer_token`. 1460 + ''; 1461 + tls_config = mkOpt promTypes.tls_config '' 1462 + Configures the remote write request's TLS settings. 1463 + ''; 1464 + proxy_url = mkOpt types.str "Optional Proxy URL."; 1465 + queue_config = mkOpt 1466 + (types.submodule { 1467 + options = { 1468 + capacity = mkOpt types.int '' 1469 + Number of samples to buffer per shard before we block reading of more 1470 + samples from the WAL. It is recommended to have enough capacity in each 1471 + shard to buffer several requests to keep throughput up while processing 1472 + occasional slow remote requests. 1473 + ''; 1474 + max_shards = mkOpt types.int '' 1475 + Maximum number of shards, i.e. amount of concurrency. 1476 + ''; 1477 + min_shards = mkOpt types.int '' 1478 + Minimum number of shards, i.e. amount of concurrency. 1479 + ''; 1480 + max_samples_per_send = mkOpt types.int '' 1481 + Maximum number of samples per send. 1482 + ''; 1483 + batch_send_deadline = mkOpt types.str '' 1484 + Maximum time a sample will wait in buffer. 1485 + ''; 1486 + min_backoff = mkOpt types.str '' 1487 + Initial retry delay. Gets doubled for every retry. 1488 + ''; 1489 + max_backoff = mkOpt types.str '' 1490 + Maximum retry delay. 1491 + ''; 1492 + }; 1493 + }) '' 1494 + Configures the queue used to write to remote storage. 1495 + ''; 1496 + metadata_config = mkOpt 1497 + (types.submodule { 1498 + options = { 1499 + send = mkOpt types.bool '' 1500 + Whether metric metadata is sent to remote storage or not. 1501 + ''; 1502 + send_interval = mkOpt types.str '' 1503 + How frequently metric metadata is sent to remote storage. 1504 + ''; 1505 + }; 1506 + }) '' 1507 + Configures the sending of series metadata to remote storage. 1508 + Metadata configuration is subject to change at any point 1509 + or be removed in future releases. 675 1510 ''; 676 1511 }; 677 1512 }; 678 1513 679 - promTypes.tls_config = types.submodule { 1514 + promTypes.remote_read = types.submodule { 680 1515 options = { 681 - ca_file = mkOpt types.str '' 682 - CA certificate to validate API server certificate with. 1516 + url = mkOption { 1517 + type = types.str; 1518 + description = '' 1519 + ServerName extension to indicate the name of the server. 1520 + http://tools.ietf.org/html/rfc4366#section-3.1 1521 + ''; 1522 + }; 1523 + name = mkOpt types.str '' 1524 + Name of the remote read config, which if specified must be unique among remote read configs. 1525 + The name will be used in metrics and logging in place of a generated value to help users distinguish between 1526 + remote read configs. 683 1527 ''; 684 - 685 - cert_file = mkOpt types.str '' 686 - Certificate file for client cert authentication to the server. 1528 + required_matchers = mkOpt (types.attrsOf types.str) '' 1529 + An optional list of equality matchers which have to be 1530 + present in a selector to query the remote read endpoint. 687 1531 ''; 688 - 689 - key_file = mkOpt types.str '' 690 - Key file for client cert authentication to the server. 1532 + remote_timeout = mkOpt types.str '' 1533 + Timeout for requests to the remote read endpoint. 691 1534 ''; 692 - 693 - server_name = mkOpt types.str '' 694 - ServerName extension to indicate the name of the server. 695 - http://tools.ietf.org/html/rfc4366#section-3.1 1535 + read_recent = mkOpt types.bool '' 1536 + Whether reads should be made for queries for time ranges that 1537 + the local storage should have complete data for. 696 1538 ''; 697 - 698 - insecure_skip_verify = mkOpt types.bool '' 699 - Disable validation of the server certificate. 1539 + basic_auth = mkOpt promTypes.basic_auth '' 1540 + Sets the `Authorization` header on every remote read request with the 1541 + configured username and password. 1542 + password and password_file are mutually exclusive. 700 1543 ''; 1544 + bearer_token = mkOpt types.str '' 1545 + Sets the `Authorization` header on every remote read request with 1546 + the configured bearer token. It is mutually exclusive with `bearer_token_file`. 1547 + ''; 1548 + bearer_token_file = mkOpt types.str '' 1549 + Sets the `Authorization` header on every remote read request with the bearer token 1550 + read from the configured file. It is mutually exclusive with `bearer_token`. 1551 + ''; 1552 + tls_config = mkOpt promTypes.tls_config '' 1553 + Configures the remote read request's TLS settings. 1554 + ''; 1555 + proxy_url = mkOpt types.str "Optional Proxy URL."; 701 1556 }; 702 1557 }; 703 1558 704 - in { 1559 + in 1560 + { 705 1561 706 1562 imports = [ 707 1563 (mkRenamedOptionModule [ "services" "prometheus2" ] [ "services" "prometheus" ]) ··· 753 1609 754 1610 extraFlags = mkOption { 755 1611 type = types.listOf types.str; 756 - default = []; 1612 + default = [ ]; 757 1613 description = '' 758 1614 Extra commandline options when launching Prometheus. 759 1615 ''; ··· 829 1685 830 1686 globalConfig = mkOption { 831 1687 type = promTypes.globalConfig; 832 - default = {}; 1688 + default = { }; 833 1689 description = '' 834 1690 Parameters that are valid in all configuration contexts. They 835 1691 also serve as defaults for other configuration sections ··· 838 1694 839 1695 remoteRead = mkOption { 840 1696 type = types.listOf promTypes.remote_read; 841 - default = []; 1697 + default = [ ]; 842 1698 description = '' 843 1699 Parameters of the endpoints to query from. 844 1700 See <link xlink:href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_read">the official documentation</link> for more information. ··· 847 1703 848 1704 remoteWrite = mkOption { 849 1705 type = types.listOf promTypes.remote_write; 850 - default = []; 1706 + default = [ ]; 851 1707 description = '' 852 1708 Parameters of the endpoints to send samples to. 853 1709 See <link xlink:href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#remote_write">the official documentation</link> for more information. ··· 856 1712 857 1713 rules = mkOption { 858 1714 type = types.listOf types.str; 859 - default = []; 1715 + default = [ ]; 860 1716 description = '' 861 1717 Alerting and/or Recording rules to evaluate at runtime. 862 1718 ''; ··· 864 1720 865 1721 ruleFiles = mkOption { 866 1722 type = types.listOf types.path; 867 - default = []; 1723 + default = [ ]; 868 1724 description = '' 869 1725 Any additional rules files to include in this configuration. 870 1726 ''; ··· 872 1728 873 1729 scrapeConfigs = mkOption { 874 1730 type = types.listOf promTypes.scrape_config; 875 - default = []; 1731 + default = [ ]; 876 1732 description = '' 877 1733 A list of scrape configurations. 878 1734 ''; ··· 891 1747 } ]; 892 1748 } ] 893 1749 ''; 894 - default = []; 1750 + default = [ ]; 895 1751 description = '' 896 1752 A list of alertmanagers to send alerts to. 897 1753 See <link xlink:href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alertmanager_config">the official documentation</link> for more information. ··· 950 1806 951 1807 config = mkIf cfg.enable { 952 1808 assertions = [ 953 - ( let 1809 + ( 1810 + let 954 1811 # Match something with dots (an IPv4 address) or something ending in 955 1812 # a square bracket (an IPv6 addresses) followed by a port number. 956 1813 legacy = builtins.match "(.*\\..*|.*]):([[:digit:]]+)" cfg.listenAddress; 957 - in { 1814 + in 1815 + { 958 1816 assertion = legacy == null; 959 1817 message = '' 960 1818 Do not specify the port for Prometheus to listen on in the ··· 974 1832 }; 975 1833 systemd.services.prometheus = { 976 1834 wantedBy = [ "multi-user.target" ]; 977 - after = [ "network.target" ]; 1835 + after = [ "network.target" ]; 978 1836 preStart = mkIf (!cfg.enableReload) '' 979 - ${lib.getBin pkgs.envsubst}/bin/envsubst -o "/run/prometheus/prometheus-substituted.yaml" \ 980 - -i "${prometheusYml}" 1837 + ${lib.getBin pkgs.envsubst}/bin/envsubst -o "/run/prometheus/prometheus-substituted.yaml" \ 1838 + -i "${prometheusYml}" 981 1839 ''; 982 1840 serviceConfig = { 983 1841 ExecStart = "${cfg.package}/bin/prometheus" + ··· 985 1843 concatStringsSep " \\\n " cmdlineArgs); 986 1844 ExecReload = mkIf cfg.enableReload "+${reload}/bin/reload-prometheus"; 987 1845 User = "prometheus"; 988 - Restart = "always"; 1846 + Restart = "always"; 989 1847 EnvironmentFile = mkIf (cfg.environmentFile != null && !cfg.enableReload) [ cfg.environmentFile ]; 990 1848 RuntimeDirectory = "prometheus"; 991 1849 RuntimeDirectoryMode = "0700";