diff --git a/config/prometheus/hack.prometheus.values.yaml b/config/prometheus/hack.prometheus.values.yaml index 4f0b5111..b1975764 100644 --- a/config/prometheus/hack.prometheus.values.yaml +++ b/config/prometheus/hack.prometheus.values.yaml @@ -351,66 +351,65 @@ serverFiles: # target_label: service -## DEVZERO COMMENTED OUT TO PREVENT SCRAPING -# # Example scrape config for pods -# # -# # The relabeling allows the actual pod scrape endpoint to be configured via the -# # following annotations: -# # -# # * `prometheus.io/scrape`: Only scrape pods that have a value of `true`, -# # except if `prometheus.io/scrape-slow` is set to `true` as well. -# # * `prometheus.io/scheme`: If the metrics endpoint is secured then you will need -# # to set this to `https` & most likely set the `tls_config` of the scrape config. -# # * `prometheus.io/path`: If the metrics path is not `/metrics` override this. -# # * `prometheus.io/port`: Scrape the pod on the indicated port instead of the default of `9102`. -# - job_name: 'kubernetes-pods' -# honor_labels: true -# -# kubernetes_sd_configs: -# - role: pod -# -# relabel_configs: -# - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_scrape ] -# action: keep -# regex: true -# - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_scrape_slow ] -# action: drop -# regex: true -# - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_scheme ] -# action: replace -# regex: (https?) -# target_label: __scheme__ -# - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_path ] -# action: replace -# target_label: __metrics_path__ -# regex: (.+) -# - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_port, __meta_kubernetes_pod_ip ] -# action: replace -# regex: (\d+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}) -# replacement: '[$2]:$1' -# target_label: __address__ -# - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_port, __meta_kubernetes_pod_ip ] -# action: replace -# regex: (\d+);((([0-9]+?)(\.|$)){4}) -# replacement: $2:$1 -# target_label: __address__ -# - action: labelmap -# regex: __meta_kubernetes_pod_annotation_prometheus_io_param_(.+) -# replacement: __param_$1 -# - action: labelmap -# regex: __meta_kubernetes_pod_label_(.+) -# - source_labels: [ __meta_kubernetes_namespace ] -# action: replace -# target_label: namespace -# - source_labels: [ __meta_kubernetes_pod_name ] -# action: replace -# target_label: pod -# - source_labels: [ __meta_kubernetes_pod_phase ] -# regex: Pending|Succeeded|Failed|Completed -# action: drop -# - source_labels: [ __meta_kubernetes_pod_node_name ] -# action: replace -# target_label: node + # Example scrape config for pods + # + # The relabeling allows the actual pod scrape endpoint to be configured via the + # following annotations: + # + # * `prometheus.io/scrape`: Only scrape pods that have a value of `true`, + # except if `prometheus.io/scrape-slow` is set to `true` as well. + # * `prometheus.io/scheme`: If the metrics endpoint is secured then you will need + # to set this to `https` & most likely set the `tls_config` of the scrape config. + # * `prometheus.io/path`: If the metrics path is not `/metrics` override this. + # * `prometheus.io/port`: Scrape the pod on the indicated port instead of the default of `9102`. + - job_name: 'kubernetes-pods' + honor_labels: true + + kubernetes_sd_configs: + - role: pod + + relabel_configs: + - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_scrape ] + action: keep + regex: true + - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_scrape_slow ] + action: drop + regex: true + - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_scheme ] + action: replace + regex: (https?) + target_label: __scheme__ + - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_path ] + action: replace + target_label: __metrics_path__ + regex: (.+) + - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_port, __meta_kubernetes_pod_ip ] + action: replace + regex: (\d+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}) + replacement: '[$2]:$1' + target_label: __address__ + - source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_port, __meta_kubernetes_pod_ip ] + action: replace + regex: (\d+);((([0-9]+?)(\.|$)){4}) + replacement: $2:$1 + target_label: __address__ + - action: labelmap + regex: __meta_kubernetes_pod_annotation_prometheus_io_param_(.+) + replacement: __param_$1 + - action: labelmap + regex: __meta_kubernetes_pod_label_(.+) + - source_labels: [ __meta_kubernetes_namespace ] + action: replace + target_label: namespace + - source_labels: [ __meta_kubernetes_pod_name ] + action: replace + target_label: pod + - source_labels: [ __meta_kubernetes_pod_phase ] + regex: Pending|Succeeded|Failed|Completed + action: drop + - source_labels: [ __meta_kubernetes_pod_node_name ] + action: replace + target_label: node ## DEVZERO COMMENTED OUT TO PREVENT SCRAPING @@ -472,4 +471,4 @@ serverFiles: # action: drop # - source_labels: [ __meta_kubernetes_pod_node_name ] # action: replace -# target_label: node \ No newline at end of file +# target_label: node diff --git a/dist/install.yaml b/dist/install.yaml index 48c3461d..c41fa0dc 100644 --- a/dist/install.yaml +++ b/dist/install.yaml @@ -117,6 +117,64 @@ data: scheme: https tls_config: ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + - honor_labels: true + 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: drop + regex: true + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_scrape_slow + - 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+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}) + replacement: '[$2]:$1' + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_port + - __meta_kubernetes_pod_ip + target_label: __address__ + - action: replace + regex: (\d+);((([0-9]+?)(\.|$)){4}) + replacement: $2:$1 + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_port + - __meta_kubernetes_pod_ip + 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 + - action: replace + source_labels: + - __meta_kubernetes_pod_node_name + target_label: node recording_rules.yml: | {} rules: | diff --git a/dist/prometheus.yaml b/dist/prometheus.yaml index e0cbd765..4e75ae7f 100644 --- a/dist/prometheus.yaml +++ b/dist/prometheus.yaml @@ -101,6 +101,64 @@ data: scheme: https tls_config: ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + - honor_labels: true + 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: drop + regex: true + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_scrape_slow + - 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+);(([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}) + replacement: '[$2]:$1' + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_port + - __meta_kubernetes_pod_ip + target_label: __address__ + - action: replace + regex: (\d+);((([0-9]+?)(\.|$)){4}) + replacement: $2:$1 + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_port + - __meta_kubernetes_pod_ip + 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 + - action: replace + source_labels: + - __meta_kubernetes_pod_node_name + target_label: node recording_rules.yml: | {} rules: |