From 619b0a25c92556765bb40cc466c21577a2992653 Mon Sep 17 00:00:00 2001
From: Aliaksandr Valialkin <valyala@gmail.com>
Date: Mon, 13 Jul 2020 21:25:11 +0300
Subject: [PATCH] docs/vmagent.md: sync with app/vmagent/README.md

---
 app/vmagent/README.md | 41 +++++++++++++++--------------------------
 docs/vmagent.md       | 26 ++++++++++++++++++++------
 2 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/app/vmagent/README.md b/app/vmagent/README.md
index e8b6f0ea47..151cb22074 100644
--- a/app/vmagent/README.md
+++ b/app/vmagent/README.md
@@ -219,39 +219,28 @@ either via `vmagent` itself or via Prometheus, so the exported metrics could be
   The directory can grow large when remote storage is unavailable for extended periods of time and if `-remoteWrite.maxDiskUsagePerURL` isn't set.
   If you don't want to send all the data from the directory to remote storage, simply stop `vmagent` and delete the directory.
 
-* If you see `skipping duplicate scrape target with identical labels` errors when scraping Kubernetes pods, then it is likely these pods listen multiple ports or           they use init container.
-  
-  To determinate duplicated targets during service discovery you can use followin pattern:
+* If you see `skipping duplicate scrape target with identical labels` errors when scraping Kubernetes pods, then it is likely these pods listen multiple ports
+  or they use init container.
+
+  The following `relabel_configs` section may help determining `__meta_*` labels resulting in duplicate targets:
   ```yml
-  ...
-  - job_name: my-app
-      metrics_path: /metrics
-      scheme: http
-      kubernetes_sd_configs:
-        - role: pod
-          namespaces:
-            names:
-              - kube-system
-    relabel_configs:
-      - action: keep
-        regex: my-app
-        source_labels: [__meta_kubernetes_pod_label_app]
-      - action: labelmap
-        regex: __meta_(.*)
+  - action: labelmap
+    regex: __meta_(.*)
   ```
-  To filter out targets with init container add the following relabeling rule to `relabel_configs` section:
-  ```yml
-    - action: keep
-      regex: false
-      source_labels: [__meta_kubernetes_pod_container_init]
-  ```
-  
-  To filter out targets with unneeded ports add the following relabeling rule to `relabel_configs` section:
+
+  The following relabeling rule may be added to `relabel_configs` section in order to filter out pods with unneeded ports:
   ```yml
   - action: keep_if_equal
     source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_port, __meta_kubernetes_pod_container_port_number]
   ```
 
+  The following relabeling rule may be added to `relabel_configs` section in order to filter out init container pods:
+  ```yml
+  - action: keep
+    source_labels: [__meta_kubernetes_pod_container_init]
+    regex: false
+  ```
+
 
 ### How to build from sources
 
diff --git a/docs/vmagent.md b/docs/vmagent.md
index 27aced8efd..151cb22074 100644
--- a/docs/vmagent.md
+++ b/docs/vmagent.md
@@ -219,13 +219,27 @@ either via `vmagent` itself or via Prometheus, so the exported metrics could be
   The directory can grow large when remote storage is unavailable for extended periods of time and if `-remoteWrite.maxDiskUsagePerURL` isn't set.
   If you don't want to send all the data from the directory to remote storage, simply stop `vmagent` and delete the directory.
 
-* If you see `skipping duplicate scrape target with identical labels` errors when scraping Kubernetes pods, then it is likely these pods listen multiple ports.
-  Just add the following relabeling rule to `relabel_configs` section in order to filter out targets with unneeded ports:
+* If you see `skipping duplicate scrape target with identical labels` errors when scraping Kubernetes pods, then it is likely these pods listen multiple ports
+  or they use init container.
 
-```yml
-- action: keep_if_equal
-  source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_port, __meta_kubernetes_pod_container_port_number]
-```
+  The following `relabel_configs` section may help determining `__meta_*` labels resulting in duplicate targets:
+  ```yml
+  - action: labelmap
+    regex: __meta_(.*)
+  ```
+
+  The following relabeling rule may be added to `relabel_configs` section in order to filter out pods with unneeded ports:
+  ```yml
+  - action: keep_if_equal
+    source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_port, __meta_kubernetes_pod_container_port_number]
+  ```
+
+  The following relabeling rule may be added to `relabel_configs` section in order to filter out init container pods:
+  ```yml
+  - action: keep
+    source_labels: [__meta_kubernetes_pod_container_init]
+    regex: false
+  ```
 
 
 ### How to build from sources