Skip to content

Commit

Permalink
Merge branch 'main' into log-4544
Browse files Browse the repository at this point in the history
  • Loading branch information
periklis authored Jan 10, 2024
2 parents ec67cd6 + 24fa648 commit 2e76bc6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/sources/query/template_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ Signature: `min(a interface{}, i ...interface{}) int64`
Example:

```template
{{ max 1 2 3 }} //output 1
{{ min 1 2 3 }} //output 1
```

## maxf
Expand Down
22 changes: 11 additions & 11 deletions pkg/logql/shardmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,7 @@ var rangeMergeMap = map[string]string{

func (m ShardMapper) mapRangeAggregationExpr(expr *syntax.RangeAggregationExpr, r *downstreamRecorder) (syntax.SampleExpr, uint64, error) {
if !expr.Shardable() {
exprStats, err := m.shards.GetStats(expr)
if err != nil {
return nil, 0, err
}
return expr, exprStats.Bytes, nil
return m.noOp(expr)
}

switch expr.Operation {
Expand Down Expand Up @@ -437,7 +433,7 @@ func (m ShardMapper) mapRangeAggregationExpr(expr *syntax.RangeAggregationExpr,
return nil, 0, err
}
if shards == 0 || !m.quantileOverTimeSharding {
return m.mapSampleExpr(expr, r)
return m.noOp(expr)
}

// quantile_over_time() by (foo) ->
Expand Down Expand Up @@ -465,12 +461,16 @@ func (m ShardMapper) mapRangeAggregationExpr(expr *syntax.RangeAggregationExpr,

default:
// don't shard if there's not an appropriate optimization
exprStats, err := m.shards.GetStats(expr)
if err != nil {
return nil, 0, err
}
return expr, exprStats.Bytes, nil
return m.noOp(expr)
}
}

func (m ShardMapper) noOp(expr *syntax.RangeAggregationExpr) (syntax.SampleExpr, uint64, error) {
exprStats, err := m.shards.GetStats(expr)
if err != nil {
return nil, 0, err
}
return expr, exprStats.Bytes, nil
}

func badASTMapping(got syntax.Expr) error {
Expand Down
25 changes: 24 additions & 1 deletion pkg/logql/shardmapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func TestMappingStrings(t *testing.T) {
}

func TestMapping(t *testing.T) {
m := NewShardMapper(ConstantShards(2), nilShardMetrics, []string{ShardQuantileOverTime})
m := NewShardMapper(ConstantShards(2), nilShardMetrics, []string{})

for _, tc := range []struct {
in string
Expand Down Expand Up @@ -1340,6 +1340,25 @@ func TestMapping(t *testing.T) {
},
},
},
{
in: `quantile_over_time(0.8, {foo="bar"} | unwrap bytes [5m]) by (cluster)`,
expr: &syntax.RangeAggregationExpr{
Operation: syntax.OpRangeTypeQuantile,
Params: float64p(0.8),
Left: &syntax.LogRange{
Left: &syntax.MatchersExpr{
Mts: []*labels.Matcher{mustNewMatcher(labels.MatchEqual, "foo", "bar")},
},
Unwrap: &syntax.UnwrapExpr{
Identifier: "bytes",
},
Interval: 5 * time.Minute,
},
Grouping: &syntax.Grouping{
Groups: []string{"cluster"},
},
},
},
} {
t.Run(tc.in, func(t *testing.T) {
ast, err := syntax.ParseExpr(tc.in)
Expand Down Expand Up @@ -1420,3 +1439,7 @@ func TestStringTrimming(t *testing.T) {
})
}
}

func float64p(v float64) *float64 {
return &v
}
4 changes: 4 additions & 0 deletions production/helm/loki/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Entries should include a reference to the pull request that introduced the chang

[//]: # (<AUTOMATED_UPDATES_LOCATOR> : do not remove this line. This locator is used by the CI pipeline to automatically create a changelog entry for each new Loki release. Add other chart versions and respective changelog entries bellow this line.)

## 5.41.5

- [BUGFIX] Added "swift" type object storage to resolve Loki HELM Chart error.

## 5.41.4

- [CHANGE] Use `/ingester/shutdown?terminate=false` for write `preStop` hook
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: loki
description: Helm chart for Grafana Loki in simple, scalable mode
type: application
appVersion: 2.9.3
version: 5.41.4
version: 5.41.5
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# loki

![Version: 5.41.4](https://img.shields.io/badge/Version-5.41.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.3](https://img.shields.io/badge/AppVersion-2.9.3-informational?style=flat-square)
![Version: 5.41.5](https://img.shields.io/badge/Version-5.41.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.3](https://img.shields.io/badge/AppVersion-2.9.3-informational?style=flat-square)

Helm chart for Grafana Loki in simple, scalable mode

Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ Create the service endpoint including port for MinIO.

{{/* Determine if deployment is using object storage */}}
{{- define "loki.isUsingObjectStorage" -}}
{{- or (eq .Values.loki.storage.type "gcs") (eq .Values.loki.storage.type "s3") (eq .Values.loki.storage.type "azure") -}}
{{- or (eq .Values.loki.storage.type "gcs") (eq .Values.loki.storage.type "s3") (eq .Values.loki.storage.type "azure") (eq .Values.loki.storage.type "swift") -}}
{{- end -}}

{{/* Configure the correct name for the memberlist service */}}
Expand Down

0 comments on commit 2e76bc6

Please sign in to comment.