Skip to content

Commit

Permalink
Do the relabeling before the scrape (#734)
Browse files Browse the repository at this point in the history
Signed-off-by: Pete Wall <[email protected]>
  • Loading branch information
petewall authored Sep 12, 2024
1 parent 442f536 commit b86647e
Show file tree
Hide file tree
Showing 63 changed files with 1,283 additions and 1,822 deletions.
1 change: 1 addition & 0 deletions charts/k8s-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ The Prometheus and Loki services may be hosted on the same cluster, or remotely
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| metrics.kubernetesMonitoring.enabled | bool | `true` | Report telemetry about this Kubernetes Monitoring chart as a metric. |
| metrics.kubernetesMonitoring.scrapeInterval | string | 60s | How frequently to scrape the telemetry report metric. Overrides metrics.scrapeInterval |

### Metrics Job: Node Exporter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,29 @@ prometheus.exporter.unix "kubernetes_monitoring_telemetry" {
}
}

prometheus.scrape "kubernetes_monitoring_telemetry" {
job_name = "integrations/kubernetes/kubernetes_monitoring_telemetry"
targets = prometheus.exporter.unix.kubernetes_monitoring_telemetry.targets
scrape_interval = {{ .Values.metrics.scrapeInterval | quote }}
{{- if .Values.alloy.alloy.clustering.enabled }}
clustering {
enabled = true
}
{{- end }}
forward_to = [prometheus.relabel.kubernetes_monitoring_telemetry.receiver]
}

prometheus.relabel "kubernetes_monitoring_telemetry" {
max_cache_size = {{ .Values.metrics.maxCacheSize | int }}
rule {
target_label = "job"
action = "replace"
replacement = "integrations/kubernetes/kubernetes_monitoring_telemetry"
}
discovery.relabel "kubernetes_monitoring_telemetry" {
targets = prometheus.exporter.unix.kubernetes_monitoring_telemetry.targets
rule {
target_label = "instance"
action = "replace"
replacement = "{{ .Release.Name }}"
}
rule {
source_labels = ["__name__"]
regex = "up|grafana_kubernetes_monitoring_.*"
action = "keep"
target_label = "job"
action = "replace"
replacement = "integrations/kubernetes/kubernetes_monitoring_telemetry"
}
}

prometheus.scrape "kubernetes_monitoring_telemetry" {
job_name = "integrations/kubernetes/kubernetes_monitoring_telemetry"
targets = discovery.relabel.kubernetes_monitoring_telemetry.output
scrape_interval = {{ .Values.metrics.kubernetesMonitoring.scrapeInterval | default .Values.metrics.scrapeInterval | quote }}
{{- if .Values.alloy.alloy.clustering.enabled }}
clustering {
enabled = true
}
{{- end }}
forward_to = [prometheus.relabel.metrics_service.receiver]
}
{{ end }}
6 changes: 6 additions & 0 deletions charts/k8s-monitoring/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,12 @@ metrics:
# @section -- Metrics Job: Kubernetes Monitoring Telemetry
enabled: true

# -- How frequently to scrape the telemetry report metric.
# Overrides metrics.scrapeInterval
# @section -- Metrics Job: Kubernetes Monitoring Telemetry
# @default -- 60s
scrapeInterval:

# Alloy Modules
# Modules can be invoked using metrics.extraConfig, this block is consuming opinionated modules from the grafana/alloy-modules repository
# or any other repository that follows the same module structure. Each module is expected to have a "kubernetes" module and a "scrape" module.
Expand Down
34 changes: 14 additions & 20 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.

68 changes: 28 additions & 40 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.

34 changes: 14 additions & 20 deletions examples/application-observability/metrics.alloy

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

68 changes: 28 additions & 40 deletions examples/application-observability/output.yaml

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

Loading

0 comments on commit b86647e

Please sign in to comment.