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 customizing otlp logs transform to make dynamic loki labels and a… #396

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions charts/k8s-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ The Prometheus and Loki services may be hosted on the same cluster, or remotely
| externalServices.prometheus.processors.memoryLimiter.checkInterval | string | `"1s"` | How often to check memory usage. |
| externalServices.prometheus.processors.memoryLimiter.enabled | bool | `false` | Use a memory limiter. |
| externalServices.prometheus.processors.memoryLimiter.limit | string | `"0MiB"` | Maximum amount of memory targeted to be allocated by the process heap. |
| externalServices.prometheus.processors.transform.loki_resource_labels | string | `"pod, namespace, cluster, job"` | Comma-separated list of labels to be added to the Loki resource label set. |
| externalServices.prometheus.processors.transform.custom_log_statements | list | `[]` | Custom log statements to be added to the Loki resource label set. |
| externalServices.prometheus.protocol | string | `"remote_write"` | The type of server protocol for writing metrics. Valid options: "remote_write" will use Prometheus Remote Write, "otlp" will use OTLP, "otlphttp" will use OTLP HTTP |
| externalServices.prometheus.proxyURL | string | `""` | HTTP proxy to proxy requests to Prometheus through. |
| externalServices.prometheus.queryEndpoint | string | `"/api/prom/api/v1/query"` | Prometheus metrics query endpoint. Preset for Grafana Cloud Metrics instances. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ otelcol.processor.transform "add_resource_attributes" {
statements = [
"set(attributes[\"pod\"], attributes[\"k8s.pod.name\"])",
"set(attributes[\"namespace\"], attributes[\"k8s.namespace.name\"])",
"set(attributes[\"loki.resource.labels\"], \"pod, namespace, cluster, job\")",
"set(attributes[\"loki.resource.labels\"], \"{{ .Values.externalServices.prometheus.processors.transform.loki_resource_labels }}\")",
"set(attributes[\"k8s.cluster.name\"], \"{{ required ".Values.cluster.name is a required value. Please set it and try again." .Values.cluster.name }}\") where attributes[\"k8s.cluster.name\"] == nil",
{{- range $key, $value := .Values.externalServices.prometheus.processors.transform.custom_log_statements }}
"set(attributes[\"{{ $key }}\"], attributes[\"{{ $value }}\"])",
{{- end }}
]
}
{{- end }}
Expand Down
9 changes: 9 additions & 0 deletions charts/k8s-monitoring/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@
"type": "string"
}
}
},
"transform": {
"loki_resource_labels": "string",
"custom_log_statements": {
"type": "array",
"items": {
"type": "object"
}
}
}
}
},
Expand Down
5 changes: 5 additions & 0 deletions charts/k8s-monitoring/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ externalServices:
checkInterval: 1s
# -- Maximum amount of memory targeted to be allocated by the process heap.
limit: 0MiB
transform:
# -- Loki resource labels to add to metrics received via the OTLP or OTLP HTTP receivers.
loki_resource_labels: "pod, namespace, cluster, job"
# -- Custom log statements to add to metrics received via the OTLP or OTLP HTTP receivers.
custom_log_statements: []

# Write-Ahead Log (WAL) settings. Only applies when protocol is "remote_write"
wal:
Expand Down
Loading