Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator: Add automatic stream sharding support #11091

Merged
merged 22 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c937d89
Add field desiredRate to LimitsTemplateSpec
periklis Oct 31, 2023
17908d8
Add validation for desiredRate field
periklis Oct 31, 2023
4098203
Replace defaults per-stream-rate limits with desired rate
periklis Oct 31, 2023
e8d74df
Add config rendering for desiredRate
periklis Oct 31, 2023
2a24330
Update API docs
periklis Oct 31, 2023
096c6d2
Add changelog entry
periklis Oct 31, 2023
092bd15
Apply suggestions from code review
periklis Oct 31, 2023
56c39f6
Address code review suggestions
periklis Oct 31, 2023
d4e2b23
Address code review suggestions
periklis Oct 31, 2023
55a0376
Address code review suggestions
periklis Oct 31, 2023
dc013a1
Simplify validation
periklis Nov 2, 2023
f2b5666
Merge remote-tracking branch 'upstream/main' into operator-auto-strea…
periklis Nov 20, 2023
e022a27
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 20, 2023
0cce214
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 20, 2023
30dd998
Apply code review suggenstions
periklis Nov 21, 2023
9130cc7
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 21, 2023
b853b43
Regenerate manifests
periklis Nov 21, 2023
8cf9c35
Remove validation and default per-stream-rate-limit to 5MB
periklis Nov 21, 2023
c317919
Apply code review suggestions
periklis Nov 22, 2023
bfdd6cd
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 22, 2023
bb1eb7a
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 23, 2023
d1c2a82
Apply code review suggestions
periklis Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions operator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Main

- [11091](https://github.com/grafana/loki/pull/11091) **periklis**: Add automatic stream sharding support
- [11022](https://github.com/grafana/loki/pull/11022) **JoaoBraveCoding**: Remove outdated BoltDB dashboards
- [10932](https://github.com/grafana/loki/pull/10932) **JoaoBraveCoding**: Adds new value v13 to schema
- [11232](https://github.com/grafana/loki/pull/11232) **periklis**: Update dependencies and dev tools
Expand Down
8 changes: 8 additions & 0 deletions operator/apis/loki/v1/lokistack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,14 @@ type QueryLimitSpec struct {

// IngestionLimitSpec defines the limits applied at the ingestion path.
type IngestionLimitSpec struct {
// DesiredRate defines the desired ingestion rate per second that LokiStack should
// target applying automatic stream sharding. Unit MB.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors="urn:alm:descriptor:com.tectonic.ui:number",displayName="Desired Ingestion Rate (in MB)"
DesiredRate int32 `json:"desiredRate,omitempty"`
xperimental marked this conversation as resolved.
Show resolved Hide resolved
periklis marked this conversation as resolved.
Show resolved Hide resolved

// IngestionRate defines the sample size per second. Units MB.
//
// +optional
Expand Down
2 changes: 2 additions & 0 deletions operator/apis/loki/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ var (
ErrReplicationSpecConflict = errors.New("replicationSpec and replicationFactor (deprecated) cannot be used at the same time")
// ErrIPv6InstanceAddrTypeNotAllowed when the default InstanceAddrType is used with enableIPv6.
ErrIPv6InstanceAddrTypeNotAllowed = errors.New(`instanceAddrType "default" cannot be used with enableIPv6 at the same time`)
// ErrDesiredRateAndPerStreamRateNotAllowed when there's a conflict in the rate limiting configuration because both desiredRate and perStreamRateLimit are set.
ErrDesiredRateAndPerStreamRateNotAllowed = errors.New("fields desiredRate and perStreamRateLimit cannot be used together")
DylanGuedes marked this conversation as resolved.
Show resolved Hide resolved
periklis marked this conversation as resolved.
Show resolved Hide resolved

// ErrRuleMustMatchNamespace indicates that an expression used in an alerting or recording rule is missing
// matchers for a namespace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ spec:
- description: Global defines the limits applied globally across the cluster.
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down Expand Up @@ -378,6 +384,12 @@ spec:
- description: Tenants defines the limits applied per tenant.
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ spec:
description: IngestionLimits defines the limits applied on
ingested log streams.
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
description: IngestionBurstSize defines the local rate-limited
sample size per distributor replica. It should be set
Expand Down Expand Up @@ -223,6 +229,12 @@ spec:
description: IngestionLimits defines the limits applied
on ingested log streams.
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
description: IngestionBurstSize defines the local rate-limited
sample size per distributor replica. It should be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ spec:
- description: Global defines the limits applied globally across the cluster.
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down Expand Up @@ -378,6 +384,12 @@ spec:
- description: Tenants defines the limits applied per tenant.
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ spec:
description: IngestionLimits defines the limits applied on
ingested log streams.
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
description: IngestionBurstSize defines the local rate-limited
sample size per distributor replica. It should be set
Expand Down Expand Up @@ -223,6 +229,12 @@ spec:
description: IngestionLimits defines the limits applied
on ingested log streams.
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
description: IngestionBurstSize defines the local rate-limited
sample size per distributor replica. It should be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ spec:
- description: Global defines the limits applied globally across the cluster.
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down Expand Up @@ -391,6 +397,12 @@ spec:
- description: Tenants defines the limits applied per tenant.
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ spec:
description: IngestionLimits defines the limits applied on
ingested log streams.
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
description: IngestionBurstSize defines the local rate-limited
sample size per distributor replica. It should be set
Expand Down Expand Up @@ -223,6 +229,12 @@ spec:
description: IngestionLimits defines the limits applied
on ingested log streams.
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
description: IngestionBurstSize defines the local rate-limited
sample size per distributor replica. It should be
Expand Down
12 changes: 12 additions & 0 deletions operator/config/crd/bases/loki.grafana.com_lokistacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ spec:
description: IngestionLimits defines the limits applied on
ingested log streams.
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
description: IngestionBurstSize defines the local rate-limited
sample size per distributor replica. It should be set
Expand Down Expand Up @@ -205,6 +211,12 @@ spec:
description: IngestionLimits defines the limits applied
on ingested log streams.
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
description: IngestionBurstSize defines the local rate-limited
sample size per distributor replica. It should be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ spec:
- description: Global defines the limits applied globally across the cluster.
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down Expand Up @@ -291,6 +297,12 @@ spec:
- description: Tenants defines the limits applied per tenant.
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ spec:
- description: Global defines the limits applied globally across the cluster.
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down Expand Up @@ -291,6 +297,12 @@ spec:
- description: Tenants defines the limits applied per tenant.
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ spec:
- description: Global defines the limits applied globally across the cluster.
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down Expand Up @@ -303,6 +309,12 @@ spec:
- description: Tenants defines the limits applied per tenant.
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
- description: IngestionBurstSize defines the local rate-limited sample size
per distributor replica. It should be set to the set at least to the maximum
logs size expected in a single push request.
Expand Down
13 changes: 13 additions & 0 deletions operator/docs/operator/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,19 @@ MemberListSpec
<tbody>
<tr>
<td>
<code>desiredRate</code><br/>
<em>
int32
</em>
</td>
<td>
<em>(Optional)</em>
<p>DesiredRate defines the desired ingestion rate per second that LokiStack should
target applying automatic stream sharding. Unit MB.</p>
</td>
</tr>
<tr>
<td>
<code>ingestionRate</code><br/>
<em>
int32
Expand Down
8 changes: 7 additions & 1 deletion operator/internal/manifests/internal/config/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ var (
//go:embed loki-runtime-config.yaml
lokiRuntimeConfigYAMLTmplFile embed.FS

lokiConfigYAMLTmpl = template.Must(template.ParseFS(lokiConfigYAMLTmplFile, "loki-config.yaml"))
lokiConfigYAMLTmpl = template.Must(template.New("loki-config.yaml").Funcs(template.FuncMap{
"toBytes": toBytes,
}).ParseFS(lokiConfigYAMLTmplFile, "loki-config.yaml"))

lokiRuntimeConfigYAMLTmpl = template.Must(template.ParseFS(lokiRuntimeConfigYAMLTmplFile, "loki-runtime-config.yaml"))
)
Expand Down Expand Up @@ -54,3 +56,7 @@ func Build(opts Options) ([]byte, []byte, error) {
}
return cfg, rcfg, nil
}

func toBytes(s int32) int32 {
return int32(float32(s) * (1 << 20))
periklis marked this conversation as resolved.
Show resolved Hide resolved
}
Loading
Loading