Skip to content

Commit

Permalink
feat(helm): Adding KEDA autoscaling support (#7282)
Browse files Browse the repository at this point in the history
* feat(helm): Adding KEDA autoscaling support

* fix: update changelog

* feat(helm): Porting the changes from #6971 into helm chart

* feat: Adding better changelog & values documentation outlining the experimental state of the feature, using the same autoscaling rules & behaviours as jsonnet, only supporting newest version of KEDA

* fix: Remove duplicate query field, add base url in CHANGELOG.md

* helm: align grpc server connection lifetime settings with jsonnet (#7269)

* helm: align grpc server connection lifetime settings with jsonnet

Co-authored-by: Marco Pracucci <[email protected]>
Signed-off-by: Vladimir Varankin <[email protected]>

* helm: rebuild tests

Signed-off-by: Vladimir Varankin <[email protected]>

---------

Signed-off-by: Vladimir Varankin <[email protected]>
Co-authored-by: Marco Pracucci <[email protected]>

* querymiddleware: Fix race condition in shardActiveSeriesMiddleware (#7290)

* querymiddleware: race condition in shardActiveSeriesMiddleware

s2.Writer is not goroutine-safe to reuse between concurrent
requests.

Signed-off-by: Vladimir Varankin <[email protected]>

* querymiddleware: remove flaky ResponseBodyStreamed test from shardActiveSeriesMiddleware

---------

Signed-off-by: Vladimir Varankin <[email protected]>

* version: add UserAgent() (#7264)

Update pkg/util/version/info.go
Update pkg/mimirtool/client/client.go

Signed-off-by: Vladimir Varankin <[email protected]>
Co-authored-by: Andy Asp <[email protected]>

* helm: remove -server.grpc.keepalive.max-connection-idle from common config (#7298)

Signed-off-by: Vladimir Varankin <[email protected]>

* Compactor: export estimated number of compaction jobs based on bucket-index (#7299)

* Compute number of compaction jobs from bucket index and export it via cortex_bucket_index_compaction_jobs metric.

Signed-off-by: Peter Štibraný <[email protected]>

* Add PR number.

Signed-off-by: Peter Štibraný <[email protected]>

* Remove unused parameter name.

Signed-off-by: Peter Štibraný <[email protected]>

* Make linter happy.

Signed-off-by: Peter Štibraný <[email protected]>

* Address review feedback.

Signed-off-by: Peter Štibraný <[email protected]>

* Fix tests.

Signed-off-by: Peter Štibraný <[email protected]>

---------

Signed-off-by: Peter Štibraný <[email protected]>

* Add KubePersistentVolumeFillingUp runbook (#7297)

* Add KubePersistentVolumeFillingUp runbook

Co-authored-by: Arve Knudsen <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>

* Added CHANGELOG entry

Signed-off-by: Marco Pracucci <[email protected]>

* Fixed linter

Signed-off-by: Marco Pracucci <[email protected]>

---------

Signed-off-by: Marco Pracucci <[email protected]>
Co-authored-by: Arve Knudsen <[email protected]>

* Internal: remove unnecessary parameter to NoCompactionMarkFilter (#7301)

* Remove unnecessary parameter to NewNoCompactionMarkFilter.

Signed-off-by: Peter Štibraný <[email protected]>

* Remove unnecessary parameter to NewNoCompactionMarkFilter.

Signed-off-by: Peter Štibraný <[email protected]>

---------

Signed-off-by: Peter Štibraný <[email protected]>

* Name query metrics for easier discovery (#7302)

Changes the way query metrics are named to make them easier to search for.

Signed-off-by: Nick Pillitteri <[email protected]>

* fix(deps): update module github.com/aws/aws-sdk-go to v1.50.11 (#7288)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/klauspost/compress to v1.17.6 (#7291)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update anchore/sbom-action action to v0.15.8 (#7286)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update grafana/agent docker tag to v0.39.2 (#7287)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update grafana/grafana docker tag to v10.3.1 (#7292)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/failsafe-go/failsafe-go to v0.4.4 (#7289)

Signed-off-by: Arve Knudsen <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Chore: removed unused parameter from GenerateBlockFromSpec() (#7303)

* Chore: removed unused parameter from GenerateBlockFromSpec()

Signed-off-by: Marco Pracucci <[email protected]>

* Removed unused variables

Signed-off-by: Marco Pracucci <[email protected]>

---------

Signed-off-by: Marco Pracucci <[email protected]>

* Update mimir-prometheus (#7293)

* Update mimir-prometheus

Signed-off-by: Marco Pracucci <[email protected]>

* Do not shard histogram_avg()

Signed-off-by: Marco Pracucci <[email protected]>

* Re-vendored

Signed-off-by: Marco Pracucci <[email protected]>

* Fix TestBucketStore_Series_ShouldQueryBlockWithOutOfOrderChunks

Signed-off-by: Marco Pracucci <[email protected]>

* Fix TestGroupCompactE2E

Signed-off-by: Marco Pracucci <[email protected]>

* Fixed TestMultitenantCompactor_OutOfOrderCompaction

Signed-off-by: Marco Pracucci <[email protected]>

* Reworked TestBucketStore_Series_ShouldQueryBlockWithOutOfOrderChunks

Signed-off-by: Marco Pracucci <[email protected]>

* Simplify TestBucketStore_Series_ShouldQueryBlockWithOutOfOrderChunks

Signed-off-by: Marco Pracucci <[email protected]>

* Use filepath.Join() instead of hardcoding path separator

Signed-off-by: Marco Pracucci <[email protected]>

---------

Signed-off-by: Marco Pracucci <[email protected]>

* Release mimir-distributed Helm chart 5.3.0-weekly.276 (#7294)

* Update mimir-distributed chart to 5.2.0-weekly.276

* Update version to 5.3.0

Signed-off-by: Dimitar Dimitrov <[email protected]>

---------

Signed-off-by: Dimitar Dimitrov <[email protected]>
Co-authored-by: grafanabot <[email protected]>
Co-authored-by: Dimitar Dimitrov <[email protected]>

* Open circuit breakers on timeouts and per-instance limit errors only (#7310)

* Open circuit breakers on timeouts and per-instance limit errors only

Signed-off-by: Yuri Nikolic <[email protected]>

* Update CHANGELOG

Signed-off-by: Yuri Nikolic <[email protected]>

---------

Signed-off-by: Yuri Nikolic <[email protected]>

* Get rid of iterators.chunkIterator and iterators.chunkMergeIterator (#7313)

* Get rid of iterators.chunkIterator and iterators.chunkMergeIterator

Signed-off-by: Yuri Nikolic <[email protected]>

* Fixing review findings

Signed-off-by: Yuri Nikolic <[email protected]>

---------

Signed-off-by: Yuri Nikolic <[email protected]>

* Compactor: Language fixes (#7315)

Signed-off-by: Arve Knudsen <[email protected]>

* Do not register compat metrics in mimirtool (#7314)

This commit does the same as we did for amtool in
prometheus/alertmanager#3713. There is no need to register these
metrics, so we use compat.NewMetrics(nil) instead of
compat.RegisteredMetrics.

* Compactor: Un-export symbols that don't need to be exported (#7317)

Signed-off-by: Arve Knudsen <[email protected]>

* Circuit breakers: add client.ErrCircuitBreakerOpen type (#7324)

Signed-off-by: Yuri Nikolic <[email protected]>

* Add mimirpb.CIRCUIT_BREAKER_OPEN error cause (#7330)

* Add mimirpb.CIRCUIT_BREAKER_OPEN error cause

Signed-off-by: Yuri Nikolic <[email protected]>

* Fixing review findings

Signed-off-by: Yuri Nikolic <[email protected]>

---------

Signed-off-by: Yuri Nikolic <[email protected]>

* store-gateway: remove cortex_bucket_store_blocks_loaded_by_duration (#7309)

* store-gateway: remove cortex_bucket_store_blocks_loaded_by_duration

The PR which added this metric 6074, the motivation was to help detect compactors which are falling behind. There is another metric `cortex_bucket_store_series_blocks_queried` added by jhalterman in 7112 which serves better the purpose of detecting uncompacted blocks. The reason is that it has an explicit label for uncompacted blocks, and it also is more sensitive to recent blocks (assuming those are queried much more often than old uncompacted blocks).

Signed-off-by: Dimitar Dimitrov <[email protected]>

* Add CHANGELOG.md entry

Signed-off-by: Dimitar Dimitrov <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Nick Pillitteri <[email protected]>

* Update code comment

Signed-off-by: Dimitar Dimitrov <[email protected]>

---------

Signed-off-by: Dimitar Dimitrov <[email protected]>
Co-authored-by: Nick Pillitteri <[email protected]>

* ruler: don't retry on non-retriable error (#7216)

* ruler: don't retry on non-retriable error

Fix 6609

Signed-off-by: Vladimir Varankin <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Dimitar Dimitrov <[email protected]>

---------

Signed-off-by: Vladimir Varankin <[email protected]>
Co-authored-by: Dimitar Dimitrov <[email protected]>

* Update Alertmanager to f69a508 (#7332)

* Update Alertmanager to f69a508

This commit updates Alertmanager to f69a508. The compat package
metrics are removed, and the tests are updated to check that
logs are emitted instead.

* Fix lint

* Fix lint again

* Use strings.Trim instead of subslice

* Remove integration test TestAlertmanagerMatchersMetrics

* Fix lint

* Prevent configurations with WebhookURLFile

This commit updates the validation rules to prevent Alertmanager
configurations for Discord and Microsoft Teams from using
WebhookURLFile.

* Add additional checks and tests for HTTPConfig

* Fix missing nil check

* Check for embedded HTTPConfig is not needed

* Helm: add ruler specific service account (#7132)

* Helm: add ruler specific service account

Signed-off-by: QuantumEnigmaa <[email protected]>

* add suggestions from review

Signed-off-by: QuantumEnigmaa <[email protected]>

* disable ruler sa by default

* add rolebinding to ruler sa

Signed-off-by: QuantumEnigmaa <[email protected]>

* remove trailing space

Signed-off-by: QuantumEnigmaa <[email protected]>

* update handling of ruler sa name

Signed-off-by: QuantumEnigmaa <[email protected]>

* add doc comment for ruler sa name

Signed-off-by: QuantumEnigmaa <[email protected]>

---------

Signed-off-by: QuantumEnigmaa <[email protected]>

* frontend/transport: log non-2xx replies from downstream as non-successful (#7296)

Signed-off-by: Vladimir Varankin <[email protected]>

* querymiddleware: Pool snappy writer in shard activity series (#7308)

* querymiddleware: pool snappy writer in shard activity series

Signed-off-by: Vladimir Varankin <[email protected]>

* test concurrent requests in shard active series

---------

Signed-off-by: Vladimir Varankin <[email protected]>

* Helm: make PSP configurable (#7190)

* Helm: make PSP configurable

Signed-off-by: QuantumEnigmaa <[email protected]>

* fix changelog

Signed-off-by: QuantumEnigmaa <[email protected]>

* fix psp rendering

Signed-off-by: QuantumEnigmaa <[email protected]>

* Update operations/helm/charts/mimir-distributed/CHANGELOG.md

---------

Signed-off-by: QuantumEnigmaa <[email protected]>
Co-authored-by: Dimitar Dimitrov <[email protected]>

* Helm - Templatable host for gateway ingress/route (#7218)

* feat: added host templating for gateway ingress

* feat: added host templating for gateway route

* fix: missing ctx ref

* Revert "fix: missing ctx ref"

This reverts commit cf956fb.

* fix: missing ctx ref

* ci: ran make build-helm-tests

* updated CHANGELOG.md

* fix: re-ordered changelog

* feat: added templating to global ingress

* fix: added templating to host rules

* docs: values.yaml examples

* test: rebuild tests according to examples

---------

Co-authored-by: Dimitar Dimitrov <[email protected]>

* [Docs] Update migrate-from-single-zone-with-helm.md (#7327)

* Update migrate-from-single-zone-with-helm.md

Fix typo beaching->breaching.

* Update changelog

* Always sort labels in distributors (#7326)

* Always sort labels in distributors

Previously, disabling metric relabelling would also disable label
sorting.

Fixes #7320

* Update comment about sorting

* Update CHANGELOG

* Do not check for ingester ring state before creating TSDB, or compacting / shipping blocks (#7322)

* Do not check for ingester ring state before creating TSDB, or compacting / shipping blocks

Signed-off-by: Marco Pracucci <[email protected]>

* Removed unused param

Signed-off-by: Marco Pracucci <[email protected]>

---------

Signed-off-by: Marco Pracucci <[email protected]>

* Compactor: String format compaction plan as comma separated blocks (#7321)

* Compactor: Format directories as comma separated string

Signed-off-by: Arve Knudsen <[email protected]>

* Compactor: string format plan as comma separated blocks

Signed-off-by: Arve Knudsen <[email protected]>

* Harmonize log message field names

Signed-off-by: Arve Knudsen <[email protected]>

---------

Signed-off-by: Arve Knudsen <[email protected]>

* Add a lifetime manager for Vault authentication tokens (#7337)

* Initial renewal implementation

* Add metrics and integration test to test token renewal

* remove unneeeded comment

* Update CHANGELOG.md

* Use promauto

* address comments

* Use global const for Vault image

* Add failure metric

* Update metrics

* Update CHANGELOG and mark as experimental

* include metric names in about-versioning

* fix(deps): update github.com/grafana/dskit digest to f245b48 (#7283)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Packaging: remove reload from systemd file as mimir does not take into account SIGHUP (#7345)

Signed-off-by: Wilfried Roset <[email protected]>

* Docs: No longer mark OTLP endpoint as experimental (#7348)

Signed-off-by: Arve Knudsen <[email protected]>

* Update golang.org/x/exp digest to 2c58cdc (#7352)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update module github.com/aws/aws-sdk-go to v1.50.15 (#7353)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update module github.com/minio/minio-go/v7 to v7.0.67 (#7354)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update dependency puppeteer to v21.11.0 (#7355)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update helm/kind-action action to v1.9.0 (#7357)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update module cloud.google.com/go/storage to v1.37.0 (#7358)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Jsonnet / Helm: improve distributors graceful shutdown (#7361)

* Jsonnet / Helm: improve distributors graceful shutdown

Signed-off-by: Marco Pracucci <[email protected]>

* Fix Helm distributor termination grace period

Signed-off-by: Marco Pracucci <[email protected]>

---------

Signed-off-by: Marco Pracucci <[email protected]>

* Release mimir-distributed Helm chart 5.3.0-weekly.277 (#7362)

Co-authored-by: grafanabot <[email protected]>

* Distributor: Make `-distributor.enable-otlp-metadata-storage` flag default to true, and deprecate (#7366)

* Distributor: Change -distributor.enable-otlp-metadata-storage flag's default to true and deprecate

---------

Signed-off-by: Arve Knudsen <[email protected]>

* Mark -ingester.limit-inflight-requests-using-grpc-method-limiter and -distributor.limit-inflight-requests-using-grpc-method-limiter as stable and enable it by default (#7360)

* Mark -ingester.limit-inflight-requests-using-grpc-method-limiter and -distributor.limit-inflight-requests-using-grpc-method-limiter as stable and enable it by default

Signed-off-by: Marco Pracucci <[email protected]>

* Improved tests

Signed-off-by: Marco Pracucci <[email protected]>

* Improved tests

Signed-off-by: Marco Pracucci <[email protected]>

* Fixed unit tests

Signed-off-by: Marco Pracucci <[email protected]>

* Mark config as deprecated

Signed-off-by: Marco Pracucci <[email protected]>

---------

Signed-off-by: Marco Pracucci <[email protected]>

* Do not consider out-of-order blocks when filtering compactable jobs (#7342)

* Do not consider out-of-order blocks when filtering compactable jobs

Co-authored-by: Marco Pracucci <[email protected]>

* mimir: Inject span profiler into tracer (#7363)

* mimir: inject span profiler into tracer

Signed-off-by: Vladimir Varankin <[email protected]>

* Update changelog

Signed-off-by: Vladimir Varankin <[email protected]>

---------

Signed-off-by: Vladimir Varankin <[email protected]>

* Add experimental partitions ring lifecycler support (#7349)

* Add experimental partitions ring lifecycler support

Signed-off-by: Marco Pracucci <[email protected]>
Co-authored-by: Dimitar Dimitrov <[email protected]>
Co-authored-by: Peter Štibraný <[email protected]>

* Use http.Error()

Signed-off-by: Marco Pracucci <[email protected]>

* Skip deprecated linter check for code that will be soon replaced

Signed-off-by: Marco Pracucci <[email protected]>

* Updated dskit

Signed-off-by: Marco Pracucci <[email protected]>

* Add partition id to logs

Signed-off-by: Marco Pracucci <[email protected]>

* Added comment

Signed-off-by: Marco Pracucci <[email protected]>

* Added TestIngester_ShouldNotCreatePartitionIfThereIsShutdownMarker

Signed-off-by: Marco Pracucci <[email protected]>

---------

Signed-off-by: Marco Pracucci <[email protected]>
Co-authored-by: Dimitar Dimitrov <[email protected]>
Co-authored-by: Peter Štibraný <[email protected]>

* feat(helm): Adding KEDA autoscaling support

* chore: rebase branch with main

* chore: make build-helm-tests

---------

Signed-off-by: Vladimir Varankin <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Nick Pillitteri <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Dimitar Dimitrov <[email protected]>
Signed-off-by: Yuri Nikolic <[email protected]>
Signed-off-by: QuantumEnigmaa <[email protected]>
Signed-off-by: Wilfried Roset <[email protected]>
Co-authored-by: Vladimir Varankin <[email protected]>
Co-authored-by: Marco Pracucci <[email protected]>
Co-authored-by: Andy Asp <[email protected]>
Co-authored-by: Peter Štibraný <[email protected]>
Co-authored-by: Arve Knudsen <[email protected]>
Co-authored-by: Nick Pillitteri <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Grot (@grafanabot) <[email protected]>
Co-authored-by: grafanabot <[email protected]>
Co-authored-by: Dimitar Dimitrov <[email protected]>
Co-authored-by: Đurica Yuri Nikolić <[email protected]>
Co-authored-by: George Robinson <[email protected]>
Co-authored-by: Zirko <[email protected]>
Co-authored-by: Itay Kalfon <[email protected]>
Co-authored-by: Éamon Ryan <[email protected]>
Co-authored-by: Patrick Oyarzun <[email protected]>
Co-authored-by: Fayzal Ghantiwala <[email protected]>
Co-authored-by: Wilfried ROSET <[email protected]>
Co-authored-by: Jonathan Halterman <[email protected]>
  • Loading branch information
20 people authored Feb 13, 2024
1 parent 2b34ad3 commit 55950ca
Show file tree
Hide file tree
Showing 148 changed files with 9,186 additions and 149 deletions.
1 change: 1 addition & 0 deletions operations/helm/charts/mimir-distributed/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Entries should include a reference to the Pull Request that introduced the chang

## main / unreleased

* [FEATURE] Added experimental feature for deploying [KEDA](https://keda.sh) ScaledObjects as part of the helm chart for the components: distributor, querier, query-frontend and ruler. Autoscaling can be enabled via `distributor.kedaAutoscaling`, `ruler.kedaAutoscaling`, `query_frontend.kedaAutoscaling`, and `querier.kedaAutoscaling`. Requires metamonitoring, for more details on metamonitoring see [Monitor the health of your system](https://grafana.com/docs/helm-charts/mimir-distributed/latest/run-production-environment-with-helm/monitor-system-health/). See [grafana/mimir#7367](https://github.com/grafana/mimir/issues/7367) for a migration procedure. #7282
* [CHANGE] Rollout-operator: remove default CPU limit. #7125
* [CHANGE] Ring: relaxed the hash ring heartbeat period and timeout for distributor, ingester, store-gateway and compactor: #6860
* `-distributor.ring.heartbeat-period` set to `1m`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Pin kube version so results are the same for running in CI and locally where the installed kube version may be different.
kubeVersionOverride: "1.20"

metaMonitoring:
grafanaAgent:
metrics:
enabled: false
remote:
url: https://mimir.example.com/api/v1/push # test with setting a different remote for the monitoring

distributor:
kedaAutoscaling:
enabled: true
minReplicaCount: 1
maxReplicaCount: 10
pollingInterval: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
customHeaders:
X-Scope-OrgID: tenant-1

ruler:
kedaAutoscaling:
enabled: true
minReplicaCount: 1
maxReplicaCount: 10
pollingInterval: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
customHeaders:
X-Scope-OrgID: tenant-1

querier:
kedaAutoscaling:
enabled: true
minReplicaCount: 2
maxReplicaCount: 10
pollingInterval: 10
querySchedulerInflightRequestsThreshold: 6
customHeaders:
X-Scope-OrgID: tenant-1

query_frontend:
kedaAutoscaling:
enabled: true
minReplicaCount: 1
maxReplicaCount: 10
pollingInterval: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
customHeaders:
X-Scope-OrgID: tenant-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Pin kube version so results are the same for running in CI and locally where the installed kube version may be different.
kubeVersionOverride: "1.20"

metaMonitoring:
grafanaAgent:
metrics:
enabled: false
# Leave the remote empty to use the default to send it to Mimir directly
# remote: #

distributor:
kedaAutoscaling:
enabled: true
minReplicaCount: 1
maxReplicaCount: 10
pollingInterval: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
customHeaders:
X-Scope-OrgID: tenant-1

ruler:
kedaAutoscaling:
enabled: true
minReplicaCount: 1
maxReplicaCount: 10
pollingInterval: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
customHeaders:
X-Scope-OrgID: tenant-1

querier:
kedaAutoscaling:
enabled: true
minReplicaCount: 2
maxReplicaCount: 10
pollingInterval: 10
querySchedulerInflightRequestsThreshold: 6
customHeaders:
X-Scope-OrgID: tenant-1

query_frontend:
kedaAutoscaling:
enabled: true
minReplicaCount: 1
maxReplicaCount: 10
pollingInterval: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
customHeaders:
X-Scope-OrgID: tenant-1
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,10 @@ Return if we should create a SecurityContextConstraints. Takes into account user
{{ include "mimir.gatewayUrl" . }}/api/v1/push
{{- end -}}

{{- define "mimir.remoteReadUrl.inCluster" -}}
{{ include "mimir.gatewayUrl" . }}{{ include "mimir.prometheusHttpPrefix" . }}
{{- end -}}

{{/*
Creates dict for zone-aware replication configuration
Params:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ metadata:
{{- toYaml .Values.distributor.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- if not .Values.distributor.kedaAutoscaling.enabled }}
# If replicas is not number (when using values file it's float64, when using --set arg it's int64) and is false (i.e. null) don't set it
{{- if or (or (kindIs "int64" .Values.distributor.replicas) (kindIs "float64" .Values.distributor.replicas)) (.Values.distributor.replicas) }}
replicas: {{ .Values.distributor.replicas }}
{{- end }}
{{- end }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "distributor" "memberlist" true) | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{- if .Values.distributor.kedaAutoscaling.enabled }}
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "distributor") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "distributor") | nindent 4 }}
annotations:
{{- toYaml .Values.distributor.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
advanced:
horizontalPodAutoscalerConfig:
{{- with .Values.distributor.kedaAutoscaling.behavior }}
behavior:
{{- toYaml . | nindent 8 }}
{{- end }}
maxReplicaCount: {{ .Values.distributor.kedaAutoscaling.maxReplicaCount }}
minReplicaCount: {{ .Values.distributor.kedaAutoscaling.minReplicaCount }}
pollingInterval: {{ .Values.distributor.kedaAutoscaling.pollingInterval }}
scaleTargetRef:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "distributor") }}
apiVersion: apps/v1
kind: Deployment
triggers:
- metadata:
query: max_over_time(sum(sum by (pod) (rate(container_cpu_usage_seconds_total{container="distributor",namespace="{{ .Release.Namespace }}"}[5m])) and max by (pod) (up{container="distributor",namespace="{{ .Release.Namespace }}"}) > 0)[15m:]) * 1000
serverAddress: {{ include "mimir.metaMonitoring.metrics.remoteReadUrl" (dict "ctx" $) }}
{{- $cpu_request := dig "requests" "cpu" nil .Values.distributor.resources }}
threshold: {{ mulf (include "mimir.parseCPU" (dict "value" $cpu_request)) (divf .Values.distributor.kedaAutoscaling.targetCPUUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.distributor.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.distributor.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
type: prometheus
- metadata:
query: max_over_time(sum((sum by (pod) (container_memory_working_set_bytes{container="distributor",namespace="{{ .Release.Namespace }}"}) and max by (pod) (up{container="distributor",namespace="{{ .Release.Namespace }}"}) > 0) or vector(0))[15m:]) + sum(sum by (pod) (max_over_time(kube_pod_container_resource_requests{container="distributor",namespace="{{ .Release.Namespace }}", resource="memory"}[15m])) and max by (pod) (changes(kube_pod_container_status_restarts_total{container="distributor",namespace="{{ .Release.Namespace }}"}[15m]) > 0) and max by (pod) (kube_pod_container_status_last_terminated_reason{container="distributor",namespace="{{ .Release.Namespace }}", reason="OOMKilled"}) or vector(0))
serverAddress: {{ include "mimir.metaMonitoring.metrics.remoteReadUrl" (dict "ctx" $) }}
{{- $mem_request := dig "requests" "memory" nil .Values.distributor.resources }}
threshold: {{ mulf (include "mimir.siToBytes" (dict "value" $mem_request)) (divf .Values.distributor.kedaAutoscaling.targetMemoryUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.distributor.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.distributor.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
type: prometheus
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{/*
Convert labels to string like: key1=value1, key2=value2, ...
Example:
customHeaders:
X-Scope-OrgID: tenant-1
becomes:
customHeaders: "X-Scope-OrgID=tenant-1"
Params:
map = map to convert to csv string
*/}}
{{- define "mimir.lib.mapToCSVString" -}}
{{- $list := list -}}
{{- range $k, $v := $.map -}}
{{- $list = append $list (printf "%s=%s" $k $v) -}}
{{- end -}}
{{ join "," $list }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@
cluster: {{ include "mimir.clusterName" $.ctx | quote}}
{{- end -}}
{{- end -}}

{{- define "mimir.metaMonitoring.metrics.remoteReadUrl" -}}
{{- with $.ctx.Values.metaMonitoring.grafanaAgent.metrics }}
{{- $writeBackToMimir := not (.remote).url -}}
{{- if $writeBackToMimir -}}
{{- include "mimir.remoteReadUrl.inCluster" $.ctx }}
{{- else -}}
{{- $parsed := urlParse (.remote).url -}}
{{ $parsed.scheme }}://{{ $parsed.host }}/prometheus
{{- end }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ metadata:
{{- toYaml .Values.querier.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- if not .Values.querier.kedaAutoscaling.enabled }}
# If replicas is not number (when using values file it's float64, when using --set arg it's int64) and is false (i.e. null) don't set it
{{- if or (or (kindIs "int64" .Values.querier.replicas) (kindIs "float64" .Values.querier.replicas)) (.Values.querier.replicas) }}
replicas: {{ .Values.querier.replicas }}
{{- end }}
{{- end }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "querier" "memberlist" true) | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- if .Values.querier.kedaAutoscaling.enabled }}
{{- if not .Values.query_scheduler.enabled }}
{{- fail "KEDA autoscaling for querier requires query scheduler to be enabled" }}
{{- end }}
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "querier") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "querier") | nindent 4 }}
annotations:
{{- toYaml .Values.querier.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
advanced:
horizontalPodAutoscalerConfig:
{{- with .Values.querier.kedaAutoscaling.behavior }}
behavior:
{{- toYaml . | nindent 8 }}
{{- end }}
maxReplicaCount: {{ .Values.querier.kedaAutoscaling.maxReplicaCount }}
minReplicaCount: {{ .Values.querier.kedaAutoscaling.minReplicaCount }}
pollingInterval: {{ .Values.querier.kedaAutoscaling.pollingInterval }}
scaleTargetRef:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "querier") }}
apiVersion: apps/v1
kind: Deployment
triggers:
- metadata:
query: sum(max_over_time(cortex_query_scheduler_inflight_requests{container="query-scheduler",namespace="{{ .Release.Namespace }}",quantile="0.5"}[1m]))
serverAddress: {{ include "mimir.metaMonitoring.metrics.remoteReadUrl" (dict "ctx" $) }}
threshold: {{ .Values.querier.kedaAutoscaling.querySchedulerInflightRequestsThreshold | quote }}
{{- if .Values.querier.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.querier.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
name: cortex_querier_hpa_default
type: prometheus
- metadata:
query: sum(rate(cortex_querier_request_duration_seconds_sum{container="querier",namespace="{{ .Release.Namespace }}"}[1m]))
serverAddress: {{ include "mimir.metaMonitoring.metrics.remoteReadUrl" (dict "ctx" $) }}
threshold: {{ .Values.querier.kedaAutoscaling.querySchedulerInflightRequestsThreshold | quote }}
{{- if .Values.querier.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.querier.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
name: cortex_querier_hpa_default_requests_duration
type: prometheus
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ metadata:
{{- toYaml .Values.query_frontend.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- if not .Values.query_frontend.kedaAutoscaling.enabled }}
# If replicas is not number (when using values file it's float64, when using --set arg it's int64) and is false (i.e. null) don't set it
{{- if or (or (kindIs "int64" .Values.query_frontend.replicas) (kindIs "float64" .Values.query_frontend.replicas)) (.Values.query_frontend.replicas) }}
replicas: {{ .Values.query_frontend.replicas }}
{{- end }}
{{- end }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "query-frontend") | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{- if .Values.query_frontend.kedaAutoscaling.enabled }}
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "query-frontend") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "query-frontend") | nindent 4 }}
annotations:
{{- toYaml .Values.query_frontend.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
advanced:
horizontalPodAutoscalerConfig:
{{- with .Values.query_frontend.kedaAutoscaling.behavior }}
behavior:
{{- toYaml . | nindent 8 }}
{{- end }}
maxReplicaCount: {{ .Values.query_frontend.kedaAutoscaling.maxReplicaCount }}
minReplicaCount: {{ .Values.query_frontend.kedaAutoscaling.minReplicaCount }}
pollingInterval: {{ .Values.query_frontend.kedaAutoscaling.pollingInterval }}
scaleTargetRef:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "query-frontend") }}
apiVersion: apps/v1
kind: Deployment
triggers:
- metadata:
query: max_over_time(sum(sum by (pod) (rate(container_cpu_usage_seconds_total{container="query-frontend",namespace="{{ .Release.Namespace }}"}[5m])) and max by (pod) (up{container="query-frontend",namespace="{{ .Release.Namespace }}"}) > 0)[15m:]) * 1000
serverAddress: {{ include "mimir.metaMonitoring.metrics.remoteReadUrl" (dict "ctx" $) }}
{{- $cpu_request := dig "requests" "cpu" nil .Values.query_frontend.resources }}
threshold: {{ mulf (include "mimir.parseCPU" (dict "value" $cpu_request)) (divf .Values.query_frontend.kedaAutoscaling.targetCPUUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.query_frontend.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.query_frontend.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
type: prometheus
- metadata:
query: max_over_time(sum((sum by (pod) (container_memory_working_set_bytes{container="query-frontend",namespace="{{ .Release.Namespace }}"}) and max by (pod) (up{container="query-frontend",namespace="{{ .Release.Namespace }}"}) > 0) or vector(0))[15m:]) + sum(sum by (pod) (max_over_time(kube_pod_container_resource_requests{container="query-frontend",namespace="{{ .Release.Namespace }}", resource="memory"}[15m])) and max by (pod) (changes(kube_pod_container_status_restarts_total{container="query-frontend",namespace="{{ .Release.Namespace }}"}[15m]) > 0) and max by (pod) (kube_pod_container_status_last_terminated_reason{container="query-frontend",namespace="{{ .Release.Namespace }}", reason="OOMKilled"}) or vector(0))
serverAddress: {{ include "mimir.metaMonitoring.metrics.remoteReadUrl" (dict "ctx" $) }}
{{- $mem_request := dig "requests" "memory" nil .Values.query_frontend.resources }}
threshold: {{ mulf (include "mimir.siToBytes" (dict "value" $mem_request)) (divf .Values.query_frontend.kedaAutoscaling.targetMemoryUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.query_frontend.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.query_frontend.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
type: prometheus
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- if .Values.ruler.kedaAutoscaling.enabled }}
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "ruler") }}
labels:
{{- include "mimir.labels" (dict "ctx" . "component" "ruler" "memberlist" true) | nindent 4 }}
annotations:
{{- toYaml .Values.ruler.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
advanced:
horizontalPodAutoscalerConfig:
{{- with .Values.ruler.kedaAutoscaling.behavior }}
behavior:
{{- toYaml . | nindent 8 }}
{{- end }}
maxReplicaCount: {{ .Values.ruler.kedaAutoscaling.maxReplicaCount }}
minReplicaCount: {{ .Values.ruler.kedaAutoscaling.minReplicaCount }}
pollingInterval: {{ .Values.ruler.kedaAutoscaling.pollingInterval }}
scaleTargetRef:
name: {{ include "mimir.resourceName" (dict "ctx" . "component" "ruler") }}
apiVersion: apps/v1
kind: Deployment
triggers:
- metadata:
metricName: ruler_cpu_hpa_default
query: max_over_time(sum(rate(container_cpu_usage_seconds_total{container="ruler",namespace="{{ .Release.Namespace }}"}[5m]))[15m:]) * 1000
serverAddress: {{ include "mimir.metaMonitoring.metrics.remoteReadUrl" (dict "ctx" $) }}
{{- $cpu_request := dig "requests" "cpu" nil .Values.ruler.resources }}
threshold: {{ mulf (include "mimir.parseCPU" (dict "value" $cpu_request)) (divf .Values.ruler.kedaAutoscaling.targetCPUUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.ruler.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.ruler.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
type: prometheus
- metadata:
metricName: ruler_memory_hpa_default
query: max_over_time(sum(container_memory_working_set_bytes{container="ruler",namespace="{{ .Release.Namespace }}"})[15m:])
serverAddress: {{ include "mimir.metaMonitoring.metrics.remoteReadUrl" (dict "ctx" $) }}
{{- $mem_request := dig "requests" "memory" nil .Values.ruler.resources }}
threshold: {{ mulf (include "mimir.siToBytes" (dict "value" $mem_request)) (divf .Values.ruler.kedaAutoscaling.targetMemoryUtilizationPercentage 100) | floor | int64 | quote }}
{{- if .Values.ruler.kedaAutoscaling.customHeaders }}
customHeaders: {{ (include "mimir.lib.mapToCSVString" (dict "map" .Values.ruler.kedaAutoscaling.customHeaders)) | quote }}
{{- end }}
type: prometheus
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ metadata:
{{- toYaml .Values.ruler.annotations | nindent 4 }}
namespace: {{ .Release.Namespace | quote }}
spec:
{{- if not .Values.ruler.kedaAutoscaling.enabled }}
replicas: {{ .Values.ruler.replicas }}
{{- end }}
selector:
matchLabels:
{{- include "mimir.selectorLabels" (dict "ctx" . "component" "ruler" "memberlist" true) | nindent 6 }}
Expand Down
Loading

0 comments on commit 55950ca

Please sign in to comment.