diff --git a/tools/az-prom-rules-converter/src/schemas/prometheus/prometheus.rules.json b/tools/az-prom-rules-converter/src/schemas/prometheus/prometheus.rules.json index bd66f44ef..3cd04005f 100644 --- a/tools/az-prom-rules-converter/src/schemas/prometheus/prometheus.rules.json +++ b/tools/az-prom-rules-converter/src/schemas/prometheus/prometheus.rules.json @@ -1,21 +1,14 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Prometheus Rules", - "description": "Prometheus rules file", - "type": "object", + "$id": "https://json.schemastore.org/prometheus.rules.json", "additionalProperties": false, - "properties": { - "groups": { - "type": "array", - "items": { - "$ref": "#/definitions/prometheus_rules_group" - } - } - }, "definitions": { "duration": { - "type": "string", - "pattern": "^([0-9]+y)?([0-9]+w)?([0-9]+d)?([0-9]+h)?([0-9]+m)?([0-9]+s)?([0-9]+ms)?$", + "type": [ + "string", + "null" + ], + "pattern": "^((([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?|0)$", "minLength": 1 }, "label_name": { @@ -26,8 +19,10 @@ "type": "string" }, "labels": { - "type": "object", - "description": "Labels.", + "type": [ + "object", + "null" + ], "patternProperties": { "^[a-zA-Z_][a-zA-Z0-9_]*$": { "$ref": "#/definitions/label_value" @@ -35,52 +30,22 @@ }, "additionalProperties": false }, - "template_string": { + "tmpl_string": { "description": "A string which is template-expanded before usage.", "type": "string" }, "annotations": { - "type": "object", + "type": [ + "object", + "null" + ], "patternProperties": { "^[a-zA-Z_][a-zA-Z0-9_]*$": { - "$ref": "#/definitions/template_string" + "$ref": "#/definitions/tmpl_string" } }, "additionalProperties": false }, - "prometheus_rules_group": { - "type": "object", - "properties": { - "name": { - "description": "The name of the group. Must be unique within a file.", - "type": "string" - }, - "interval": { - "description": "How often rules in the group are evaluated.", - "$ref": "#/definitions/duration" - }, - "limit": { - "description": "Limit the number of alerts an alerting rule and series a recording rule can produce. 0 is no limit.", - "type": "integer", - "default": 0 - }, - "rules": { - "type": "array", - "items": { - "oneOf": [ - { - "$ref": "#/definitions/recording_rule" - }, - { - "$ref": "#/definitions/alerting_rule" - } - ] - } - } - }, - "required": ["name"], - "additionalProperties": false - }, "recording_rule": { "type": "object", "properties": { @@ -90,14 +55,24 @@ }, "expr": { "description": "The PromQL expression to evaluate. Every evaluation cycle this is evaluated at the current time, and the result recorded as a new set of time series with the metric name as given by 'record'.", - "type": "string" + "anyOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] }, "labels": { - "description": "Labels to add or overwrite before storing the result.", - "$ref": "#/definitions/labels" + "$ref": "#/definitions/labels", + "description": "Labels to add or overwrite before storing the result." } }, - "required": ["record", "expr"], + "required": [ + "record", + "expr" + ], "additionalProperties": false }, "alerting_rule": { @@ -109,23 +84,92 @@ }, "expr": { "description": "The PromQL expression to evaluate. Every evaluation cycle this is evaluated at the current time, and all resultant time series become pending/firing alerts.", - "type": "string" + "anyOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] }, "for": { - "description": "Alerts are considered firing once they have been returned for this long. Alerts which have not yet fired for long enough are considered pending.", - "$ref": "#/definitions/duration" + "$ref": "#/definitions/duration", + "description": "Alerts are considered firing once they have been returned for this long. Alerts which have not yet fired for long enough are considered pending." + }, + "keep_firing_for": { + "$ref": "#/definitions/duration", + "description": "How long an alert will continue firing after the condition that triggered it has cleared." }, "labels": { - "description": "Labels to add or overwrite for each alert.", - "$ref": "#/definitions/labels" + "$ref": "#/definitions/labels", + "description": "Labels to add or overwrite for each alert." }, "annotations": { - "description": "Annotations to add to each alert.", - "$ref": "#/definitions/annotations" + "$ref": "#/definitions/annotations", + "description": "Annotations to add to each alert." } }, - "required": ["alert", "expr"], + "required": [ + "alert", + "expr" + ], "additionalProperties": false } - } + }, + "description": "Prometheus rules file", + "properties": { + "groups": { + "type": [ + "array", + "null" + ], + "items": { + "type": "object", + "properties": { + "name": { + "description": "The name of the group. Must be unique within a file.", + "type": "string" + }, + "interval": { + "$ref": "#/definitions/duration", + "description": "How often rules in the group are evaluated." + }, + "limit": { + "description": "Limit the number of alerts an alerting rule and series a recording rule can produce. 0 is no limit.", + "type": [ + "integer", + "null" + ], + "default": 0 + }, + "rules": { + "type": [ + "array", + "null" + ], + "items": { + "oneOf": [ + { + "$ref": "#/definitions/recording_rule" + }, + { + "$ref": "#/definitions/alerting_rule" + } + ] + } + } + }, + "required": [ + "name" + ], + "additionalProperties": false + } + } + }, + "title": "Prometheus Rules", + "type": [ + "object", + "null" + ] } \ No newline at end of file