{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "http://json.schemastore.org/prometheus",
    "title": "Prometheus",
    "description": "Prometheus configuration file",
    "type": [
        "object",
        "null"
    ],
    "properties": {
        "global": {
            "description": "The global configuration specifies parameters that are valid in all other configuration contexts. They also serve as defaults for other configuration sections.",
            "type": [
                "object",
                "null"
            ],
            "properties": {
                "scrape_interval": {
                    "description": "How frequently to scrape targets by default.",
                    "$ref": "#/definitions/duration",
                    "default": "1m"
                },
                "scrape_timeout": {
                    "description": "How long until a scrape request times out.",
                    "$ref": "#/definitions/duration",
                    "default": "10s"
                },
                "evaluation_interval": {
                    "description": "How frequently to evaluate rules.",
                    "$ref": "#/definitions/duration",
                    "default": "1m"
                },
                "external_labels": {
                    "description": "The labels to add to any time series or alerts when communicating with external systems (federation, remote storage, Alertmanager).",
                    "$ref": "#/definitions/labels"
                }
            },
            "additionalProperties": false
        },
        "rule_files": {
            "description": "Rule files specifies a list of globs. Rules and alerts are read from all matching files.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "$ref": "#/definitions/filepath_glob"
            }
        },
        "remote_write": {
            "description": "Settings related to the remote write feature.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object",
                "properties": {
                    "url": {
                        "description": "The URL of the endpoint to send samples to.",
                        "type": "string",
                        "format": "uri-reference"
                    },
                    "remote_timeout": {
                        "description": "Timeout for requests to the remote write endpoint.",
                        "$ref": "#/definitions/duration",
                        "default": "30s"
                    },
                    "write_relabel_configs": {
                        "description": "List of remote write relabel configurations.",
                        "$ref": "#/definitions/relabel_configs"
                    },
                    "basic_auth": {
                        "$ref": "#/definitions/basic_auth"
                    },
                    "bearer_token": {
                        "$ref": "#/definitions/bearer_token"
                    },
                    "bearer_token_file": {
                        "$ref": "#/definitions/bearer_token_file"
                    },
                    "tls_config": {
                        "description": "Configures the remote write request's TLS settings.",
                        "$ref": "#/definitions/tls_config"
                    },
                    "proxy_url": {
                        "description": "Optional proxy URL.",
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uri-reference"
                    },
                    "queue_config": {
                        "description": "Configures the queue used to write to remote storage.",
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "capacity": {
                                "description": "Number of samples to buffer per shard before we block reading of more samples from the WAL. It is recommended to have enough capacity in each shard to buffer several requests to keep throughput up while processing occasional slow remote requests.",
                                "type": [
                                    "integer",
                                    "null"
                                ],
                                "default": 500
                            },
                            "max_shards": {
                                "description": "Maximum number of shards, i.e. amount of concurrency.",
                                "type": [
                                    "integer",
                                    "null"
                                ],
                                "default": 1000
                            },
                            "min_shards": {
                                "description": "Minimum number of shards, i.e. amount of concurrency.",
                                "type": [
                                    "integer",
                                    "null"
                                ],
                                "default": 1
                            },
                            "max_samples_per_send": {
                                "description": "Maximum number of samples per send.",
                                "type": [
                                    "integer",
                                    "null"
                                ],
                                "default": 100
                            },
                            "batch_send_deadline": {
                                "description": "Maximum time a sample will wait in buffer.",
                                "$ref": "#/definitions/duration",
                                "default": "5s"
                            },
                            "min_backoff": {
                                "description": "Initial retry delay. Gets doubled for every retry.",
                                "$ref": "#/definitions/duration",
                                "default": "30ms"
                            },
                            "max_backoff": {
                                "description": "Maximum retry delay.",
                                "$ref": "#/definitions/duration",
                                "default": "100ms"
                            }
                        }
                    }
                },
                "allOf": [
                    {
                        "$ref": "#/definitions/auth"
                    }
                ],
                "additionalProperties": false,
                "required": [
                    "url"
                ]
            }
        },
        "remote_read": {
            "description": "Settings related to the remote read feature.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object",
                "properties": {
                    "url": {
                        "description": "The URL of the endpoint to query from.",
                        "type": "string",
                        "format": "uri-reference"
                    },
                    "required_matchers": {
                        "description": "An optional list of equality matchers which have to be present in a selector to query the remote read endpoint.",
                        "$ref": "#/definitions/labels"
                    },
                    "remote_timeout": {
                        "description": "Timeout for requests to the remote read endpoint.",
                        "$ref": "#/definitions/duration",
                        "default": "1m"
                    },
                    "read_recent": {
                        "description": "Whether reads should be made for queries for time ranges that the local storage should have complete data for.",
                        "type": [
                            "boolean",
                            "null"
                        ],
                        "default": false
                    },
                    "basic_auth": {
                        "$ref": "#/definitions/basic_auth"
                    },
                    "bearer_token": {
                        "$ref": "#/definitions/bearer_token"
                    },
                    "bearer_token_file": {
                        "$ref": "#/definitions/bearer_token_file"
                    },
                    "tls_config": {
                        "$ref": "#/definitions/tls_config"
                    },
                    "proxy_url": {
                        "description": "Optional proxy URL.",
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uri-reference"
                    }
                },
                "allOf": [
                    {
                        "$ref": "#/definitions/auth"
                    }
                ],
                "additionalProperties": false,
                "required": [
                    "url"
                ]
            }
        },
        "scrape_configs": {
            "description": "A list of scrape configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object",
                "properties": {
                    "job_name": {
                        "description": "The job name assigned to scraped metrics by default. Must be unique across all scrape configurations.",
                        "type": "string"
                    },
                    "scrape_interval": {
                        "description": "How frequently to scrape targets from this job. Defaults to `global.scrape_interval`.",
                        "$ref": "#/definitions/duration"
                    },
                    "scrape_timeout": {
                        "description": "Per-scrape timeout when scraping this job. Defaults to `global.scrape_timeout`.",
                        "$ref": "#/definitions/duration"
                    },
                    "metrics_path": {
                        "description": "The HTTP resource path on which to fetch metrics from targets.",
                        "type": [
                            "string",
                            "null"
                        ],
                        "default": "/metrics"
                    },
                    "honor_labels": {
                        "description": "Controls how Prometheus handles conflicts between labels that are already present in scraped data and labels that Prometheus would attach server-side (\"job\" and \"instance\" labels, manually configured target labels, and labels generated by service discovery implementations).",
                        "type": [
                            "boolean",
                            "null"
                        ],
                        "default": false
                    },
                    "honor_timestamps": {
                        "description": "Controls whether Prometheus respects the timestamps present in scraped data.",
                        "type": [
                            "boolean",
                            "null"
                        ],
                        "default": true
                    },
                    "scheme": {
                        "description": "Configures the protocol scheme used for requests.",
                        "$ref": "#/definitions/scheme"
                    },
                    "params": {
                        "description": "Optional HTTP(S) URL parameters.",
                        "type": [
                            "object",
                            "null"
                        ],
                        "additionalProperties": {
                            "type": "string"
                        }
                    },
                    "basic_auth": {
                        "$ref": "#/definitions/basic_auth"
                    },
                    "bearer_token": {
                        "$ref": "#/definitions/bearer_token"
                    },
                    "bearer_token_file": {
                        "$ref": "#/definitions/bearer_token_file"
                    },
                    "tls_config": {
                        "description": "Configures the scrape request's TLS settings.",
                        "$ref": "#/definitions/tls_config"
                    },
                    "proxy_url": {
                        "description": "Optional proxy URL.",
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uri-reference"
                    },
                    "azure_sd_configs": {
                        "$ref": "#/definitions/azure_sd_configs"
                    },
                    "consul_sd_configs": {
                        "$ref": "#/definitions/consul_sd_configs"
                    },
                    "dns_sd_configs": {
                        "$ref": "#/definitions/dns_sd_configs"
                    },
                    "ec2_sd_configs": {
                        "$ref": "#/definitions/ec2_sd_configs"
                    },
                    "openstack_sd_configs": {
                        "$ref": "#/definitions/openstack_sd_configs"
                    },
                    "file_sd_configs": {
                        "$ref": "#/definitions/file_sd_configs"
                    },
                    "gce_sd_configs": {
                        "$ref": "#/definitions/gce_sd_configs"
                    },
                    "kubernetes_sd_configs": {
                        "$ref": "#/definitions/kubernetes_sd_configs"
                    },
                    "marathon_sd_configs": {
                        "$ref": "#/definitions/marathon_sd_configs"
                    },
                    "nerve_sd_configs": {
                        "$ref": "#/definitions/nerve_sd_configs"
                    },
                    "serverset_sd_configs": {
                        "$ref": "#/definitions/serverset_sd_configs"
                    },
                    "triton_sd_configs": {
                        "$ref": "#/definitions/triton_sd_configs"
                    },
                    "static_configs": {
                        "$ref": "#/definitions/static_configs"
                    },
                    "relabel_configs": {
                        "description": "List of target relabel configurations.",
                        "$ref": "#/definitions/relabel_configs"
                    },
                    "metric_relabel_configs": {
                        "description": "List of metric relabel configurations.",
                        "$ref": "#/definitions/relabel_configs"
                    },
                    "sample_limit": {
                        "description": "Per-scrape limit on number of scraped samples that will be accepted. If more than this number of samples are present after metric relabelling the entire scrape will be treated as failed. 0 means no limit.",
                        "type": [
                            "integer",
                            "null"
                        ],
                        "default": 0
                    }
                },
                "allOf": [
                    {
                        "$ref": "#/definitions/auth"
                    }
                ],
                "additionalProperties": false,
                "required": [
                    "job_name"
                ]
            }
        },
        "alerting": {
            "description": "Alerting specifies settings related to the Alertmanager.",
            "type": [
                "object",
                "null"
            ],
            "properties": {
                "alert_relabel_configs": {
                    "$ref": "#/definitions/relabel_configs"
                },
                "alertmanagers": {
                    "type": [
                        "array",
                        "null"
                    ],
                    "items": {
                        "type": "object",
                        "properties": {
                            "timeout": {
                                "description": "Per-target Alertmanager timeout when pushing alerts.",
                                "$ref": "#/definitions/duration",
                                "default": "10s"
                            },
                            "api_version": {
                                "description": "The api version of Alertmanager.",
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "default": "v1"
                            },
                            "path_prefix": {
                                "description": "Prefix for the HTTP path alerts are pushed to.",
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "default": "/"
                            },
                            "scheme": {
                                "description": "Configures the protocol scheme used for requests.",
                                "$ref": "#/definitions/scheme"
                            },
                            "basic_auth": {
                                "$ref": "#/definitions/basic_auth"
                            },
                            "bearer_token": {
                                "$ref": "#/definitions/bearer_token"
                            },
                            "bearer_token_file": {
                                "$ref": "#/definitions/bearer_token_file"
                            },
                            "tls_config": {
                                "description": "Configures the scrape request's TLS settings.",
                                "$ref": "#/definitions/tls_config"
                            },
                            "proxy_url": {
                                "description": "Optional proxy URL.",
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "uri-reference"
                            },
                            "azure_sd_configs": {
                                "$ref": "#/definitions/azure_sd_configs"
                            },
                            "consul_sd_configs": {
                                "$ref": "#/definitions/consul_sd_configs"
                            },
                            "dns_sd_configs": {
                                "$ref": "#/definitions/dns_sd_configs"
                            },
                            "ec2_sd_configs": {
                                "$ref": "#/definitions/ec2_sd_configs"
                            },
                            "file_sd_configs": {
                                "$ref": "#/definitions/file_sd_configs"
                            },
                            "gce_sd_configs": {
                                "$ref": "#/definitions/gce_sd_configs"
                            },
                            "kubernetes_sd_configs": {
                                "$ref": "#/definitions/kubernetes_sd_configs"
                            },
                            "marathon_sd_configs": {
                                "$ref": "#/definitions/marathon_sd_configs"
                            },
                            "nerve_sd_configs": {
                                "$ref": "#/definitions/nerve_sd_configs"
                            },
                            "serverset_sd_configs": {
                                "$ref": "#/definitions/serverset_sd_configs"
                            },
                            "triton_sd_configs": {
                                "$ref": "#/definitions/triton_sd_configs"
                            },
                            "static_configs": {
                                "$ref": "#/definitions/static_configs"
                            },
                            "relabel_configs": {
                                "description": "List of target relabel configurations.",
                                "$ref": "#/definitions/relabel_configs"
                            }
                        },
                        "allOf": [
                            {
                                "$ref": "#/definitions/auth"
                            }
                        ]
                    }
                }
            }
        }
    },
    "additionalProperties": false,
    "definitions": {
        "duration": {
            "type": [
                "string",
                "null"
            ],
            "pattern": "^[0-9]+(ms|[smhdwy])$"
        },
        "label_name": {
            "type": "string",
            "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
        },
        "label_value": {
            "type": "string"
        },
        "labels": {
            "type": [
                "object",
                "null"
            ],
            "patternProperties": {
                "^[a-zA-Z_][a-zA-Z0-9_]*$": {
                    "$ref": "#/definitions/label_value"
                }
            },
            "additionalProperties": false
        },
        "filepath_glob": {
            "type": "string"
        },
        "filepath": {
            "type": [
                "string",
                "null"
            ],
            "format": "uri-reference"
        },
        "basic_auth": {
            "description": "Sets the `Authorization` header on every remote write request with the configured username and password. password and password_file are mutually exclusive.",
            "type": [
                "object",
                "null"
            ],
            "properties": {
                "username": {
                    "type": "string"
                },
                "password": {
                    "type": [
                        "string",
                        "null"
                    ]
                },
                "password_file": {
                    "$ref": "#/definitions/filepath"
                }
            },
            "oneOf": [
                {
                    "required": [
                        "password"
                    ]
                },
                {
                    "required": [
                        "password_file"
                    ]
                }
            ],
            "additionalProperties": false,
            "required": [
                "username"
            ]
        },
        "bearer_token": {
            "description": "Sets the `Authorization` header on every scrape request with the configured bearer token. It is mutually exclusive with `bearer_token_file`.",
            "type": [
                "string",
                "null"
            ]
        },
        "bearer_token_file": {
            "description": "Sets the `Authorization` header on every scrape request with the bearer token read from the configured file. It is mutually exclusive with `bearer_token`.",
            "$ref": "#/definitions/filepath"
        },
        "auth": {
            "allOf": [
                {
                    "if": {
                        "not": {
                            "properties": {
                                "basic_auth": {
                                    "const": null
                                }
                            }
                        }
                    },
                    "then": {
                        "properties": {
                            "bearer_token": {
                                "const": null
                            },
                            "bearer_token_file": {
                                "const": null
                            }
                        }
                    }
                },
                {
                    "if": {
                        "not": {
                            "properties": {
                                "bearer_token": {
                                    "const": null
                                }
                            }
                        }
                    },
                    "then": {
                        "properties": {
                            "basic_auth": {
                                "const": null
                            },
                            "bearer_token_file": {
                                "const": null
                            }
                        }
                    }
                },
                {
                    "if": {
                        "not": {
                            "properties": {
                                "bearer_token_file": {
                                    "const": null
                                }
                            }
                        }
                    },
                    "then": {
                        "properties": {
                            "basic_auth": {
                                "const": null
                            },
                            "bearer_token": {
                                "const": null
                            }
                        }
                    }
                }
            ]
        },
        "relabel_configs": {
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object",
                "properties": {
                    "source_labels": {
                        "description": "The source labels select values from existing labels. Their content is concatenated using the configured separator and matched against the configured regular expression for the replace, keep, and drop actions.",
                        "type": "array",
                        "items": {
                            "$ref": "#/definitions/label_name"
                        }
                    },
                    "separator": {
                        "description": "Separator placed between concatenated source label values.",
                        "type": "string",
                        "default": ";"
                    },
                    "target_label": {
                        "description": "Label to which the resulting value is written in a replace action. It is mandatory for replace actions. Regex capture groups are available.",
                        "$comment": "https://github.com/prometheus/prometheus/blob/release-2.13/config/testdata/conf.good.yml#L146 has a regex capture group, violating vanilla label_name definition.",
                        "type": "string"
                    },
                    "regex": {
                        "description": "Regular expression against which the extracted value is matched.",
                        "$comment": "https://github.com/prometheus/prometheus/blob/release-2.13/config/testdata/conf.good.yml#L111 has integer instead of string",
                        "default": "(.*)"
                    },
                    "modulus": {
                        "description": "Modulus to take of the hash of the source label values.",
                        "type": "integer"
                    },
                    "replacement": {
                        "description": "Replacement value against which a regex replace is performed if the regular expression matches. Regex capture groups are available.",
                        "type": "string",
                        "default": "$1"
                    },
                    "action": {
                        "description": "Action to perform based on regex matching.",
                        "type": "string",
                        "enum": [
                            "replace",
                            "keep",
                            "drop",
                            "hashmod",
                            "labelmap",
                            "labeldrop",
                            "labelkeep"
                        ],
                        "default": "replace"
                    }
                },
                "if": {
                    "properties": {
                        "action": {
                            "const": "replace"
                        }
                    }
                },
                "then": {
                    "required": [
                        "target_label"
                    ]
                }
            }
        },
        "tls_config": {
            "type": [
                "object",
                "null"
            ],
            "properties": {
                "ca_file": {
                    "description": "CA certificate to validate API server certificate with.",
                    "$ref": "#/definitions/filepath"
                },
                "cert_file": {
                    "description": "Certificate file for client cert authentication to the server.",
                    "$ref": "#/definitions/filepath"
                },
                "key_file": {
                    "description": "Key file for client cert authentication to the server.",
                    "$ref": "#/definitions/filepath"
                },
                "server_name": {
                    "description": "ServerName extension to indicate the name of the server.",
                    "type": [
                        "string",
                        "null"
                    ]
                },
                "insecure_skip_verify": {
                    "description": "Disable validation of the server certificate.",
                    "type": [
                        "boolean",
                        "null"
                    ]
                }
            },
            "additionalProperties": false
        },
        "scheme": {
            "type": [
                "string",
                "null"
            ],
            "enum": [
                "http",
                "https",
                null
            ]
        },
        "azure_sd_configs": {
            "description": "List of Azure service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "description": "The information to access the Azure API.",
                "type": "object"
            }
        },
        "consul_sd_configs": {
            "description": "List of Consul service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "description": "The information to access the Consul API. It is to be defined as the Consul documentation requires.",
                "type": "object"
            }
        },
        "dns_sd_configs": {
            "description": "List of DNS service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "description": "A DNS-based service discovery configuration allows specifying a set of DNS domain names which are periodically queried to discover a list of targets. The DNS servers to be contacted are read from /etc/resolv.conf. This service discovery method only supports basic DNS A, AAAA and SRV record queries, but not the advanced DNS-SD approach specified in RFC6763. During the relabeling phase, the meta label __meta_dns_name is available on each target and is set to the record name that produced the discovered target.",
                "type": "object"
            }
        },
        "ec2_sd_configs": {
            "description": "List of EC2 service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "description": "The information to access the EC2 API.",
                "type": "object"
            }
        },
        "openstack_sd_configs": {
            "description": "List of OpenStack service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "description": "The information to access the OpenStack API.",
                "type": "object"
            }
        },
        "file_sd_configs": {
            "description": "List of file service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object",
                "properties": {
                    "files": {
                        "description": "Patterns for files from which target groups are extracted. Where the pattern may be a path ending in .json, .yml or .yaml. The last path segment may contain a single * that matches any character sequence, e.g. my/path/tg_*.json.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "minItems": 1
                    },
                    "refresh_interval": {
                        "description": "Refresh interval to re-read the files.",
                        "$ref": "#/definitions/duration",
                        "default": "5m"
                    }
                }
            }
        },
        "gce_sd_configs": {
            "description": "List of GCE service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "description": "The information to access the GCE API.",
                "type": "object"
            }
        },
        "kubernetes_sd_configs": {
            "description": "List of Kubernetes service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "description": "The information to access the Kubernetes API.",
                "type": "object"
            }
        },
        "marathon_sd_configs": {
            "description": "List of Marathon service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object"
            }
        },
        "nerve_sd_configs": {
            "description": "List of AirBnB's Nerve service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object"
            }
        },
        "serverset_sd_configs": {
            "description": "List of Zookeeper Serverset service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object"
            }
        },
        "triton_sd_configs": {
            "description": "List of Triton service discovery configurations.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "description": "The information to access the Triton discovery API.",
                "type": "object"
            }
        },
        "static_configs": {
            "description": "List of labeled statically configured targets for this job.",
            "type": [
                "array",
                "null"
            ],
            "items": {
                "type": "object",
                "properties": {
                    "targets": {
                        "description": "The targets specified by the static config.",
                        "type": [
                            "array",
                            "null"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "labels": {
                        "description": "Labels assigned to all metrics scraped from the targets.",
                        "$ref": "#/definitions/labels"
                    }
                }
            }
        }
    }
}