From bcdc807dd34d7a4e2e1dcfdffecd869da66e6efe Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Thu, 29 Jun 2023 20:57:20 +0200 Subject: [PATCH] operator: Expose limits config setting cardinality_limit (#9830) --- operator/CHANGELOG.md | 1 + operator/apis/loki/v1/lokistack_types.go | 7 +++++++ .../loki-operator.clusterserviceversion.yaml | 12 +++++++++++- .../manifests/loki.grafana.com_lokistacks.yaml | 10 ++++++++++ .../loki-operator.clusterserviceversion.yaml | 12 +++++++++++- .../manifests/loki.grafana.com_lokistacks.yaml | 10 ++++++++++ .../loki-operator.clusterserviceversion.yaml | 12 +++++++++++- .../manifests/loki.grafana.com_lokistacks.yaml | 10 ++++++++++ .../crd/bases/loki.grafana.com_lokistacks.yaml | 10 ++++++++++ .../bases/loki-operator.clusterserviceversion.yaml | 10 ++++++++++ .../bases/loki-operator.clusterserviceversion.yaml | 10 ++++++++++ .../bases/loki-operator.clusterserviceversion.yaml | 10 ++++++++++ operator/docs/operator/api.md | 12 ++++++++++++ .../internal/manifests/internal/config/build_test.go | 10 ++++++++++ .../manifests/internal/config/loki-config.yaml | 2 +- .../internal/config/loki-runtime-config.yaml | 3 +++ operator/internal/manifests/internal/sizes.go | 4 ++++ 17 files changed, 141 insertions(+), 4 deletions(-) diff --git a/operator/CHANGELOG.md b/operator/CHANGELOG.md index 6ffa62f9dd..7f7a7269c5 100644 --- a/operator/CHANGELOG.md +++ b/operator/CHANGELOG.md @@ -1,5 +1,6 @@ ## Main +- [9830](https://github.com/grafana/loki/pull/9830) **periklis**: Expose limits config setting cardinality_limit - [9600](https://github.com/grafana/loki/pull/9600) **periklis**: Add rules labels filters for openshift-logging application tenant - [9735](https://github.com/grafana/loki/pull/9735) **JoaoBraveCoding** Adjust 1x.extra-small resources according to findings - [9689](https://github.com/grafana/loki/pull/9689) **xperimental**: Fix availability of demo LokiStack size diff --git a/operator/apis/loki/v1/lokistack_types.go b/operator/apis/loki/v1/lokistack_types.go index 70ed9bccd7..21e8fde4e6 100644 --- a/operator/apis/loki/v1/lokistack_types.go +++ b/operator/apis/loki/v1/lokistack_types.go @@ -564,6 +564,13 @@ type QueryLimitSpec struct { // +kubebuilder:default:="3m" // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Query Timeout" QueryTimeout string `json:"queryTimeout,omitempty"` + + // CardinalityLimit defines the cardinality limit for index queries. + // + // +optional + // +kubebuilder:validation:Optional + // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors="urn:alm:descriptor:com.tectonic.ui:number",displayName="Cardinality Limit" + CardinalityLimit int32 `json:"cardinalityLimit,omitempty"` } // IngestionLimitSpec defines the limits applied at the ingestion path. diff --git a/operator/bundle/community-openshift/manifests/loki-operator.clusterserviceversion.yaml b/operator/bundle/community-openshift/manifests/loki-operator.clusterserviceversion.yaml index 806029fbc7..e3ec545ee3 100644 --- a/operator/bundle/community-openshift/manifests/loki-operator.clusterserviceversion.yaml +++ b/operator/bundle/community-openshift/manifests/loki-operator.clusterserviceversion.yaml @@ -150,7 +150,7 @@ metadata: categories: OpenShift Optional, Logging & Tracing certified: "false" containerImage: docker.io/grafana/loki-operator:main-ac1c1fd - createdAt: "2023-06-12T17:36:46Z" + createdAt: "2023-06-29T17:58:18Z" description: The Community Loki Operator provides Kubernetes native deployment and management of Loki and related logging components. operators.operatorframework.io/builder: operator-sdk-unknown @@ -341,6 +341,11 @@ spec: path: limits.global.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.global.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query @@ -420,6 +425,11 @@ spec: path: limits.tenants.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.tenants.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query diff --git a/operator/bundle/community-openshift/manifests/loki.grafana.com_lokistacks.yaml b/operator/bundle/community-openshift/manifests/loki.grafana.com_lokistacks.yaml index 14cb9648ed..d6ffdede14 100644 --- a/operator/bundle/community-openshift/manifests/loki.grafana.com_lokistacks.yaml +++ b/operator/bundle/community-openshift/manifests/loki.grafana.com_lokistacks.yaml @@ -145,6 +145,11 @@ spec: description: QueryLimits defines the limit applied on querying log streams. properties: + cardinalityLimit: + description: CardinalityLimit defines the cardinality + limit for index queries. + format: int32 + type: integer maxChunksPerQuery: description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. @@ -267,6 +272,11 @@ spec: description: QueryLimits defines the limit applied on querying log streams. properties: + cardinalityLimit: + description: CardinalityLimit defines the cardinality + limit for index queries. + format: int32 + type: integer maxChunksPerQuery: description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. diff --git a/operator/bundle/community/manifests/loki-operator.clusterserviceversion.yaml b/operator/bundle/community/manifests/loki-operator.clusterserviceversion.yaml index e81f5bc1e4..aead97e482 100644 --- a/operator/bundle/community/manifests/loki-operator.clusterserviceversion.yaml +++ b/operator/bundle/community/manifests/loki-operator.clusterserviceversion.yaml @@ -150,7 +150,7 @@ metadata: categories: OpenShift Optional, Logging & Tracing certified: "false" containerImage: docker.io/grafana/loki-operator:main-ac1c1fd - createdAt: "2023-06-12T17:36:41Z" + createdAt: "2023-06-29T17:58:15Z" description: The Community Loki Operator provides Kubernetes native deployment and management of Loki and related logging components. operators.operatorframework.io/builder: operator-sdk-unknown @@ -341,6 +341,11 @@ spec: path: limits.global.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.global.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query @@ -420,6 +425,11 @@ spec: path: limits.tenants.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.tenants.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query diff --git a/operator/bundle/community/manifests/loki.grafana.com_lokistacks.yaml b/operator/bundle/community/manifests/loki.grafana.com_lokistacks.yaml index 780822dd48..4c933b347e 100644 --- a/operator/bundle/community/manifests/loki.grafana.com_lokistacks.yaml +++ b/operator/bundle/community/manifests/loki.grafana.com_lokistacks.yaml @@ -145,6 +145,11 @@ spec: description: QueryLimits defines the limit applied on querying log streams. properties: + cardinalityLimit: + description: CardinalityLimit defines the cardinality + limit for index queries. + format: int32 + type: integer maxChunksPerQuery: description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. @@ -267,6 +272,11 @@ spec: description: QueryLimits defines the limit applied on querying log streams. properties: + cardinalityLimit: + description: CardinalityLimit defines the cardinality + limit for index queries. + format: int32 + type: integer maxChunksPerQuery: description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. diff --git a/operator/bundle/openshift/manifests/loki-operator.clusterserviceversion.yaml b/operator/bundle/openshift/manifests/loki-operator.clusterserviceversion.yaml index 0fe1378643..14a37978a5 100644 --- a/operator/bundle/openshift/manifests/loki-operator.clusterserviceversion.yaml +++ b/operator/bundle/openshift/manifests/loki-operator.clusterserviceversion.yaml @@ -150,7 +150,7 @@ metadata: categories: OpenShift Optional, Logging & Tracing certified: "false" containerImage: quay.io/openshift-logging/loki-operator:v0.1.0 - createdAt: "2023-06-12T17:36:51Z" + createdAt: "2023-06-29T17:58:20Z" description: | The Loki Operator for OCP provides a means for configuring and managing a Loki stack for cluster logging. ## Prerequisites and Requirements @@ -354,6 +354,11 @@ spec: path: limits.global.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.global.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query @@ -433,6 +438,11 @@ spec: path: limits.tenants.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.tenants.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query diff --git a/operator/bundle/openshift/manifests/loki.grafana.com_lokistacks.yaml b/operator/bundle/openshift/manifests/loki.grafana.com_lokistacks.yaml index bde43a4b27..ae149b380d 100644 --- a/operator/bundle/openshift/manifests/loki.grafana.com_lokistacks.yaml +++ b/operator/bundle/openshift/manifests/loki.grafana.com_lokistacks.yaml @@ -145,6 +145,11 @@ spec: description: QueryLimits defines the limit applied on querying log streams. properties: + cardinalityLimit: + description: CardinalityLimit defines the cardinality + limit for index queries. + format: int32 + type: integer maxChunksPerQuery: description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. @@ -267,6 +272,11 @@ spec: description: QueryLimits defines the limit applied on querying log streams. properties: + cardinalityLimit: + description: CardinalityLimit defines the cardinality + limit for index queries. + format: int32 + type: integer maxChunksPerQuery: description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. diff --git a/operator/config/crd/bases/loki.grafana.com_lokistacks.yaml b/operator/config/crd/bases/loki.grafana.com_lokistacks.yaml index 78e49cd1d0..b56e02fd9b 100644 --- a/operator/config/crd/bases/loki.grafana.com_lokistacks.yaml +++ b/operator/config/crd/bases/loki.grafana.com_lokistacks.yaml @@ -128,6 +128,11 @@ spec: description: QueryLimits defines the limit applied on querying log streams. properties: + cardinalityLimit: + description: CardinalityLimit defines the cardinality + limit for index queries. + format: int32 + type: integer maxChunksPerQuery: description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. @@ -250,6 +255,11 @@ spec: description: QueryLimits defines the limit applied on querying log streams. properties: + cardinalityLimit: + description: CardinalityLimit defines the cardinality + limit for index queries. + format: int32 + type: integer maxChunksPerQuery: description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. diff --git a/operator/config/manifests/community-openshift/bases/loki-operator.clusterserviceversion.yaml b/operator/config/manifests/community-openshift/bases/loki-operator.clusterserviceversion.yaml index ad8e8b303d..e5cb07855c 100644 --- a/operator/config/manifests/community-openshift/bases/loki-operator.clusterserviceversion.yaml +++ b/operator/config/manifests/community-openshift/bases/loki-operator.clusterserviceversion.yaml @@ -254,6 +254,11 @@ spec: path: limits.global.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.global.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query @@ -333,6 +338,11 @@ spec: path: limits.tenants.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.tenants.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query diff --git a/operator/config/manifests/community/bases/loki-operator.clusterserviceversion.yaml b/operator/config/manifests/community/bases/loki-operator.clusterserviceversion.yaml index cef4c8043c..209eabc5d2 100644 --- a/operator/config/manifests/community/bases/loki-operator.clusterserviceversion.yaml +++ b/operator/config/manifests/community/bases/loki-operator.clusterserviceversion.yaml @@ -254,6 +254,11 @@ spec: path: limits.global.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.global.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query @@ -333,6 +338,11 @@ spec: path: limits.tenants.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.tenants.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query diff --git a/operator/config/manifests/openshift/bases/loki-operator.clusterserviceversion.yaml b/operator/config/manifests/openshift/bases/loki-operator.clusterserviceversion.yaml index da6266ec0a..5ca4fdffc6 100644 --- a/operator/config/manifests/openshift/bases/loki-operator.clusterserviceversion.yaml +++ b/operator/config/manifests/openshift/bases/loki-operator.clusterserviceversion.yaml @@ -266,6 +266,11 @@ spec: path: limits.global.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.global.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query @@ -345,6 +350,11 @@ spec: path: limits.tenants.ingestion.perStreamRateLimitBurst x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number + - description: CardinalityLimit defines the cardinality limit for index queries. + displayName: Cardinality Limit + path: limits.tenants.queries.cardinalityLimit + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number - description: MaxChunksPerQuery defines the maximum number of chunks that can be fetched by a single query. displayName: Max Chunk per Query diff --git a/operator/docs/operator/api.md b/operator/docs/operator/api.md index 8fa7cd56ae..17939f6712 100644 --- a/operator/docs/operator/api.md +++ b/operator/docs/operator/api.md @@ -2641,6 +2641,18 @@ string

Timeout when querying ingesters or storage during the execution of a query request.

+ + +cardinalityLimit
+ +int32 + + + +(Optional) +

CardinalityLimit defines the cardinality limit for index queries.

+ + diff --git a/operator/internal/manifests/internal/config/build_test.go b/operator/internal/manifests/internal/config/build_test.go index 659a9be0fd..dfdd0b45a1 100644 --- a/operator/internal/manifests/internal/config/build_test.go +++ b/operator/internal/manifests/internal/config/build_test.go @@ -198,6 +198,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "1m", + CardinalityLimit: 100000, }, }, }, @@ -454,6 +455,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "1m", + CardinalityLimit: 100000, }, }, Tenants: map[string]lokiv1.LimitsTemplateSpec{ @@ -863,6 +865,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "1m", + CardinalityLimit: 100000, }, }, }, @@ -1215,6 +1218,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "1m", + CardinalityLimit: 100000, }, }, }, @@ -1581,6 +1585,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "1m", + CardinalityLimit: 100000, }, }, }, @@ -1915,6 +1920,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "1m", + CardinalityLimit: 100000, }, Retention: &lokiv1.RetentionLimitSpec{ Days: 15, @@ -2305,6 +2311,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "2m", + CardinalityLimit: 100000, }, }, }, @@ -2696,6 +2703,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "1m", + CardinalityLimit: 100000, }, }, }, @@ -3086,6 +3094,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "2m", + CardinalityLimit: 100000, }, }, }, @@ -3470,6 +3479,7 @@ overrides: MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "1m", + CardinalityLimit: 100000, }, }, }, diff --git a/operator/internal/manifests/internal/config/loki-config.yaml b/operator/internal/manifests/internal/config/loki-config.yaml index fd296a18d9..71748b64ad 100644 --- a/operator/internal/manifests/internal/config/loki-config.yaml +++ b/operator/internal/manifests/internal/config/loki-config.yaml @@ -162,7 +162,7 @@ limits_config: max_query_length: 721h max_query_parallelism: 32 max_query_series: {{ .Stack.Limits.Global.QueryLimits.MaxQuerySeries }} - cardinality_limit: 100000 + cardinality_limit: {{ .Stack.Limits.Global.QueryLimits.CardinalityLimit }} max_streams_matchers_per_query: 1000 query_timeout: {{ .Stack.Limits.Global.QueryLimits.QueryTimeout }} {{- if .Retention.Enabled }}{{- with .Stack.Limits.Global.Retention }} diff --git a/operator/internal/manifests/internal/config/loki-runtime-config.yaml b/operator/internal/manifests/internal/config/loki-runtime-config.yaml index 524eb39702..ca62d0a783 100644 --- a/operator/internal/manifests/internal/config/loki-runtime-config.yaml +++ b/operator/internal/manifests/internal/config/loki-runtime-config.yaml @@ -46,6 +46,9 @@ overrides: {{- if $spec.QueryLimits.QueryTimeout }} query_timeout: {{ $spec.QueryLimits.QueryTimeout }} {{- end }} + {{- if $spec.QueryLimits.CardinalityLimit }} + cardinality_limit: {{ $spec.QueryLimits.CardinalityLimit }} + {{- end }} {{- end -}} {{- with $spec.Retention }} retention_period: {{ .Days }}d diff --git a/operator/internal/manifests/internal/sizes.go b/operator/internal/manifests/internal/sizes.go index 03915b1989..dd56b2b0cb 100644 --- a/operator/internal/manifests/internal/sizes.go +++ b/operator/internal/manifests/internal/sizes.go @@ -250,6 +250,7 @@ var StackSizeTable = map[lokiv1.LokiStackSizeType]lokiv1.LokiStackSpec{ MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "3m", + CardinalityLimit: 100000, }, }, }, @@ -304,6 +305,7 @@ var StackSizeTable = map[lokiv1.LokiStackSizeType]lokiv1.LokiStackSpec{ MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "3m", + CardinalityLimit: 100000, }, }, }, @@ -361,6 +363,7 @@ var StackSizeTable = map[lokiv1.LokiStackSizeType]lokiv1.LokiStackSpec{ MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "3m", + CardinalityLimit: 100000, }, }, }, @@ -418,6 +421,7 @@ var StackSizeTable = map[lokiv1.LokiStackSizeType]lokiv1.LokiStackSpec{ MaxChunksPerQuery: 2000000, MaxQuerySeries: 500, QueryTimeout: "3m", + CardinalityLimit: 100000, }, }, },