Skip to content

Instantly share code, notes, and snippets.

@shawnho1018
Created September 19, 2022 10:55
Show Gist options
  • Save shawnho1018/22e5658a2411d2f164999fca674274de to your computer and use it in GitHub Desktop.
Save shawnho1018/22e5658a2411d2f164999fca674274de to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: ConfigMap
metadata:
namespace: gmp-test
name: prometheus-test
labels:
prometheus: test
data:
config.yaml: |
global:
scrape_interval: 30s
scrape_timeout: 10s
evaluation_interval: 1m
scrape_configs:
# Let Prometheus scrape itself.
- job_name: kubernetes-pods
kubernetes_sd_configs:
- role: pod
relabel_configs:
- action: keep
regex: true
source_labels:
- __meta_kubernetes_pod_annotation_prometheus_io_scrape
- action: replace
regex: (https?)
source_labels:
- __meta_kubernetes_pod_annotation_prometheus_io_scheme
target_label: __scheme__
- action: replace
regex: (.+)
source_labels:
- __meta_kubernetes_pod_annotation_prometheus_io_path
target_label: __metrics_path__
- action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
source_labels:
- __address__
- __meta_kubernetes_pod_annotation_prometheus_io_port
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_annotation_prometheus_io_param_(.+)
replacement: __param_$1
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: replace
source_labels:
- __meta_kubernetes_namespace
target_label: namespace
- action: replace
source_labels:
- __meta_kubernetes_pod_name
target_label: pod
- action: drop
regex: Pending|Succeeded|Failed|Completed
source_labels:
- __meta_kubernetes_pod_phase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment