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

Add the ability to specify processing stages per loki destination #1186

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions charts/k8s-monitoring/destinations/loki-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ extraLabels: {}
# @section -- General
extraLabelsFrom: {}

# -- Stage blocks to be evaluated before delivering to the Loki destination. See
# ([docs](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/#blocks)) for more information.
# @section -- General
logProcessingStages: ""

auth:
# -- The type of authentication to do.
# Options are "none" (default), "basic", "bearerToken", "oauth2".
Expand Down
1 change: 1 addition & 0 deletions charts/k8s-monitoring/docs/destinations/loki.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ This defines the options for defining a destination for logs that use the Loki p
| extraHeadersFrom | object | `{}` | Extra headers to be set when sending data through a dynamic reference. All values are treated as raw strings and not quoted. |
| extraLabels | object | `{}` | Custom labels to be added to all logs and events. All values are treated as strings and automatically quoted. |
| extraLabelsFrom | object | `{}` | Custom labels to be added to all logs and events through a dynamic reference. All values are treated as raw strings and not quoted. |
| logProcessingStages | string | `""` | Stage blocks to be evaluated before delivering to the Loki destination. See ([docs](https://grafana.com/docs/alloy/latest/reference/components/loki/loki.process/#blocks)) for more information. |
| name | string | `""` | The name for this Loki destination. |
| proxyURL | string | `""` | The Proxy URL for the Loki destination. |
| tenantId | string | `""` | The tenant ID for the Loki destination. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
"extraLabelsFrom": {
"type": "object"
},
"logProcessingStages": {
"type": "string"
},
"name": {
"type": "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
{{- $defaultValues := "destinations/loki-values.yaml" | .Files.Get | fromYaml }}
{{- with merge .destination $defaultValues }}
otelcol.exporter.loki {{ include "helper.alloy_name" .name | quote }} {
forward_to = [{{ include "destinations.loki.alloy.loki.logs.target" . }}]
}
{{- if .logProcessingStages }}

loki.process {{ include "helper.alloy_name" .name | quote }} {
{{ .logProcessingStages | indent 2 }}
forward_to = [loki.write.{{ include "helper.alloy_name" .name }}.receiver]
}
{{- end }}

loki.write {{ include "helper.alloy_name" .name | quote }} {
endpoint {
Expand Down Expand Up @@ -122,7 +129,13 @@ loki.write {{ include "helper.alloy_name" .name | quote }} {
- tls.key
{{- end -}}

{{- define "destinations.loki.alloy.loki.logs.target" }}loki.write.{{ include "helper.alloy_name" .name }}.receiver{{ end -}}
{{- define "destinations.loki.alloy.loki.logs.target" }}
{{- if .logProcessingStages -}}
loki.process.{{ include "helper.alloy_name" .name }}.receiver
{{- else -}}
loki.write.{{ include "helper.alloy_name" .name }}.receiver
{{- end -}}
{{- end -}}
{{- define "destinations.loki.alloy.otlp.logs.target" }}otelcol.exporter.loki.{{ include "helper.alloy_name" .name }}.input{{ end -}}

{{- define "destinations.loki.supports_metrics" }}false{{ end -}}
Expand Down
Loading