Skip to content

Commit

Permalink
Upgrade to latest mimir-prometheus (#8012)
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 Apr 30, 2024
1 parent 2455c30 commit 2032768
Show file tree
Hide file tree
Showing 22 changed files with 679 additions and 527 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
* [ENHANCEMENT] Expose TLS configuration for the S3 backend client. #2652
* [ENHANCEMENT] Rules: Support expansion of native histogram values when using rule templates #7974
* [ENHANCEMENT] Rules: Add metric `cortex_prometheus_rule_group_last_restore_duration_seconds` which measures how long it takes to restore rule groups using the `ALERTS_FOR_STATE` series #7974
* [ENHANCEMENT] OTLP: Improve remote write format translation performance by using label set hashes for metric identifiers instead of string based ones. #8012
* [ENHANCEMENT] Querying: Remove OpEmptyMatch from regex concatenations. #8012
* [BUGFIX] Rules: improve error handling when querier is local to the ruler. #7567
* [BUGFIX] Querier, store-gateway: Protect against panics raised during snappy encoding. #7520
* [BUGFIX] Ingester: Prevent timely compaction of empty blocks. #7624
Expand All @@ -45,6 +47,8 @@
* [BUGFIX] Distributor: fix cardinality API to return more accurate number of in-memory series when number of zones is larger than replication factor. #7984
* [BUGFIX] All: fix config validation for non-ingester modules, when ingester's ring is configured with spread-minimizing token generation strategy. #7990
* [BUGFIX] Ingester: copy LabelValues strings out of mapped memory to avoid a segmentation fault if the region becomes unmapped before the result is marshaled. #8003
* [BUGFIX] OTLP: Don't generate target_info unless at least one identifying label is defined. #8012
* [BUGFIX] OTLP: Don't generate target_info unless there are metrics. #8012

### Mixin

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ require (
)

// Using a fork of Prometheus with Mimir-specific changes.
replace github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20240425135920-25fa9704a18d
replace github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20240430115734-de14b0ea393d

// Replace memberlist with our fork which includes some fixes that haven't been
// merged upstream yet:
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56 h1:X8IKQ0wu40wp
github.com/grafana/gomemcache v0.0.0-20240229205252-cd6a66d6fb56/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU=
github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe h1:yIXAAbLswn7VNWBIvM71O2QsgfgW9fRXZNR0DXe6pDU=
github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
github.com/grafana/mimir-prometheus v0.0.0-20240425135920-25fa9704a18d h1:wHlI86MW5ctiymgKFQ7/b3s6gdKRV8Pjtz1UEin4Vdw=
github.com/grafana/mimir-prometheus v0.0.0-20240425135920-25fa9704a18d/go.mod h1:aHDiVcHIagfJ2pA67wkdb+PZloT0qmhnz354giFb3AQ=
github.com/grafana/mimir-prometheus v0.0.0-20240430115734-de14b0ea393d h1:Om2XlhefR+CpriqWNjX9ysS2GrrKQxRU8NzQRE5yJC4=
github.com/grafana/mimir-prometheus v0.0.0-20240430115734-de14b0ea393d/go.mod h1:aHDiVcHIagfJ2pA67wkdb+PZloT0qmhnz354giFb3AQ=
github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956 h1:em1oddjXL8c1tL0iFdtVtPloq2hRPen2MJQKoAWpxu0=
github.com/grafana/opentracing-contrib-go-stdlib v0.0.0-20230509071955-f410e79da956/go.mod h1:qtI1ogk+2JhVPIXVc6q+NHziSmy2W5GbdQZFUHADCBU=
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 h1:nEdZ8louGAplSvIJi1HVp7kWvFvdiiYg3COLlTwJiFo=
Expand Down
14 changes: 8 additions & 6 deletions pkg/distributor/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,11 @@ func otelMetricsToMetadata(addSuffixes bool, md pmetric.Metrics) []*mimirpb.Metr
}

func otelMetricsToTimeseries(tenantID string, addSuffixes bool, discardedDueToOtelParseError *prometheus.CounterVec, logger log.Logger, md pmetric.Metrics) ([]mimirpb.PreallocTimeseries, error) {
tsMap, errs := prometheusremotewrite.FromMetrics(md, prometheusremotewrite.Settings{
converter := prometheusremotewrite.NewPrometheusConverter()
errs := converter.FromMetrics(md, prometheusremotewrite.Settings{
AddMetricSuffixes: addSuffixes,
})
promTS := converter.TimeSeries()
if errs != nil {
dropped := len(multierr.Errors(errs))
discardedDueToOtelParseError.WithLabelValues(tenantID, "").Add(float64(dropped)) // Group is empty here as metrics couldn't be parsed
Expand All @@ -274,19 +276,19 @@ func otelMetricsToTimeseries(tenantID string, addSuffixes bool, discardedDueToOt
parseErrs = parseErrs[:maxErrMsgLen]
}

if len(tsMap) == 0 {
if len(promTS) == 0 {
return nil, errors.New(parseErrs)
}

level.Warn(logger).Log("msg", "OTLP parse error", "err", parseErrs)
}

mimirTs := mimirpb.PreallocTimeseriesSliceFromPool()
for _, promTs := range tsMap {
mimirTs = append(mimirTs, promToMimirTimeseries(promTs))
mimirTS := mimirpb.PreallocTimeseriesSliceFromPool()
for _, ts := range promTS {
mimirTS = append(mimirTS, promToMimirTimeseries(&ts))
}

return mimirTs, nil
return mimirTS, nil
}

func promToMimirTimeseries(promTs *prompb.TimeSeries) mimirpb.PreallocTimeseries {
Expand Down
12 changes: 6 additions & 6 deletions pkg/distributor/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,10 @@ func TestHandler_otlpDroppedMetricsPanic2(t *testing.T) {
resp := httptest.NewRecorder()
handler := OTLPHandler(100000, nil, false, true, limits, RetryConfig{}, nil, func(_ context.Context, pushReq *Request) error {
request, err := pushReq.WriteRequest()
assert.NoError(t, err)
assert.Len(t, request.Timeseries, 2)
t.Cleanup(pushReq.CleanUp)
require.NoError(t, err)
assert.Len(t, request.Timeseries, 1)
assert.False(t, request.SkipLabelNameValidation)
pushReq.CleanUp()
return nil
}, log.NewNopLogger())
handler.ServeHTTP(resp, req)
Expand All @@ -435,10 +435,10 @@ func TestHandler_otlpDroppedMetricsPanic2(t *testing.T) {
resp = httptest.NewRecorder()
handler = OTLPHandler(100000, nil, false, true, limits, RetryConfig{}, nil, func(_ context.Context, pushReq *Request) error {
request, err := pushReq.WriteRequest()
assert.NoError(t, err)
assert.Len(t, request.Timeseries, 10) // 6 buckets (including +Inf) + 2 sum/count + 2 from the first case
t.Cleanup(pushReq.CleanUp)
require.NoError(t, err)
assert.Len(t, request.Timeseries, 9) // 6 buckets (including +Inf) + 2 sum/count + 2 from the first case
assert.False(t, request.SkipLabelNameValidation)
pushReq.CleanUp()
return nil
}, log.NewNopLogger())
handler.ServeHTTP(resp, req)
Expand Down
10 changes: 0 additions & 10 deletions vendor/github.com/prometheus/prometheus/discovery/metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions vendor/github.com/prometheus/prometheus/rules/alerting.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 35 additions & 29 deletions vendor/github.com/prometheus/prometheus/scrape/scrape.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2032768

Please sign in to comment.