mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promrelabel: allow calling Match on nil IfExpression
This simplifies the caller side of IfExpression
This commit is contained in:
parent
18ee36f0cf
commit
a7942c6c0d
2 changed files with 4 additions and 1 deletions
|
@ -78,6 +78,9 @@ func (ie *IfExpression) MarshalYAML() (interface{}, error) {
|
|||
|
||||
// Match returns true if ie matches the given labels.
|
||||
func (ie *IfExpression) Match(labels []prompbmarshal.Label) bool {
|
||||
if ie == nil {
|
||||
return true
|
||||
}
|
||||
for _, lf := range ie.lfs {
|
||||
if !lf.match(labels) {
|
||||
return false
|
||||
|
|
|
@ -158,7 +158,7 @@ func FinalizeLabels(dst, src []prompbmarshal.Label) []prompbmarshal.Label {
|
|||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
|
||||
func (prc *parsedRelabelConfig) apply(labels []prompbmarshal.Label, labelsOffset int) []prompbmarshal.Label {
|
||||
src := labels[labelsOffset:]
|
||||
if prc.If != nil && !prc.If.Match(labels) {
|
||||
if !prc.If.Match(labels) {
|
||||
if prc.Action == "keep" {
|
||||
// Drop the target on `if` mismatch for `action: keep`
|
||||
return labels[:labelsOffset]
|
||||
|
|
Loading…
Reference in a new issue