* Alerting: Remove internal labels from prometheus compatible API responses
* Appease the linter
* Fix integration tests
* Fix API documentation & linter
* move removal of internal labels to the models
"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"
@ -2835,9 +2836,9 @@
"$ref":"#/definitions/Userinfo"
}
},
"title":"URL is a custom URL type that allows validation at configuration load time.",
"title":"A URL represents a parsed URL (technically, a URI reference).",
"description":"The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.",
"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.",
"type":"object",
"title":"URL is a custom URL type that allows validation at configuration load time.",
"title":"A URL represents a parsed URL (technically, a URI reference).",
"description":"The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.",
ErrAlertRuleUniqueConstraintViolation=errors.New("a conflicting alert rule is found: rule title under the same organisation and folder should be unique")
)
@ -77,6 +74,12 @@ const (
OkErrStateExecutionErrorState="OK"
)
// InternalLabelNameSet are labels that grafana automatically include as part of the labelset.
varInternalLabelNameSet=map[string]struct{}{
RuleUIDLabel:{},
NamespaceUIDLabel:{},
}
const(
RuleUIDLabel="__alert_rule_uid__"
NamespaceUIDLabel="__alert_rule_namespace_uid__"
@ -110,6 +113,29 @@ type AlertRule struct {
Labelsmap[string]string
}
typeLabelOptionfunc(map[string]string)
funcWithoutInternalLabels()LabelOption{
returnfunc(labelsmap[string]string){
fork:=rangelabels{
if_,ok:=InternalLabelNameSet[k];ok{
delete(labels,k)
}
}
}
}
// GetLabels returns the labels specified as part of the alert rule.