You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/08/27 09:54:27 UTC

[skywalking-satellite] branch main updated: fix: remove instance from labels (#63)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-satellite.git


The following commit(s) were added to refs/heads/main by this push:
     new 884b55f  fix: remove instance from labels (#63)
884b55f is described below

commit 884b55f7178f567659c912a49dcb16b744344f5e
Author: kv <gx...@163.com>
AuthorDate: Fri Aug 27 17:53:28 2021 +0800

    fix: remove instance from labels (#63)
    
    * fix: remove instance from label, because the instance has been in metadata already
    
    * remove the job label
    
    * docs: add comments for the configuration of  prometheus fetcher
---
 docs/en/setup/plugins/fetcher_prometheus-metrics-fetcher.md | 10 ++++++++++
 plugins/fetcher/prometheus/fetcher.go                       | 10 ++++++++++
 plugins/fetcher/prometheus/metric_family.go                 |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/docs/en/setup/plugins/fetcher_prometheus-metrics-fetcher.md b/docs/en/setup/plugins/fetcher_prometheus-metrics-fetcher.md
index b55896f..451d99a 100755
--- a/docs/en/setup/plugins/fetcher_prometheus-metrics-fetcher.md
+++ b/docs/en/setup/plugins/fetcher_prometheus-metrics-fetcher.md
@@ -3,13 +3,23 @@
 This is a fetcher for Skywalking prometheus metrics format, which will translate Prometheus metrics to Skywalking meter system.
 ## DefaultConfig
 ```yaml
+# scrape_configs is the scrape configuration of prometheus 
+# which is fully compatible with prometheus scrap.
 scrape_configs:
+# job_name will be used as the label in prometheus, 
+# and in skywalking meterdata will be used as the service name.
+# Set the scrape interval through scrape_interval
+# static_configs is the service list of metrics server
 - job_name: 'prometheus'
   metrics_path: '/metrics'
   scrape_interval: 10s
   static_configs:
     - targets:
       - "127.0.0.1:9100"
+# In K8S, service discovery needs to be used to obtain the metrics server list.
+# Configure and select related pods through kubernetes_sd_configs.selectors
+# Because K8S resource permissions are involved, K8S serviceaccount needs to be configured
+# tls_config is the certificate assigned by K8S to satellite, and generally does not need to be changed.
 - job_name: 'prometheus-k8s'
   metrics_path: '/metrics'
   scrape_interval: 10s
diff --git a/plugins/fetcher/prometheus/fetcher.go b/plugins/fetcher/prometheus/fetcher.go
index 573a86b..1f76c11 100644
--- a/plugins/fetcher/prometheus/fetcher.go
+++ b/plugins/fetcher/prometheus/fetcher.go
@@ -98,13 +98,23 @@ func (f *Fetcher) Description() string {
 
 func (f *Fetcher) DefaultConfig() string {
 	return `
+# scrape_configs is the scrape configuration of prometheus 
+# which is fully compatible with prometheus scrap.
 scrape_configs:
+# job_name will be used as the label in prometheus, 
+# and in skywalking meterdata will be used as the service name.
+# Set the scrape interval through scrape_interval
+# static_configs is the service list of metrics server
 - job_name: 'prometheus'
   metrics_path: '/metrics'
   scrape_interval: 10s
   static_configs:
     - targets:
       - "127.0.0.1:9100"
+# In K8S, service discovery needs to be used to obtain the metrics server list.
+# Configure and select related pods through kubernetes_sd_configs.selectors
+# Because K8S resource permissions are involved, K8S serviceaccount needs to be configured
+# tls_config is the certificate assigned by K8S to satellite, and generally does not need to be changed.
 - job_name: 'prometheus-k8s'
   metrics_path: '/metrics'
   scrape_interval: 10s
diff --git a/plugins/fetcher/prometheus/metric_family.go b/plugins/fetcher/prometheus/metric_family.go
index b2f399b..eaf0c49 100644
--- a/plugins/fetcher/prometheus/metric_family.go
+++ b/plugins/fetcher/prometheus/metric_family.go
@@ -348,9 +348,11 @@ func isUsefulLabel(mType textparse.MetricType, labelKey string) bool {
 	switch labelKey {
 	case model.MetricNameLabel:
 	case model.InstanceLabel:
+		return false // instance name already in metadata
 	case model.SchemeLabel:
 	case model.MetricsPathLabel:
 	case model.JobLabel:
+		return false // service name already in metadata
 	case model.BucketLabel: // histogram le
 		return mType != textparse.MetricTypeHistogram
 	case model.QuantileLabel: // summary quantile