Skip to content

Commit 42846db

Browse files
Jayclifford345petewall
authored andcommitted
feat: added support for batching to loki write (#1754)
* added support for batching to loki write * removed new test * removed destination test
1 parent fa241f0 commit 42846db

File tree

7 files changed

+32
-0
lines changed

7 files changed

+32
-0
lines changed

charts/k8s-monitoring/destinations/loki-values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ maxBackoffPeriod: 5m
7676
# @section -- General
7777
maxBackoffRetries: 10
7878

79+
# -- Maximum batch size of logs to accumulate before sending.
80+
# @section -- General
81+
batchSize: ""
82+
83+
# -- Maximum amount of time to wait before sending a batch.
84+
# @section -- General
85+
batchWait: ""
86+
7987
auth:
8088
# -- The type of authentication to do.
8189
# Options are "none" (default), "basic", "bearerToken", "oauth2".

charts/k8s-monitoring/docs/destinations/loki.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ This defines the options for defining a destination for logs that use the Loki p
5353

5454
| Key | Type | Default | Description |
5555
|-----|------|---------|-------------|
56+
| batchSize | string | `""` | Maximum batch size of logs to accumulate before sending. |
57+
| batchWait | string | `""` | Maximum amount of time to wait before sending a batch. |
5658
| clusterLabels | list | `["cluster","k8s.cluster.name"]` | Labels to be set with the cluster name as the value. |
5759
| extraHeaders | object | `{}` | Extra headers to be set when sending data. All values are treated as strings and automatically quoted. |
5860
| extraHeadersFrom | object | `{}` | Extra headers to be set when sending data through a dynamic reference. All values are treated as raw strings and not quoted. |

charts/k8s-monitoring/schema-mods/definitions/loki-destination.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@
8686
}
8787
}
8888
},
89+
"batchSize": {
90+
"type": "string"
91+
},
92+
"batchWait": {
93+
"type": "string"
94+
},
8995
"clusterLabels": {
9096
"type": "array",
9197
"items": {

charts/k8s-monitoring/templates/destinations/_destination_loki.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ loki.write {{ include "helper.alloy_name" .name | quote }} {
1818
{{- else }}
1919
url = {{ .url | quote }}
2020
{{- end }}
21+
{{- if .batchSize }}
22+
batch_size = {{ .batchSize | quote }}
23+
{{- end }}
24+
{{- if .batchWait }}
25+
batch_wait = {{ .batchWait | quote }}
26+
{{- end }}
2127
{{- if eq (include "secrets.usesSecret" (dict "object" . "key" "tenantId")) "true" }}
2228
tenant_id = {{ include "secrets.read" (dict "object" . "key" "tenantId" "nonsensitive" true) }}
2329
{{- end }}

charts/k8s-monitoring/tests/integration/pod-logs/default/.rendered/output.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/k8s-monitoring/tests/integration/pod-logs/default/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ destinations:
66
- name: localLoki
77
type: loki
88
url: http://loki.loki.svc:3100/loki/api/v1/push
9+
batchSize: "1MiB"
10+
batchWait: "1s"
911
tenantId: "1"
1012
auth:
1113
type: basic

charts/k8s-monitoring/values.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,12 @@
13561356
}
13571357
}
13581358
},
1359+
"batchSize": {
1360+
"type": "string"
1361+
},
1362+
"batchWait": {
1363+
"type": "string"
1364+
},
13591365
"clusterLabels": {
13601366
"type": "array",
13611367
"items": {

0 commit comments

Comments
 (0)