From 4d37dca66968147f138ce4180823a4b9933c500f Mon Sep 17 00:00:00 2001 From: Jimmi Dyson Date: Wed, 2 Nov 2016 15:06:20 +0000 Subject: [PATCH 1/2] Kubernetes SD: Update config for discovery in 1.3 --- .../examples/prometheus-kubernetes.yml | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/documentation/examples/prometheus-kubernetes.yml b/documentation/examples/prometheus-kubernetes.yml index a0850b1f9..fa206ef35 100644 --- a/documentation/examples/prometheus-kubernetes.yml +++ b/documentation/examples/prometheus-kubernetes.yml @@ -5,9 +5,9 @@ # Kubernetes labels will be added as Prometheus labels on metrics via the # `labelmap` relabeling action. -# Scrape config for cluster components. +# Scrape config for API servers. scrape_configs: -- job_name: 'kubernetes-cluster' +- job_name: 'kubernetes-apiservers' # Default to scraping over https. If required, just disable this or change to # `http`. @@ -28,11 +28,9 @@ scrape_configs: # insecure_skip_verify: true bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token - kubernetes_sd_configs: - - api_servers: - - 'https://kubernetes.default.svc' - in_cluster: true - role: apiserver + static_configs: + - targets: + - kubernetes.default.svc - job_name: 'kubernetes-nodes' @@ -56,10 +54,7 @@ scrape_configs: bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token kubernetes_sd_configs: - - api_servers: - - 'https://kubernetes.default.svc' - in_cluster: true - role: node + - role: node relabel_configs: - action: labelmap @@ -79,10 +74,7 @@ scrape_configs: - job_name: 'kubernetes-service-endpoints' kubernetes_sd_configs: - - api_servers: - - 'https://kubernetes.default.svc' - in_cluster: true - role: endpoint + - role: endpoints relabel_configs: - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape] @@ -123,10 +115,7 @@ scrape_configs: module: [http_2xx] kubernetes_sd_configs: - - api_servers: - - 'https://kubernetes.default.svc' - in_cluster: true - role: service + - role: service relabel_configs: - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_probe] @@ -156,10 +145,7 @@ scrape_configs: - job_name: 'kubernetes-pods' kubernetes_sd_configs: - - api_servers: - - 'https://kubernetes.default.svc' - in_cluster: true - role: pod + - role: pod relabel_configs: - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape] From da23543f29e51701b4e8ec0ffc1912e3a530c5d1 Mon Sep 17 00:00:00 2001 From: Jimmi Dyson Date: Wed, 2 Nov 2016 20:48:01 +0000 Subject: [PATCH 2/2] Kubernetes SD: Update example config to use endpoints role for API server discovery --- documentation/examples/prometheus-kubernetes.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/documentation/examples/prometheus-kubernetes.yml b/documentation/examples/prometheus-kubernetes.yml index fa206ef35..9c7b3b95d 100644 --- a/documentation/examples/prometheus-kubernetes.yml +++ b/documentation/examples/prometheus-kubernetes.yml @@ -28,9 +28,13 @@ scrape_configs: # insecure_skip_verify: true bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token - static_configs: - - targets: - - kubernetes.default.svc + # Keep only the default/kubernetes service endpoints for the https port. This + # will add targets for each API server which Kubernetes adds an endpoint to + # the default/kubernetes service. + relabel_configs: + - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name] + action: keep + regex: default;kubernetes;https - job_name: 'kubernetes-nodes'