Alerting: Fetch all applied alerting configurations (#65728)

* WIP

* skip invalid historic configurations instead of erroring

* add warning log when bad historic config is found

* remove unused custom marshaller for GettableHistoricUserConfig

* add id to historic user config, move limit check to store, fix typo

* swagger spec
This commit is contained in:
Santiago
2023-03-31 17:43:04 -03:00
committed by GitHub
parent 412fc4dcfb
commit aba91d3053
17 changed files with 920 additions and 117 deletions
+164 -17
View File
@@ -185,9 +185,9 @@
},
"execErrState": {
"enum": [
"OK",
"Alerting",
"Error",
"OK"
"Error"
],
"type": "string"
},
@@ -528,6 +528,9 @@
"DataLink": {
"description": "DataLink define what",
"properties": {
"internal": {
"$ref": "#/definitions/InternalDataLink"
},
"targetBlank": {
"type": "boolean"
},
@@ -715,6 +718,40 @@
],
"type": "object"
},
"EnumFieldConfig": {
"description": "Enum field config\nVector values are used as lookup keys into the enum fields",
"properties": {
"color": {
"description": "Color is the color value for a given index (empty is undefined)",
"items": {
"type": "string"
},
"type": "array"
},
"description": {
"description": "Description of the enum state",
"items": {
"type": "string"
},
"type": "array"
},
"icon": {
"description": "Icon supports setting an icon for a given index value",
"items": {
"type": "string"
},
"type": "array"
},
"text": {
"description": "Value is the string display value for a given index",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"ErrorType": {
"title": "ErrorType models the different API error types.",
"type": "string"
@@ -754,6 +791,9 @@
"type": "object"
},
"EvalQueriesResponse": {},
"ExplorePanelsState": {
"description": "This is an object constructed with the keys as the values of the enum VisType and the value being a bag of properties"
},
"ExtendedReceiver": {
"properties": {
"email_configs": {
@@ -870,6 +910,9 @@
"thresholds": {
"$ref": "#/definitions/ThresholdsConfig"
},
"type": {
"$ref": "#/definitions/FieldTypeConfig"
},
"unit": {
"description": "Numeric Options",
"type": "string"
@@ -882,11 +925,20 @@
"title": "FieldConfig represents the display properties for a Field.",
"type": "object"
},
"FieldTypeConfig": {
"description": "FieldTypeConfig has type specific configs, only one should be active at a time",
"properties": {
"enum": {
"$ref": "#/definitions/EnumFieldConfig"
}
},
"type": "object"
},
"Frame": {
"description": "Each Field is well typed by its FieldType and supports optional Labels.\n\nA Frame is a general data container for Grafana. A Frame can be table data\nor time series data depending on its content and field types.",
"properties": {
"Fields": {
"description": "Fields are the columns of a frame.\nAll Fields must be of the same the length when marshalling the Frame for transmission.",
"description": "Fields are the columns of a frame.\nAll Fields must be of the same the length when marshalling the Frame for transmission.\nThere should be no `nil` entries in the Fields slice (making them pointers was a mistake).",
"items": {
"$ref": "#/definitions/Field"
},
@@ -958,6 +1010,9 @@
},
"type": {
"$ref": "#/definitions/FrameType"
},
"typeVersion": {
"$ref": "#/definitions/FrameTypeVersion"
}
},
"title": "FrameMeta matches:",
@@ -967,8 +1022,16 @@
"description": "A FrameType string, when present in a frame's metadata, asserts that the\nframe's structure conforms to the FrameType's specification.\nThis property is currently optional, so FrameType may be FrameTypeUnknown even if the properties of\nthe Frame correspond to a defined FrameType.",
"type": "string"
},
"FrameTypeVersion": {
"items": {
"format": "uint64",
"type": "integer"
},
"title": "FrameType is a 2 number version (Major / Minor).",
"type": "array"
},
"Frames": {
"description": "It is the main data container within a backend.DataResponse.",
"description": "It is the main data container within a backend.DataResponse.\nThere should be no `nil` entries in the Frames slice (making them pointers was a mistake).",
"items": {
"$ref": "#/definitions/Frame"
},
@@ -1259,6 +1322,34 @@
},
"type": "object"
},
"GettableHistoricUserConfig": {
"properties": {
"alertmanager_config": {
"$ref": "#/definitions/GettableApiAlertingConfig"
},
"id": {
"format": "int64",
"type": "integer"
},
"last_applied": {
"format": "date-time",
"type": "string"
},
"template_file_provenances": {
"additionalProperties": {
"$ref": "#/definitions/Provenance"
},
"type": "object"
},
"template_files": {
"additionalProperties": {
"type": "string"
},
"type": "object"
}
},
"type": "object"
},
"GettableNGalertConfig": {
"properties": {
"alertmanagersChoice": {
@@ -1521,6 +1612,31 @@
"title": "InspectType is a type for the Inspect property of a Notice.",
"type": "integer"
},
"InternalDataLink": {
"description": "InternalDataLink definition to allow Explore links to be constructed in the backend",
"properties": {
"datasourceName": {
"type": "string"
},
"datasourceUid": {
"type": "string"
},
"panelsState": {
"$ref": "#/definitions/ExplorePanelsState"
},
"query": {},
"timeRange": {
"$ref": "#/definitions/TimeRange"
},
"transformations": {
"items": {
"$ref": "#/definitions/LinkTransformationConfig"
},
"type": "array"
}
},
"type": "object"
},
"Json": {
"type": "object"
},
@@ -1562,6 +1678,23 @@
},
"type": "array"
},
"LinkTransformationConfig": {
"properties": {
"expression": {
"type": "string"
},
"field": {
"type": "string"
},
"mapValue": {
"type": "string"
},
"type": {
"$ref": "#/definitions/SupportedTransformationTypes"
}
},
"type": "object"
},
"MatchRegexps": {
"additionalProperties": {
"$ref": "#/definitions/Regexp"
@@ -2272,9 +2405,9 @@
},
"execErrState": {
"enum": [
"OK",
"Alerting",
"Error",
"OK"
"Error"
],
"type": "string"
},
@@ -2472,6 +2605,9 @@
"thresholds": {
"$ref": "#/definitions/ThresholdsConfig"
},
"type": {
"$ref": "#/definitions/FieldTypeConfig"
},
"unit": {
"description": "Numeric Options",
"type": "string"
@@ -3040,6 +3176,9 @@
"Success": {
"$ref": "#/definitions/ResponseDetails"
},
"SupportedTransformationTypes": {
"type": "string"
},
"TLSConfig": {
"properties": {
"ca_file": {
@@ -3279,22 +3418,20 @@
"type": "object"
},
"TimeRange": {
"description": "For example, 4:00PM to End of the day would Begin at 1020 and End at 1440.",
"description": "Redefining this to avoid an import cycle",
"properties": {
"EndMinute": {
"format": "int64",
"type": "integer"
"from": {
"format": "date-time",
"type": "string"
},
"StartMinute": {
"format": "int64",
"type": "integer"
"to": {
"format": "date-time",
"type": "string"
}
},
"title": "TimeRange represents a range of minutes within a 1440 minute day, exclusive of the End minute. A day consists of 1440 minutes.",
"type": "object"
},
"URL": {
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.",
"properties": {
"ForceQuery": {
"type": "boolean"
@@ -3330,7 +3467,7 @@
"$ref": "#/definitions/Userinfo"
}
},
"title": "A URL represents a parsed URL (technically, a URI reference).",
"title": "URL is a custom URL type that allows validation at configuration load time.",
"type": "object"
},
"Userinfo": {
@@ -3530,7 +3667,6 @@
"type": "object"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"items": {
"$ref": "#/definitions/alertGroup"
},
@@ -3894,6 +4030,7 @@
"type": "array"
},
"postableSilence": {
"description": "PostableSilence postable silence",
"properties": {
"comment": {
"description": "comment",
@@ -3931,6 +4068,7 @@
"type": "object"
},
"receiver": {
"description": "Receiver receiver",
"properties": {
"active": {
"description": "active",
@@ -4864,6 +5002,15 @@
"application/json"
],
"responses": {
"GettableHistoricUserConfigs": {
"description": "",
"schema": {
"items": {
"$ref": "#/definitions/GettableHistoricUserConfig"
},
"type": "array"
}
},
"receiversResponse": {
"description": "",
"schema": {