Skip to content

Commit

Permalink
Use the release label instead of the app.kubernetes.io/instance label (
Browse files Browse the repository at this point in the history
…#696)

* Use the release label instead of the app.kubernetes.io/instance label for ksm, nodeexporter, and windowsexporter

Signed-off-by: Pete Wall <[email protected]>

* Remove the release name check for alloy and opencost.

Signed-off-by: Pete Wall <[email protected]>

---------

Signed-off-by: Pete Wall <[email protected]>
  • Loading branch information
petewall authored Aug 15, 2024
1 parent 76649c1 commit 648af90
Show file tree
Hide file tree
Showing 59 changed files with 410 additions and 940 deletions.
3 changes: 3 additions & 0 deletions charts/k8s-monitoring/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ values.schema.json: values.yaml schema-mods/enums-and-types.json schema-mods/req
| del(.properties["kube-state-metrics"].properties.autosharding) \
| del(.properties["kube-state-metrics"].properties.nodeSelector) \
| del(.properties["kube-state-metrics"].properties.prometheusScrape) \
| del(.properties["kube-state-metrics"].properties.releaseLabel) \
| del(.properties["kube-state-metrics"].properties.updateStrategy) \
| del(.properties["prometheus-node-exporter"].properties.nodeSelector) \
| del(.properties["prometheus-node-exporter"].properties.podAnnotations) \
| del(.properties["prometheus-node-exporter"].properties.releaseLabel) \
| del(.properties["prometheus-node-exporter"].properties.service) \
| del(.properties["prometheus-windows-exporter"].properties.config) \
| del(.properties["prometheus-windows-exporter"].properties.podAnnotations) \
| del(.properties["prometheus-windows-exporter"].properties.releaseLabel) \
| del(.properties.logs.properties.pod_logs.properties.labels.properties) \
| del(.properties.opencost.properties.opencost)' values.schema.generated.json) \
schema-mods/enums-and-types.json \
Expand Down
5 changes: 0 additions & 5 deletions charts/k8s-monitoring/templates/alloy_config/_alloy.alloy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ up
// Grafana Alloy
discovery.relabel "alloy" {
targets = discovery.kubernetes.pods.targets
rule {
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_instance"]
regex = "{{ .Release.Name }}"
action = "keep"
}
{{- range $k, $v := .Values.metrics.alloy.labelMatchers }}
rule {
source_labels = ["__meta_kubernetes_pod_label_{{ include "escape_label" $k }}"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ discovery.relabel "kube_state_metrics" {
targets = discovery.kubernetes.services.targets
{{- if (index .Values "kube-state-metrics").enabled }}
rule {
source_labels = ["__meta_kubernetes_service_label_app_kubernetes_io_instance"]
source_labels = ["__meta_kubernetes_service_label_release"]
regex = "{{ .Release.Name }}"
action = "keep"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ discovery.relabel "node_exporter" {
targets = discovery.kubernetes.pods.targets
{{- if (index .Values "prometheus-node-exporter").enabled }}
rule {
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_instance"]
source_labels = ["__meta_kubernetes_pod_label_release"]
regex = "{{ .Release.Name }}"
action = "keep"
}
Expand Down
5 changes: 0 additions & 5 deletions charts/k8s-monitoring/templates/alloy_config/_opencost.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
// OpenCost
discovery.relabel "opencost" {
targets = discovery.kubernetes.services.targets
rule {
source_labels = ["__meta_kubernetes_service_label_app_kubernetes_io_instance"]
regex = "{{ .Release.Name }}"
action = "keep"
}
{{- range $k, $v := .Values.metrics.cost.labelMatchers }}
rule {
source_labels = ["__meta_kubernetes_service_label_{{ include "escape_label" $k }}"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ discovery.relabel "windows_exporter" {
targets = discovery.kubernetes.pods.targets
{{- if (index .Values "prometheus-windows-exporter").enabled }}
rule {
source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_instance"]
source_labels = ["__meta_kubernetes_pod_label_release"]
regex = "{{ .Release.Name }}"
action = "keep"
}
Expand Down
10 changes: 10 additions & 0 deletions charts/k8s-monitoring/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2019,10 +2019,14 @@ kube-state-metrics:
# do not want to scrape metrics from Kube State Metrics.
# @section -- Deployment: [Kube State Metrics](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics)
enabled: true

# @ignored
nodeSelector:
kubernetes.io/os: linux

# @ignored - Enable the release label
releaseLabel: true

# @ignored - Disable autosharding
autosharding:
enabled: false
Expand Down Expand Up @@ -2060,6 +2064,9 @@ prometheus-node-exporter:
operator: NotIn
values: [fargate]

# @ignored - Enable the release label
releaseLabel: true

# @ignored - Set annotation to override the job label
podAnnotations:
k8s.grafana.com/logs.job: integrations/node_exporter
Expand Down Expand Up @@ -2088,6 +2095,9 @@ prometheus-windows-exporter:
service:
services-where: "Name='containerd' or Name='kubelet'"
# @ignored - Enable the release label
releaseLabel: true

# @ignored - Set annotation to override the job label
podAnnotations:
k8s.grafana.com/logs.job: integrations/windows_exporter
Expand Down
14 changes: 2 additions & 12 deletions examples/alloy-autoscaling-and-storage/metrics.alloy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 14 additions & 24 deletions examples/alloy-autoscaling-and-storage/output.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 2 additions & 12 deletions examples/application-observability/metrics.alloy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 648af90

Please sign in to comment.