You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: Handle duplicate validation correctly when sanitizing (#4238)
When replacing dots with underscores, we don't take care of the order of
the labels slice, hence our duplicate check can be ineffective.
This change will fix this bug and also will handle the case when both
the sanitized and unsanitized label values actually match and reduce them
to the sanitized variant.
Discovered when reviewing #4236
SeriesLimitErrorMsg="Maximum active series limit exceeded (%d/%d), reduce the number of active streams (reduce labels or reduce label values), or contact your administrator to see if the limit can be increased"
67
-
MissingLabelsErrorMsg="error at least one label pair is required per profile"
68
-
InvalidLabelsErrorMsg="invalid labels '%s' with error: %s"
69
-
MaxLabelNamesPerSeriesErrorMsg="profile series '%s' has %d label names; limit %d"
70
-
LabelNameTooLongErrorMsg="profile with labels '%s' has label name too long: '%s'"
71
-
LabelValueTooLongErrorMsg="profile with labels '%s' has label value too long: '%s'"
72
-
DuplicateLabelNamesErrorMsg="profile with labels '%s' has duplicate label name: '%s'"
73
-
QueryTooLongErrorMsg="the query time range exceeds the limit (max_query_length, actual: %s, limit: %s)"
74
-
ProfileTooBigErrorMsg="the profile with labels '%s' exceeds the size limit (max_profile_size_byte, actual: %d, limit: %d)"
75
-
ProfileTooManySamplesErrorMsg="the profile with labels '%s' exceeds the samples count limit (max_profile_stacktrace_samples, actual: %d, limit: %d)"
76
-
ProfileTooManySampleLabelsErrorMsg="the profile with labels '%s' exceeds the sample labels limit (max_profile_stacktrace_sample_labels, actual: %d, limit: %d)"
77
-
NotInIngestionWindowErrorMsg="profile with labels '%s' is outside of ingestion window (profile timestamp: %s, %s)"
78
-
MaxFlameGraphNodesErrorMsg="max flamegraph nodes limit %d is greater than allowed %d"
79
-
MaxFlameGraphNodesUnlimitedErrorMsg="max flamegraph nodes limit must be set (max allowed %d)"
80
-
QueryMissingTimeRangeErrorMsg="missing time range in the query"
81
-
QueryStartAfterEndErrorMsg="query start time is after end time"
66
+
SeriesLimitErrorMsg="Maximum active series limit exceeded (%d/%d), reduce the number of active streams (reduce labels or reduce label values), or contact your administrator to see if the limit can be increased"
67
+
MissingLabelsErrorMsg="error at least one label pair is required per profile"
68
+
InvalidLabelsErrorMsg="invalid labels '%s' with error: %s"
69
+
MaxLabelNamesPerSeriesErrorMsg="profile series '%s' has %d label names; limit %d"
70
+
LabelNameTooLongErrorMsg="profile with labels '%s' has label name too long: '%s'"
71
+
LabelValueTooLongErrorMsg="profile with labels '%s' has label value too long: '%s'"
72
+
DuplicateLabelNamesErrorMsg="profile with labels '%s' has duplicate label name: '%s'"
73
+
DuplicateLabelNamesAfterSanitizationErrorMsg="profile with labels '%s' has duplicate label name '%s' after label name sanitization from '%s'"
74
+
QueryTooLongErrorMsg="the query time range exceeds the limit (max_query_length, actual: %s, limit: %s)"
75
+
ProfileTooBigErrorMsg="the profile with labels '%s' exceeds the size limit (max_profile_size_byte, actual: %d, limit: %d)"
76
+
ProfileTooManySamplesErrorMsg="the profile with labels '%s' exceeds the samples count limit (max_profile_stacktrace_samples, actual: %d, limit: %d)"
77
+
ProfileTooManySampleLabelsErrorMsg="the profile with labels '%s' exceeds the sample labels limit (max_profile_stacktrace_sample_labels, actual: %d, limit: %d)"
78
+
NotInIngestionWindowErrorMsg="profile with labels '%s' is outside of ingestion window (profile timestamp: %s, %s)"
79
+
MaxFlameGraphNodesErrorMsg="max flamegraph nodes limit %d is greater than allowed %d"
80
+
MaxFlameGraphNodesUnlimitedErrorMsg="max flamegraph nodes limit must be set (max allowed %d)"
81
+
QueryMissingTimeRangeErrorMsg="missing time range in the query"
82
+
QueryStartAfterEndErrorMsg="query start time is after end time"
expectedErr: "profile with labels '{__name__=\"qux\", label_name=\"foo\", label_name=\"bar\", service_name=\"svc\"}' has duplicate label name: 'label.name'",
126
+
expectedErr: "profile with labels '{__name__=\"qux\", label.name=\"bar\", label_name=\"foo\", service_name=\"svc\"}' has duplicate label name 'label_name' after label name sanitization from 'label.name'",
127
+
},
128
+
{
129
+
name: "duplicates once sanitized with matching values",
130
+
lbs: []*typesv1.LabelPair{
131
+
{Name: model.MetricNameLabel, Value: "qux"},
132
+
{Name: "service.name", Value: "svc0"},
133
+
{Name: "service_abc", Value: "def"},
134
+
{Name: "service_name", Value: "svc0"},
135
+
},
136
+
},
137
+
{
138
+
name: "duplicates once sanitized with conflicting values",
139
+
lbs: []*typesv1.LabelPair{
140
+
{Name: model.MetricNameLabel, Value: "qux"},
141
+
{Name: "service.name", Value: "svc1"},
142
+
{Name: "service_abc", Value: "def"},
143
+
{Name: "service_name", Value: "svc0"},
144
+
},
145
+
expectedReason: DuplicateLabelNames,
146
+
expectedErr: "profile with labels '{__name__=\"qux\", service_abc=\"def\", service_abc=\"def\", service_name=\"svc0\"}' has duplicate label name 'service_name' after label name sanitization from 'service.name'",
0 commit comments