Skip to content

Commit e704cdd

Browse files
committed
fix(alloy): scrape all alloy pod targets on the Alloy HTTP port
Pod discovery makes one scrape target for each declared container port. It makes a target on port 80 for containers that declare no port, such as config-reloader. Alloy does not listen on port 80, so the config-reloader target is always down. Set the prometheus.io/port annotation on the Alloy pod to the Alloy HTTP port by default. Operators no longer need to set it in their own values.
1 parent 938aba9 commit e704cdd

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ values which are defined [here](https://github.com/grafana/helm-charts/tree/main
319319
| alloy.alloy.mounts.dockercontainers | bool | `true` | |
320320
| alloy.alloy.mounts.varlog | bool | `true` | |
321321
| alloy.commonRelabellings | string | `"rule {\n source_labels = [\"__meta_kubernetes_namespace\"]\n target_label = \"namespace\"\n}\nrule {\n source_labels = [\"__meta_kubernetes_pod_name\"]\n target_label = \"pod\"\n}\n// coalesce the following labels and pick the first value; we'll use this to define the \"job\" label\nrule {\n source_labels = [\"__meta_kubernetes_pod_label_app_kubernetes_io_component\", \"app\", \"__meta_kubernetes_pod_container_name\"]\n separator = \"/\"\n target_label = \"__meta_app\"\n action = \"replace\"\n regex = \"^/*([^/]+?)(?:/.*)?$\" // split by the delimiter if it exists, we only want the first one\n replacement = \"${1}\"\n}\nrule {\n source_labels = [\"__meta_kubernetes_namespace\", \"__meta_kubernetes_pod_label_app_kubernetes_io_name\", \"__meta_app\"]\n separator = \"/\"\n target_label = \"job\"\n}\nrule {\n source_labels = [\"__meta_kubernetes_pod_container_name\"]\n target_label = \"container\"\n}\nrule {\n regex = \"__meta_kubernetes_pod_label_(statefulset_kubernetes_io_pod_name|controller_revision_hash)\"\n action = \"labeldrop\"\n}\nrule {\n regex = \"pod_template_generation\"\n action = \"labeldrop\"\n}\nrule {\n source_labels = [\"__meta_kubernetes_pod_phase\"]\n regex = \"Pending|Succeeded|Failed|Completed\"\n action = \"drop\"\n}\nrule {\n source_labels = [\"__meta_kubernetes_pod_node_name\"]\n action = \"replace\"\n target_label = \"node\"\n}\nrule {\n action = \"labelmap\"\n regex = \"__meta_kubernetes_pod_annotation_prometheus_io_param_(.+)\"\n replacement = \"__param_$1\"\n}"` | |
322+
| alloy.controller.podAnnotations."prometheus.io/port" | string | `"12345"` | |
322323
| alloy.controller.podAnnotations."prometheus.io/scrape" | string | `"true"` | |
323324
| alloy.controller.type | string | `"daemonset"` | |
324325
| alloy.crds.create | bool | `false` | |

‎coder-observability/values.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ alloy:
211211
type: daemonset
212212
podAnnotations:
213213
prometheus.io/scrape: "true"
214+
# Pod discovery makes one target per declared container port, and a target
215+
# on port 80 for containers that declare none (such as config-reloader).
216+
# Pin every target of this pod to the Alloy HTTP port.
217+
# Must equal alloy.alloy.listenPort.
218+
prometheus.io/port: "12345"
214219
crds:
215220
create: false
216221

‎compiled/resources.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12072,6 +12072,7 @@ spec:
1207212072
metadata:
1207312073
annotations:
1207412074
kubectl.kubernetes.io/default-container: alloy
12075+
prometheus.io/port: "12345"
1207512076
prometheus.io/scrape: "true"
1207612077
labels:
1207712078
app.kubernetes.io/name: alloy

0 commit comments

Comments
 (0)