Skip to content

Commit

Permalink
distributor: Adorn label value too long message with label name
Browse files Browse the repository at this point in the history
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
  • Loading branch information
aknuds1 committed Mar 27, 2024
1 parent 85d0dbb commit 1139413
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* [CHANGE] Querier: the CLI flag `-querier.minimize-ingester-requests` has been moved from "experimental" to "advanced". #7638
* [CHANGE] Ingester: `/ingester/flush` endpoint is now only allowed to execute only while the ingester is in `Running` state. The 503 status code is returned if the endpoint is called while the ingester is not in `Running` state. #7486
* [CHANGE] Distributor: Include label name in `err-mimir-label-value-too-long` error message: #7740
* [FEATURE] Store-gateway: Allow specific tenants to be enabled or disabled via `-store-gateway.enabled-tenants` or `-store-gateway.disabled-tenants` CLI flags or their corresponding YAML settings. #7653
* [FEATURE] New `-<prefix>.s3.bucket-lookup-type` flag configures lookup style type, used to access bucket in s3 compatible providers. #7684
* [ENHANCEMENT] Store-gateway: merge series from different blocks concurrently. #7456
Expand Down
2 changes: 1 addition & 1 deletion pkg/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ func TestDistributor_PushHAInstances(t *testing.T) {
testReplica: "instance1234567890123456789012345678901234567890",
cluster: "cluster0",
samples: 5,
expectedError: status.New(codes.FailedPrecondition, fmt.Sprintf(labelValueTooLongMsgFormat, "instance1234567890123456789012345678901234567890", mimirpb.FromLabelAdaptersToString(labelSetGenWithReplicaAndCluster("instance1234567890123456789012345678901234567890", "cluster0")(0)))),
expectedError: status.New(codes.FailedPrecondition, fmt.Sprintf(labelValueTooLongMsgFormat, "__replica__", "instance1234567890123456789012345678901234567890", mimirpb.FromLabelAdaptersToString(labelSetGenWithReplicaAndCluster("instance1234567890123456789012345678901234567890", "cluster0")(0)))),
expectedDetails: &mimirpb.ErrorDetails{Cause: mimirpb.BAD_DATA},
},
} {
Expand Down
4 changes: 2 additions & 2 deletions pkg/distributor/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var (
validation.MaxLabelNameLengthFlag,
)
labelValueTooLongMsgFormat = globalerror.SeriesLabelValueTooLong.MessageWithPerTenantLimitConfig(
"received a series whose label value length exceeds the limit, value: '%.200s' (truncated) series: '%.200s'",
"received a series whose label value length exceeds the limit, label: '%s', value: '%.200s' (truncated) series: '%.200s'",
validation.MaxLabelValueLengthFlag,
)
invalidLabelMsgFormat = globalerror.SeriesInvalidLabel.Message("received a series with an invalid label: '%.200s' series: '%.200s'")
Expand Down Expand Up @@ -370,7 +370,7 @@ func validateLabels(m *sampleValidationMetrics, cfg labelValidationConfig, userI
return fmt.Errorf(labelNameTooLongMsgFormat, l.Name, mimirpb.FromLabelAdaptersToString(ls))
} else if len(l.Value) > maxLabelValueLength {
m.labelValueTooLong.WithLabelValues(userID, group).Inc()
return fmt.Errorf(labelValueTooLongMsgFormat, l.Value, mimirpb.FromLabelAdaptersToString(ls))
return fmt.Errorf(labelValueTooLongMsgFormat, l.Name, l.Value, mimirpb.FromLabelAdaptersToString(ls))
} else if lastLabelName == l.Name {
m.duplicateLabelNames.WithLabelValues(userID, group).Inc()
return fmt.Errorf(duplicateLabelMsgFormat, l.Name, mimirpb.FromLabelAdaptersToString(ls))
Expand Down
1 change: 1 addition & 0 deletions pkg/distributor/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func TestValidateLabels(t *testing.T) {
false,
fmt.Errorf(
labelValueTooLongMsgFormat,
"much_shorter_name",
"test_value_please_ignore_no_really_nothing_to_see_here",
mimirpb.FromLabelAdaptersToString(
[]mimirpb.LabelAdapter{
Expand Down

0 comments on commit 1139413

Please sign in to comment.