From 4dc62b8c1183953d21217c99927820534bb6efe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=BD=AA?= Date: Thu, 19 Sep 2024 11:44:11 +0800 Subject: [PATCH] fix: fix nginx host tag error --- internal/export/doc/en/apis.md | 0 internal/export/doc/en/changelog.md | 0 internal/export/doc/en/confd.md | 0 .../export/doc/en/datakit-batch-deploy.md | 0 internal/export/doc/en/datakit-conf.md | 0 .../export/doc/en/datakit-daemonset-deploy.md | 0 internal/export/doc/en/datakit-dql-how-to.md | 0 internal/export/doc/en/datakit-filter.md | 0 internal/export/doc/en/datakit-input-conf.md | 0 internal/export/doc/en/datakit-install.md | 0 internal/export/doc/en/datakit-monitor.md | 0 .../export/doc/en/datakit-offline-install.md | 0 internal/export/doc/en/datakit-refer-table.md | 0 .../export/doc/en/datakit-service-how-to.md | 0 .../export/doc/en/datakit-tools-how-to.md | 0 internal/export/doc/en/datakit-update.md | 0 internal/export/doc/en/dca.md | 0 internal/export/doc/en/development.md | 0 internal/export/doc/en/election.md | 0 internal/export/doc/en/git-config-how-to.md | 0 internal/export/doc/en/inputs/apache.md | 0 internal/export/doc/en/inputs/beats_output.md | 0 internal/export/doc/en/inputs/cassandra.md | 0 internal/export/doc/en/inputs/clickhousev1.md | 0 internal/export/doc/en/inputs/cloudprober.md | 0 internal/export/doc/en/inputs/cockroachdb.md | 0 internal/export/doc/en/inputs/consul.md | 0 .../export/doc/en/inputs/container-log.md | 0 internal/export/doc/en/inputs/container.md | 0 internal/export/doc/en/inputs/coredns.md | 0 internal/export/doc/en/inputs/cpu.md | 0 .../doc/en/inputs/datakit-logging-how.md | 0 .../export/doc/en/inputs/datakit-logging.md | 0 .../en/inputs/datakit-tracing-introduction.md | 0 .../doc/en/inputs/datakit-tracing-struct.md | 0 .../export/doc/en/inputs/datakit-tracing.md | 0 internal/export/doc/en/inputs/db2.md | 0 internal/export/doc/en/inputs/ddtrace-cpp.md | 0 .../export/doc/en/inputs/ddtrace-golang.md | 0 internal/export/doc/en/inputs/ddtrace-java.md | 0 .../export/doc/en/inputs/ddtrace-nodejs.md | 0 internal/export/doc/en/inputs/ddtrace-php.md | 0 .../export/doc/en/inputs/ddtrace-python.md | 0 internal/export/doc/en/inputs/ddtrace-ruby.md | 0 internal/export/doc/en/inputs/ddtrace.md | 0 .../export/doc/en/inputs/dialtesting_json.md | 0 internal/export/doc/en/inputs/disk.md | 0 internal/export/doc/en/inputs/diskio.md | 0 internal/export/doc/en/inputs/doc-logging.md | 0 internal/export/doc/en/inputs/doris.md | 0 internal/export/doc/en/inputs/ebpf.md | 0 .../export/doc/en/inputs/elasticsearch.md | 0 internal/export/doc/en/inputs/etcd.md | 0 internal/export/doc/en/inputs/external.md | 0 internal/export/doc/en/inputs/flinkv1.md | 0 internal/export/doc/en/inputs/gitlab.md | 0 internal/export/doc/en/inputs/gpu_smi.md | 0 .../export/doc/en/inputs/host_processes.md | 0 internal/export/doc/en/inputs/hostdir.md | 0 internal/export/doc/en/inputs/hostobject.md | 0 internal/export/doc/en/inputs/iis.md | 0 internal/export/doc/en/inputs/influxdb.md | 0 internal/export/doc/en/inputs/ipmi.md | 0 internal/export/doc/en/inputs/jaeger.md | 0 internal/export/doc/en/inputs/jenkins.md | 0 internal/export/doc/en/inputs/jvm.md | 0 internal/export/doc/en/inputs/kafka.md | 0 internal/export/doc/en/inputs/kafkamq.md | 0 .../export/doc/en/inputs/kubernetes-crd.md | 0 .../export/doc/en/inputs/kubernetes-prom.md | 0 .../kubernetes-prometheus-operator-crd.md | 0 internal/export/doc/en/inputs/logfwd.md | 0 internal/export/doc/en/inputs/logfwdserver.md | 0 .../doc/en/inputs/logging-pipeline-bench.md | 0 internal/export/doc/en/inputs/logging.md | 0 .../export/doc/en/inputs/logging_socket.md | 0 internal/export/doc/en/inputs/logstreaming.md | 0 internal/export/doc/en/inputs/mem.md | 0 internal/export/doc/en/inputs/memcached.md | 0 internal/export/doc/en/inputs/mongodb.md | 0 internal/export/doc/en/inputs/mysql.md | 0 internal/export/doc/en/inputs/net.md | 0 internal/export/doc/en/inputs/netflow.md | 0 internal/export/doc/en/inputs/netstat.md | 0 internal/export/doc/en/inputs/nginx.md | 0 internal/export/doc/en/inputs/nsq.md | 0 internal/export/doc/en/inputs/oceanbase.md | 0 .../export/doc/en/inputs/opentelemetry-go.md | 0 .../doc/en/inputs/opentelemetry-java.md | 0 .../export/doc/en/inputs/opentelemetry.md | 0 internal/export/doc/en/inputs/oracle.md | 0 internal/export/doc/en/inputs/postgresql.md | 0 internal/export/doc/en/inputs/profile.md | 0 internal/export/doc/en/inputs/prom.md | 0 .../export/doc/en/inputs/prom_remote_write.md | 0 internal/export/doc/en/inputs/promtail.md | 0 internal/export/doc/en/inputs/proxy.md | 0 .../export/doc/en/inputs/python-profiling.md | 0 internal/export/doc/en/inputs/rabbitmq.md | 0 internal/export/doc/en/inputs/redis.md | 0 internal/export/doc/en/inputs/rum.md | 0 internal/export/doc/en/inputs/sec-checker.md | 0 internal/export/doc/en/inputs/sensors.md | 0 internal/export/doc/en/inputs/skywalking.md | 0 internal/export/doc/en/inputs/smart.md | 0 internal/export/doc/en/inputs/snmp.md | 0 internal/export/doc/en/inputs/socket.md | 0 internal/export/doc/en/inputs/solr.md | 0 internal/export/doc/en/inputs/sqlserver.md | 0 internal/export/doc/en/inputs/ssh.md | 0 internal/export/doc/en/inputs/statsd.md | 0 internal/export/doc/en/inputs/swap.md | 0 internal/export/doc/en/inputs/system.md | 0 internal/export/doc/en/inputs/tdengine.md | 0 internal/export/doc/en/inputs/telegraf.md | 0 internal/export/doc/en/inputs/tomcat.md | 0 .../export/doc/en/inputs/windows_event.md | 0 internal/export/doc/en/inputs/zipkin.md | 0 internal/export/doc/en/k8s-config-how-to.md | 0 internal/export/doc/en/why-no-data.md | 0 .../zh/inputs/datakit-trace-performance.md | 0 internal/plugins/inputs/nginx/cfg.go | 1 + internal/plugins/inputs/nginx/collector.go | 20 +++---- internal/plugins/inputs/nginx/export.go | 0 internal/plugins/inputs/nginx/input.go | 8 +++ .../inputs/postgresql/customer_object.go | 18 ++---- .../postgresql/customer_object_helpers.go | 16 ++--- internal/plugins/inputs/postgresql/input.go | 25 +++++--- .../inputs/postgresql/input_unit_test.go | 6 +- .../inputs/postgresql/metric_fields.go | 17 ++---- .../plugins/inputs/postgresql/metric_up.go | 17 ++---- .../inputs/postgresql/metric_up_helpers.go | 60 ++++++------------- 132 files changed, 81 insertions(+), 107 deletions(-) mode change 100755 => 100644 internal/export/doc/en/apis.md mode change 100755 => 100644 internal/export/doc/en/changelog.md mode change 100755 => 100644 internal/export/doc/en/confd.md mode change 100755 => 100644 internal/export/doc/en/datakit-batch-deploy.md mode change 100755 => 100644 internal/export/doc/en/datakit-conf.md mode change 100755 => 100644 internal/export/doc/en/datakit-daemonset-deploy.md mode change 100755 => 100644 internal/export/doc/en/datakit-dql-how-to.md mode change 100755 => 100644 internal/export/doc/en/datakit-filter.md mode change 100755 => 100644 internal/export/doc/en/datakit-input-conf.md mode change 100755 => 100644 internal/export/doc/en/datakit-install.md mode change 100755 => 100644 internal/export/doc/en/datakit-monitor.md mode change 100755 => 100644 internal/export/doc/en/datakit-offline-install.md mode change 100755 => 100644 internal/export/doc/en/datakit-refer-table.md mode change 100755 => 100644 internal/export/doc/en/datakit-service-how-to.md mode change 100755 => 100644 internal/export/doc/en/datakit-tools-how-to.md mode change 100755 => 100644 internal/export/doc/en/datakit-update.md mode change 100755 => 100644 internal/export/doc/en/dca.md mode change 100755 => 100644 internal/export/doc/en/development.md mode change 100755 => 100644 internal/export/doc/en/election.md mode change 100755 => 100644 internal/export/doc/en/git-config-how-to.md mode change 100755 => 100644 internal/export/doc/en/inputs/apache.md mode change 100755 => 100644 internal/export/doc/en/inputs/beats_output.md mode change 100755 => 100644 internal/export/doc/en/inputs/cassandra.md mode change 100755 => 100644 internal/export/doc/en/inputs/clickhousev1.md mode change 100755 => 100644 internal/export/doc/en/inputs/cloudprober.md mode change 100755 => 100644 internal/export/doc/en/inputs/cockroachdb.md mode change 100755 => 100644 internal/export/doc/en/inputs/consul.md mode change 100755 => 100644 internal/export/doc/en/inputs/container-log.md mode change 100755 => 100644 internal/export/doc/en/inputs/container.md mode change 100755 => 100644 internal/export/doc/en/inputs/coredns.md mode change 100755 => 100644 internal/export/doc/en/inputs/cpu.md mode change 100755 => 100644 internal/export/doc/en/inputs/datakit-logging-how.md mode change 100755 => 100644 internal/export/doc/en/inputs/datakit-logging.md mode change 100755 => 100644 internal/export/doc/en/inputs/datakit-tracing-introduction.md mode change 100755 => 100644 internal/export/doc/en/inputs/datakit-tracing-struct.md mode change 100755 => 100644 internal/export/doc/en/inputs/datakit-tracing.md mode change 100755 => 100644 internal/export/doc/en/inputs/db2.md mode change 100755 => 100644 internal/export/doc/en/inputs/ddtrace-cpp.md mode change 100755 => 100644 internal/export/doc/en/inputs/ddtrace-golang.md mode change 100755 => 100644 internal/export/doc/en/inputs/ddtrace-java.md mode change 100755 => 100644 internal/export/doc/en/inputs/ddtrace-nodejs.md mode change 100755 => 100644 internal/export/doc/en/inputs/ddtrace-php.md mode change 100755 => 100644 internal/export/doc/en/inputs/ddtrace-python.md mode change 100755 => 100644 internal/export/doc/en/inputs/ddtrace-ruby.md mode change 100755 => 100644 internal/export/doc/en/inputs/ddtrace.md mode change 100755 => 100644 internal/export/doc/en/inputs/dialtesting_json.md mode change 100755 => 100644 internal/export/doc/en/inputs/disk.md mode change 100755 => 100644 internal/export/doc/en/inputs/diskio.md mode change 100755 => 100644 internal/export/doc/en/inputs/doc-logging.md mode change 100755 => 100644 internal/export/doc/en/inputs/doris.md mode change 100755 => 100644 internal/export/doc/en/inputs/ebpf.md mode change 100755 => 100644 internal/export/doc/en/inputs/elasticsearch.md mode change 100755 => 100644 internal/export/doc/en/inputs/etcd.md mode change 100755 => 100644 internal/export/doc/en/inputs/external.md mode change 100755 => 100644 internal/export/doc/en/inputs/flinkv1.md mode change 100755 => 100644 internal/export/doc/en/inputs/gitlab.md mode change 100755 => 100644 internal/export/doc/en/inputs/gpu_smi.md mode change 100755 => 100644 internal/export/doc/en/inputs/host_processes.md mode change 100755 => 100644 internal/export/doc/en/inputs/hostdir.md mode change 100755 => 100644 internal/export/doc/en/inputs/hostobject.md mode change 100755 => 100644 internal/export/doc/en/inputs/iis.md mode change 100755 => 100644 internal/export/doc/en/inputs/influxdb.md mode change 100755 => 100644 internal/export/doc/en/inputs/ipmi.md mode change 100755 => 100644 internal/export/doc/en/inputs/jaeger.md mode change 100755 => 100644 internal/export/doc/en/inputs/jenkins.md mode change 100755 => 100644 internal/export/doc/en/inputs/jvm.md mode change 100755 => 100644 internal/export/doc/en/inputs/kafka.md mode change 100755 => 100644 internal/export/doc/en/inputs/kafkamq.md mode change 100755 => 100644 internal/export/doc/en/inputs/kubernetes-crd.md mode change 100755 => 100644 internal/export/doc/en/inputs/kubernetes-prom.md mode change 100755 => 100644 internal/export/doc/en/inputs/kubernetes-prometheus-operator-crd.md mode change 100755 => 100644 internal/export/doc/en/inputs/logfwd.md mode change 100755 => 100644 internal/export/doc/en/inputs/logfwdserver.md mode change 100755 => 100644 internal/export/doc/en/inputs/logging-pipeline-bench.md mode change 100755 => 100644 internal/export/doc/en/inputs/logging.md mode change 100755 => 100644 internal/export/doc/en/inputs/logging_socket.md mode change 100755 => 100644 internal/export/doc/en/inputs/logstreaming.md mode change 100755 => 100644 internal/export/doc/en/inputs/mem.md mode change 100755 => 100644 internal/export/doc/en/inputs/memcached.md mode change 100755 => 100644 internal/export/doc/en/inputs/mongodb.md mode change 100755 => 100644 internal/export/doc/en/inputs/mysql.md mode change 100755 => 100644 internal/export/doc/en/inputs/net.md mode change 100755 => 100644 internal/export/doc/en/inputs/netflow.md mode change 100755 => 100644 internal/export/doc/en/inputs/netstat.md mode change 100755 => 100644 internal/export/doc/en/inputs/nginx.md mode change 100755 => 100644 internal/export/doc/en/inputs/nsq.md mode change 100755 => 100644 internal/export/doc/en/inputs/oceanbase.md mode change 100755 => 100644 internal/export/doc/en/inputs/opentelemetry-go.md mode change 100755 => 100644 internal/export/doc/en/inputs/opentelemetry-java.md mode change 100755 => 100644 internal/export/doc/en/inputs/opentelemetry.md mode change 100755 => 100644 internal/export/doc/en/inputs/oracle.md mode change 100755 => 100644 internal/export/doc/en/inputs/postgresql.md mode change 100755 => 100644 internal/export/doc/en/inputs/profile.md mode change 100755 => 100644 internal/export/doc/en/inputs/prom.md mode change 100755 => 100644 internal/export/doc/en/inputs/prom_remote_write.md mode change 100755 => 100644 internal/export/doc/en/inputs/promtail.md mode change 100755 => 100644 internal/export/doc/en/inputs/proxy.md mode change 100755 => 100644 internal/export/doc/en/inputs/python-profiling.md mode change 100755 => 100644 internal/export/doc/en/inputs/rabbitmq.md mode change 100755 => 100644 internal/export/doc/en/inputs/redis.md mode change 100755 => 100644 internal/export/doc/en/inputs/rum.md mode change 100755 => 100644 internal/export/doc/en/inputs/sec-checker.md mode change 100755 => 100644 internal/export/doc/en/inputs/sensors.md mode change 100755 => 100644 internal/export/doc/en/inputs/skywalking.md mode change 100755 => 100644 internal/export/doc/en/inputs/smart.md mode change 100755 => 100644 internal/export/doc/en/inputs/snmp.md mode change 100755 => 100644 internal/export/doc/en/inputs/socket.md mode change 100755 => 100644 internal/export/doc/en/inputs/solr.md mode change 100755 => 100644 internal/export/doc/en/inputs/sqlserver.md mode change 100755 => 100644 internal/export/doc/en/inputs/ssh.md mode change 100755 => 100644 internal/export/doc/en/inputs/statsd.md mode change 100755 => 100644 internal/export/doc/en/inputs/swap.md mode change 100755 => 100644 internal/export/doc/en/inputs/system.md mode change 100755 => 100644 internal/export/doc/en/inputs/tdengine.md mode change 100755 => 100644 internal/export/doc/en/inputs/telegraf.md mode change 100755 => 100644 internal/export/doc/en/inputs/tomcat.md mode change 100755 => 100644 internal/export/doc/en/inputs/windows_event.md mode change 100755 => 100644 internal/export/doc/en/inputs/zipkin.md mode change 100755 => 100644 internal/export/doc/en/k8s-config-how-to.md mode change 100755 => 100644 internal/export/doc/en/why-no-data.md mode change 100755 => 100644 internal/export/doc/zh/inputs/datakit-trace-performance.md mode change 100755 => 100644 internal/plugins/inputs/nginx/export.go diff --git a/internal/export/doc/en/apis.md b/internal/export/doc/en/apis.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/changelog.md b/internal/export/doc/en/changelog.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/confd.md b/internal/export/doc/en/confd.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-batch-deploy.md b/internal/export/doc/en/datakit-batch-deploy.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-conf.md b/internal/export/doc/en/datakit-conf.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-daemonset-deploy.md b/internal/export/doc/en/datakit-daemonset-deploy.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-dql-how-to.md b/internal/export/doc/en/datakit-dql-how-to.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-filter.md b/internal/export/doc/en/datakit-filter.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-input-conf.md b/internal/export/doc/en/datakit-input-conf.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-install.md b/internal/export/doc/en/datakit-install.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-monitor.md b/internal/export/doc/en/datakit-monitor.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-offline-install.md b/internal/export/doc/en/datakit-offline-install.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-refer-table.md b/internal/export/doc/en/datakit-refer-table.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-service-how-to.md b/internal/export/doc/en/datakit-service-how-to.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-tools-how-to.md b/internal/export/doc/en/datakit-tools-how-to.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/datakit-update.md b/internal/export/doc/en/datakit-update.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/dca.md b/internal/export/doc/en/dca.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/development.md b/internal/export/doc/en/development.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/election.md b/internal/export/doc/en/election.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/git-config-how-to.md b/internal/export/doc/en/git-config-how-to.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/apache.md b/internal/export/doc/en/inputs/apache.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/beats_output.md b/internal/export/doc/en/inputs/beats_output.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/cassandra.md b/internal/export/doc/en/inputs/cassandra.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/clickhousev1.md b/internal/export/doc/en/inputs/clickhousev1.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/cloudprober.md b/internal/export/doc/en/inputs/cloudprober.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/cockroachdb.md b/internal/export/doc/en/inputs/cockroachdb.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/consul.md b/internal/export/doc/en/inputs/consul.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/container-log.md b/internal/export/doc/en/inputs/container-log.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/container.md b/internal/export/doc/en/inputs/container.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/coredns.md b/internal/export/doc/en/inputs/coredns.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/cpu.md b/internal/export/doc/en/inputs/cpu.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/datakit-logging-how.md b/internal/export/doc/en/inputs/datakit-logging-how.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/datakit-logging.md b/internal/export/doc/en/inputs/datakit-logging.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/datakit-tracing-introduction.md b/internal/export/doc/en/inputs/datakit-tracing-introduction.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/datakit-tracing-struct.md b/internal/export/doc/en/inputs/datakit-tracing-struct.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/datakit-tracing.md b/internal/export/doc/en/inputs/datakit-tracing.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/db2.md b/internal/export/doc/en/inputs/db2.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ddtrace-cpp.md b/internal/export/doc/en/inputs/ddtrace-cpp.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ddtrace-golang.md b/internal/export/doc/en/inputs/ddtrace-golang.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ddtrace-java.md b/internal/export/doc/en/inputs/ddtrace-java.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ddtrace-nodejs.md b/internal/export/doc/en/inputs/ddtrace-nodejs.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ddtrace-php.md b/internal/export/doc/en/inputs/ddtrace-php.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ddtrace-python.md b/internal/export/doc/en/inputs/ddtrace-python.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ddtrace-ruby.md b/internal/export/doc/en/inputs/ddtrace-ruby.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ddtrace.md b/internal/export/doc/en/inputs/ddtrace.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/dialtesting_json.md b/internal/export/doc/en/inputs/dialtesting_json.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/disk.md b/internal/export/doc/en/inputs/disk.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/diskio.md b/internal/export/doc/en/inputs/diskio.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/doc-logging.md b/internal/export/doc/en/inputs/doc-logging.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/doris.md b/internal/export/doc/en/inputs/doris.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ebpf.md b/internal/export/doc/en/inputs/ebpf.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/elasticsearch.md b/internal/export/doc/en/inputs/elasticsearch.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/etcd.md b/internal/export/doc/en/inputs/etcd.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/external.md b/internal/export/doc/en/inputs/external.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/flinkv1.md b/internal/export/doc/en/inputs/flinkv1.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/gitlab.md b/internal/export/doc/en/inputs/gitlab.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/gpu_smi.md b/internal/export/doc/en/inputs/gpu_smi.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/host_processes.md b/internal/export/doc/en/inputs/host_processes.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/hostdir.md b/internal/export/doc/en/inputs/hostdir.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/hostobject.md b/internal/export/doc/en/inputs/hostobject.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/iis.md b/internal/export/doc/en/inputs/iis.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/influxdb.md b/internal/export/doc/en/inputs/influxdb.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ipmi.md b/internal/export/doc/en/inputs/ipmi.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/jaeger.md b/internal/export/doc/en/inputs/jaeger.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/jenkins.md b/internal/export/doc/en/inputs/jenkins.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/jvm.md b/internal/export/doc/en/inputs/jvm.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/kafka.md b/internal/export/doc/en/inputs/kafka.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/kafkamq.md b/internal/export/doc/en/inputs/kafkamq.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/kubernetes-crd.md b/internal/export/doc/en/inputs/kubernetes-crd.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/kubernetes-prom.md b/internal/export/doc/en/inputs/kubernetes-prom.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/kubernetes-prometheus-operator-crd.md b/internal/export/doc/en/inputs/kubernetes-prometheus-operator-crd.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/logfwd.md b/internal/export/doc/en/inputs/logfwd.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/logfwdserver.md b/internal/export/doc/en/inputs/logfwdserver.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/logging-pipeline-bench.md b/internal/export/doc/en/inputs/logging-pipeline-bench.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/logging.md b/internal/export/doc/en/inputs/logging.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/logging_socket.md b/internal/export/doc/en/inputs/logging_socket.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/logstreaming.md b/internal/export/doc/en/inputs/logstreaming.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/mem.md b/internal/export/doc/en/inputs/mem.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/memcached.md b/internal/export/doc/en/inputs/memcached.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/mongodb.md b/internal/export/doc/en/inputs/mongodb.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/mysql.md b/internal/export/doc/en/inputs/mysql.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/net.md b/internal/export/doc/en/inputs/net.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/netflow.md b/internal/export/doc/en/inputs/netflow.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/netstat.md b/internal/export/doc/en/inputs/netstat.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/nginx.md b/internal/export/doc/en/inputs/nginx.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/nsq.md b/internal/export/doc/en/inputs/nsq.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/oceanbase.md b/internal/export/doc/en/inputs/oceanbase.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/opentelemetry-go.md b/internal/export/doc/en/inputs/opentelemetry-go.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/opentelemetry-java.md b/internal/export/doc/en/inputs/opentelemetry-java.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/opentelemetry.md b/internal/export/doc/en/inputs/opentelemetry.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/oracle.md b/internal/export/doc/en/inputs/oracle.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/postgresql.md b/internal/export/doc/en/inputs/postgresql.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/profile.md b/internal/export/doc/en/inputs/profile.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/prom.md b/internal/export/doc/en/inputs/prom.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/prom_remote_write.md b/internal/export/doc/en/inputs/prom_remote_write.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/promtail.md b/internal/export/doc/en/inputs/promtail.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/proxy.md b/internal/export/doc/en/inputs/proxy.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/python-profiling.md b/internal/export/doc/en/inputs/python-profiling.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/rabbitmq.md b/internal/export/doc/en/inputs/rabbitmq.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/redis.md b/internal/export/doc/en/inputs/redis.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/rum.md b/internal/export/doc/en/inputs/rum.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/sec-checker.md b/internal/export/doc/en/inputs/sec-checker.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/sensors.md b/internal/export/doc/en/inputs/sensors.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/skywalking.md b/internal/export/doc/en/inputs/skywalking.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/smart.md b/internal/export/doc/en/inputs/smart.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/snmp.md b/internal/export/doc/en/inputs/snmp.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/socket.md b/internal/export/doc/en/inputs/socket.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/solr.md b/internal/export/doc/en/inputs/solr.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/sqlserver.md b/internal/export/doc/en/inputs/sqlserver.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/ssh.md b/internal/export/doc/en/inputs/ssh.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/statsd.md b/internal/export/doc/en/inputs/statsd.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/swap.md b/internal/export/doc/en/inputs/swap.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/system.md b/internal/export/doc/en/inputs/system.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/tdengine.md b/internal/export/doc/en/inputs/tdengine.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/telegraf.md b/internal/export/doc/en/inputs/telegraf.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/tomcat.md b/internal/export/doc/en/inputs/tomcat.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/windows_event.md b/internal/export/doc/en/inputs/windows_event.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/inputs/zipkin.md b/internal/export/doc/en/inputs/zipkin.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/k8s-config-how-to.md b/internal/export/doc/en/k8s-config-how-to.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/en/why-no-data.md b/internal/export/doc/en/why-no-data.md old mode 100755 new mode 100644 diff --git a/internal/export/doc/zh/inputs/datakit-trace-performance.md b/internal/export/doc/zh/inputs/datakit-trace-performance.md old mode 100755 new mode 100644 diff --git a/internal/plugins/inputs/nginx/cfg.go b/internal/plugins/inputs/nginx/cfg.go index df43e9ee2d..01a2df95c5 100644 --- a/internal/plugins/inputs/nginx/cfg.go +++ b/internal/plugins/inputs/nginx/cfg.go @@ -65,6 +65,7 @@ type Input struct { UsePlusAPI bool `toml:"use_plus_api"` Log *ngxlog `toml:"log"` Tags map[string]string `toml:"tags"` + mergedTags map[string]string UpState int diff --git a/internal/plugins/inputs/nginx/collector.go b/internal/plugins/inputs/nginx/collector.go index 54735af6d3..6b76ef7951 100644 --- a/internal/plugins/inputs/nginx/collector.go +++ b/internal/plugins/inputs/nginx/collector.go @@ -105,7 +105,7 @@ func (ipt *Input) getStubStatusModuleMetric(port int) { kvs := make(point.KVs, 0, 9) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for k, v := range ipt.Tags { kvs = kvs.MustAddTag(k, v) @@ -176,7 +176,7 @@ func (ipt *Input) handVTSResponse(r io.Reader, port int) { func (ipt *Input) makeConnectionsLine(vtsResp NginxVTSResponse) { kvs := make(point.KVs, 0, 12) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for k, v := range vtsResp.tags { kvs = kvs.MustAddTag(k, v) @@ -198,7 +198,7 @@ func (ipt *Input) makeServerZoneLine(vtsResp NginxVTSResponse) { for k, v := range vtsResp.ServerZones { kvs := make(point.KVs, 0, 13) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for kk, vv := range vtsResp.tags { kvs = kvs.MustAddTag(kk, vv) @@ -223,7 +223,7 @@ func (ipt *Input) makeUpstreamZoneLine(vtsResp NginxVTSResponse) { for _, upstream := range upstreams { kvs := make(point.KVs, 0, 14) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for kk, vv := range vtsResp.tags { kvs = kvs.MustAddTag(kk, vv) @@ -249,7 +249,7 @@ func (ipt *Input) makeCacheZoneLine(vtsResp NginxVTSResponse) { for cacheName, cacheZone := range vtsResp.CacheZones { kvs := make(point.KVs, 0, 17) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for kk, vv := range vtsResp.tags { kvs = kvs.MustAddTag(kk, vv) @@ -341,7 +341,7 @@ func (ipt *Input) handlePlusAPIResponse(r io.Reader, plusAPIResp *NginxPlusAPIRe func (ipt *Input) makeNginxLine(plusAPIResp NginxPlusAPIResponse) { kvs := make(point.KVs, 0, 10) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for k, v := range plusAPIResp.tags { kvs = kvs.MustAddTag(k, v) @@ -358,7 +358,7 @@ func (ipt *Input) makeServerLine(plusAPIResp NginxPlusAPIResponse) { for k, v := range plusAPIResp.Servers { kvs := make(point.KVs, 0, 20) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for kk, vv := range plusAPIResp.tags { kvs = kvs.MustAddTag(kk, vv) @@ -392,7 +392,7 @@ func (ipt *Input) makeUpStreamLine(plusAPIResp NginxPlusAPIResponse) { for _, upstream := range upstreams.Peers { kvs := make(point.KVs, 0, 20) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for kk, vv := range plusAPIResp.tags { kvs = kvs.MustAddTag(kk, vv) @@ -424,7 +424,7 @@ func (ipt *Input) makeCacheLine(plusAPIResp NginxPlusAPIResponse) { for k, v := range plusAPIResp.Caches { kvs := make(point.KVs, 0, 15) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for kk, vv := range plusAPIResp.tags { kvs = kvs.MustAddTag(kk, vv) @@ -450,7 +450,7 @@ func (ipt *Input) makeLocationLine(plusAPIResp NginxPlusAPIResponse) { for locationName, location := range plusAPIResp.Locations { kvs := make(point.KVs, 0, 20) opts := point.DefaultMetricOptions() - opts = append(opts, point.WithTime(ipt.start)) + opts = append(opts, point.WithTime(ipt.start), point.WithExtraTags(ipt.mergedTags)) for kk, vv := range plusAPIResp.tags { kvs = kvs.MustAddTag(kk, vv) diff --git a/internal/plugins/inputs/nginx/export.go b/internal/plugins/inputs/nginx/export.go old mode 100755 new mode 100644 diff --git a/internal/plugins/inputs/nginx/input.go b/internal/plugins/inputs/nginx/input.go index 1302adfd8a..ea8cb80073 100644 --- a/internal/plugins/inputs/nginx/input.go +++ b/internal/plugins/inputs/nginx/input.go @@ -188,6 +188,14 @@ func (ipt *Input) Run() { tick := time.NewTicker(ipt.Interval) defer tick.Stop() + if ipt.Election { + ipt.mergedTags = inputs.MergeTags(ipt.Tagger.ElectionTags(), ipt.Tags, ipt.URL) + } else { + ipt.mergedTags = inputs.MergeTags(ipt.Tagger.HostTags(), ipt.Tags, ipt.URL) + } + + l.Infof("merged tags: %+#v", ipt.mergedTags) + for { if ipt.pause { l.Debugf("not leader, skipped") diff --git a/internal/plugins/inputs/postgresql/customer_object.go b/internal/plugins/inputs/postgresql/customer_object.go index 7cafd7aaab..d27ad28c0b 100644 --- a/internal/plugins/inputs/postgresql/customer_object.go +++ b/internal/plugins/inputs/postgresql/customer_object.go @@ -7,29 +7,21 @@ package postgresql import ( "github.com/GuanceCloud/cliutils/point" - "gitlab.jiagouyun.com/cloudcare-tools/datakit/internal/datakit" "gitlab.jiagouyun.com/cloudcare-tools/datakit/internal/plugins/inputs" ) type customerObjectMeasurement struct { - name string - tags map[string]string - fields map[string]interface{} - election bool + name string + tags map[string]string + fields map[string]interface{} + ipt *Input } // Point implement MeasurementV2. func (m *customerObjectMeasurement) Point() *point.Point { - opts := point.DefaultObjectOptions() - if m.election { - opts = append(opts, - point.WithExtraTags(datakit.GlobalElectionTags()), - ) - point.DefaultObjectOptions() - } return point.NewPointV2(m.name, append(point.NewTags(m.tags), point.NewKVs(m.fields)...), - opts...) + append(point.DefaultObjectOptions(), point.WithExtraTags(m.ipt.mergedTags))...) } //nolint:lll diff --git a/internal/plugins/inputs/postgresql/customer_object_helpers.go b/internal/plugins/inputs/postgresql/customer_object_helpers.go index eac6493bde..97e61fb4e7 100644 --- a/internal/plugins/inputs/postgresql/customer_object_helpers.go +++ b/internal/plugins/inputs/postgresql/customer_object_helpers.go @@ -70,10 +70,10 @@ func (ipt *Input) getCoPointByColErr() []*gcPoint.Point { "col_co_status": ipt.CollectCoStatus, } m := &customerObjectMeasurement{ - name: "database", - tags: tags, - fields: fields, - election: ipt.Election, + name: "database", + tags: tags, + fields: fields, + ipt: ipt, } ipt.setIptLastCOInfo(m) ms = append(ms, m) @@ -170,10 +170,10 @@ func (ipt *Input) collectCustomerObjectMeasurement() ([]*gcPoint.Point, error) { "col_co_status": ipt.CollectCoStatus, } m := &customerObjectMeasurement{ - name: "database", - tags: tags, - fields: fields, - election: ipt.Election, + name: "database", + tags: tags, + fields: fields, + ipt: ipt, } ipt.setIptLastCOInfo(m) ms = append(ms, m) diff --git a/internal/plugins/inputs/postgresql/input.go b/internal/plugins/inputs/postgresql/input.go index 5e1e547a8f..cfd8ba0228 100644 --- a/internal/plugins/inputs/postgresql/input.go +++ b/internal/plugins/inputs/postgresql/input.go @@ -192,9 +192,10 @@ type Input struct { Databases []string `toml:"databases"` Interval string `toml:"interval"` Tags map[string]string `toml:"tags"` - Relations []Relation `toml:"relations"` - CustomQuery []*customQuery `toml:"custom_queries"` - Log *postgresqllog `toml:"log"` + mergedTags map[string]string + Relations []Relation `toml:"relations"` + CustomQuery []*customQuery `toml:"custom_queries"` + Log *postgresqllog `toml:"log"` Version string Uptime int @@ -832,11 +833,11 @@ func (ipt *Input) accRow(columnMap map[string]*interface{}, measurementInfo *inp name = measurementInfo.Name } ms := &inputMeasurement{ - name: name, - fields: fields, - tags: tags, - ts: time.Now(), - election: ipt.Election, + name: name, + fields: fields, + tags: tags, + ts: time.Now(), + ipt: ipt, } ipt.collectCache = append(ipt.collectCache, ms.Point()) } @@ -912,6 +913,14 @@ func (ipt *Input) init() error { ipt.Tags["server"] = tagAddress ipt.Tags["db"] = dbName + if ipt.Election { + ipt.mergedTags = inputs.MergeTags(ipt.tagger.ElectionTags(), ipt.Tags, ipt.Address) + } else { + ipt.mergedTags = inputs.MergeTags(ipt.tagger.HostTags(), ipt.Tags, ipt.Address) + } + + l.Infof("merged tags: %+#v", ipt.mergedTags) + // init query cache ipt.metricQueryCache = map[string]*queryCacheItem{} diff --git a/internal/plugins/inputs/postgresql/input_unit_test.go b/internal/plugins/inputs/postgresql/input_unit_test.go index 91c5aa909f..31016a5fa4 100644 --- a/internal/plugins/inputs/postgresql/input_unit_test.go +++ b/internal/plugins/inputs/postgresql/input_unit_test.go @@ -129,9 +129,9 @@ func getTrueData(mockFields map[string]interface{}) map[string]interface{} { } func TestCollect(t *testing.T) { - input := &Input{ - version: &semver.Version{Major: 12}, - } + input := defaultInput() + + input.version = &semver.Version{Major: 12} input.service = &MockCollectService{} err := input.Collect() if err != nil { diff --git a/internal/plugins/inputs/postgresql/metric_fields.go b/internal/plugins/inputs/postgresql/metric_fields.go index d6c7788853..069c269596 100644 --- a/internal/plugins/inputs/postgresql/metric_fields.go +++ b/internal/plugins/inputs/postgresql/metric_fields.go @@ -10,7 +10,6 @@ import ( "github.com/GuanceCloud/cliutils/point" - "gitlab.jiagouyun.com/cloudcare-tools/datakit/internal/datakit" "gitlab.jiagouyun.com/cloudcare-tools/datakit/internal/plugins/inputs" ) @@ -109,20 +108,16 @@ WHERE %s } type inputMeasurement struct { - name string - tags map[string]string - fields map[string]interface{} - ts time.Time - election bool + name string + tags map[string]string + fields map[string]interface{} + ts time.Time + ipt *Input } // Point implement MeasurementV2. func (m *inputMeasurement) Point() *point.Point { - opts := point.DefaultMetricOptions() - - if m.election { - opts = append(opts, point.WithExtraTags(datakit.GlobalElectionTags())) - } + opts := append(point.DefaultMetricOptions(), point.WithExtraTags(m.ipt.mergedTags)) return point.NewPointV2(m.name, append(point.NewTags(m.tags), point.NewKVs(m.fields)...), diff --git a/internal/plugins/inputs/postgresql/metric_up.go b/internal/plugins/inputs/postgresql/metric_up.go index 3972b8bea0..af468ac91d 100644 --- a/internal/plugins/inputs/postgresql/metric_up.go +++ b/internal/plugins/inputs/postgresql/metric_up.go @@ -7,28 +7,21 @@ package postgresql import ( "github.com/GuanceCloud/cliutils/point" - "gitlab.jiagouyun.com/cloudcare-tools/datakit/internal/datakit" "gitlab.jiagouyun.com/cloudcare-tools/datakit/internal/plugins/inputs" ) type upMeasurement struct { - name string - tags map[string]string - fields map[string]interface{} - election bool + name string + tags map[string]string + fields map[string]interface{} + ipt *Input } // Point implement MeasurementV2. func (m *upMeasurement) Point() *point.Point { - opts := point.DefaultMetricOptions() - - if m.election { - opts = append(opts, point.WithExtraTags(datakit.GlobalElectionTags())) - } - return point.NewPointV2(m.name, append(point.NewTags(m.tags), point.NewKVs(m.fields)...), - opts...) + append(point.DefaultMetricOptions(), point.WithExtraTags(m.ipt.mergedTags))...) } func (m *upMeasurement) Info() *inputs.MeasurementInfo { //nolint:funlen diff --git a/internal/plugins/inputs/postgresql/metric_up_helpers.go b/internal/plugins/inputs/postgresql/metric_up_helpers.go index e9a9bfcdcf..7c63461503 100644 --- a/internal/plugins/inputs/postgresql/metric_up_helpers.go +++ b/internal/plugins/inputs/postgresql/metric_up_helpers.go @@ -10,13 +10,11 @@ import ( "net" "net/url" "strconv" - "time" "github.com/GuanceCloud/cliutils/point" dkio "gitlab.jiagouyun.com/cloudcare-tools/datakit/internal/io" "gitlab.jiagouyun.com/cloudcare-tools/datakit/internal/metrics" - "gitlab.jiagouyun.com/cloudcare-tools/datakit/internal/plugins/inputs" ) func (ipt *Input) setUpState() { @@ -51,8 +49,7 @@ func (ipt *Input) getUpInstance() string { return ipPort } -func (ipt *Input) buildUpPoints() ([]*point.Point, error) { - ms := []inputs.MeasurementV2{} +func (ipt *Input) buildUpPoints() *point.Point { tags := map[string]string{ "job": ipt.getUpJob(), "instance": ipt.getUpInstance(), @@ -61,49 +58,28 @@ func (ipt *Input) buildUpPoints() ([]*point.Point, error) { "up": ipt.UpState, } m := &upMeasurement{ - name: "collector", - tags: tags, - fields: fields, - election: ipt.Election, - } - l.Debugf("build up %s points:%s", inputName, m.Point().LineProto()) - ms = append(ms, m) - if len(ms) > 0 { - pts := getPointsFromMeasurement2(ms) - for k, v := range ipt.Tags { - for _, pt := range pts { - pt.AddTag(k, v) - } - } - return pts, nil + name: "collector", + tags: tags, + fields: fields, + ipt: ipt, } - return []*point.Point{}, nil + return m.Point() } -func getPointsFromMeasurement2(ms []inputs.MeasurementV2) []*point.Point { - pts := []*point.Point{} - for _, m := range ms { - pts = append(pts, m.Point()) - } +func (ipt *Input) FeedUpMetric() { + pt := ipt.buildUpPoints() - return pts -} + l.Debug("feed up metric") -func (ipt *Input) FeedUpMetric() { - pts, _ := ipt.buildUpPoints() - if len(pts) > 0 { - l.Debug("feed up metric") - if err := ipt.feeder.FeedV2(point.Metric, pts, - dkio.WithCollectCost(time.Since(time.Now())), - dkio.WithElection(ipt.Election), - dkio.WithInputName(inputName), - ); err != nil { - ipt.feeder.FeedLastError(err.Error(), - metrics.WithLastErrorInput(inputName), - metrics.WithLastErrorCategory(point.Metric), - ) - l.Errorf("feed : %s", err) - } + if err := ipt.feeder.FeedV2(point.Metric, []*point.Point{pt}, + dkio.WithElection(ipt.Election), + dkio.WithInputName(inputName), + ); err != nil { + ipt.feeder.FeedLastError(err.Error(), + metrics.WithLastErrorInput(inputName), + metrics.WithLastErrorCategory(point.Metric), + ) + l.Errorf("feed : %s", err) } }