Skip to content

Commit

Permalink
Fix Promtail labels to match k8s semantics
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
graphite-app[bot] committed Feb 13, 2024
2 parents 7267a6d + 946be49 commit 619b422
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **api-status** More comprehensive status check that both creates a lobby & connects to it
- More details in `CLAIMS_MISSING_ENTITLEMENT` error
- **API** Added 120s timeout to reading request body and writing response to all requests going through Traefik
- **Infra** Update Promtail logs to match k8s semantics

### Fixed

Expand Down
32 changes: 18 additions & 14 deletions infra/tf/k8s_infra/promtail.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
locals {
labels = {
ns = var.namespace
}
external_labels = join(",", [
for key, value in local.labels:
"${key}=${value}"
])
service_promtail = lookup(var.services, "promtail", {
count = 1
resources = {
Expand Down Expand Up @@ -56,25 +49,40 @@ resource "helm_release" "promtail" {
]
# NOTE: Do not add relabel configs to `common` below, add them here
extraRelabelConfigs = [
{
action = "replace"
source_labels = ["__meta_kubernetes_namespace"]
target_label = "namespace"
},
{
action = "replace"
source_labels = ["__meta_kubernetes_pod_node_name"]
target_label = "node"
},
{
action = "replace"
source_labels = ["__meta_kubernetes_pod_name"]
target_label = "pod"
},
{
action = "replace"
source_labels = ["__meta_kubernetes_pod_uid"]
target_label = "alloc"
target_label = "pod_uid"
},
{
action = "replace"
source_labels = ["__meta_kubernetes_pod_container_name"]
target_label = "container"
},
{
action = "replace"
# Label names cannot use dots or slashes, convert to underscore
# https://groups.google.com/g/prometheus-users/c/dGx7MArW-eE
# https://github.com/prometheus/docs/issues/735
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"]
target_label = "service"
target_label = "name"
},
# Doesn't work for some reason
# TODO: Doesn't work for some reason
{
action = "labeldrop"
regex = "^(host|filename)$"
Expand Down Expand Up @@ -139,9 +147,5 @@ resource "helm_release" "promtail" {
cpu = "${local.service_promtail.resources.cpu}m"
}
} : null

extraArgs = [
"-client.external-labels=${local.external_labels}"
]
})]
}

0 comments on commit 619b422

Please sign in to comment.