From 23bc67fd7db43bb5754d664ecbf75062d577f2a6 Mon Sep 17 00:00:00 2001 From: Ilya Mashchenko Date: Fri, 15 Mar 2024 12:49:42 +0200 Subject: [PATCH] go.d sd docker use well-known port for app identification too (#17174) --- .../agent/discovery/sd/pipeline/promport.go | 1 - .../go.d.plugin/config/go.d/sd/docker.conf | 31 +++++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/go/collectors/go.d.plugin/agent/discovery/sd/pipeline/promport.go b/src/go/collectors/go.d.plugin/agent/discovery/sd/pipeline/promport.go index 7c15933893c159..2ebe9f95ba5c1a 100644 --- a/src/go/collectors/go.d.plugin/agent/discovery/sd/pipeline/promport.go +++ b/src/go/collectors/go.d.plugin/agent/discovery/sd/pipeline/promport.go @@ -70,7 +70,6 @@ var prometheusPortAllocations = map[int]string{ 9150: "memcached_exporter", 9151: "varnish_request_exporter", 9152: "command_runner_exporter", - 9153: "coredns", 9154: "postfix_exporter", 9155: "vsphere_graphite", 9156: "webdriver_exporter", diff --git a/src/go/collectors/go.d.plugin/config/go.d/sd/docker.conf b/src/go/collectors/go.d.plugin/config/go.d/sd/docker.conf index 676cf838942749..9120eebd8ead48 100644 --- a/src/go/collectors/go.d.plugin/config/go.d/sd/docker.conf +++ b/src/go/collectors/go.d.plugin/config/go.d/sd/docker.conf @@ -31,39 +31,37 @@ classify: - tags: "coredns" expr: '{{ match "sp" .Image "*/coredns */coredns:*" }}' - tags: "couchbase" - expr: '{{ match "sp" .Image "couchbase couchbase:*" }}' + expr: '{{ or (eq .PrivatePort "8091") (match "sp" .Image "couchbase couchbase:*") }}' - tags: "couchdb" - expr: '{{ match "sp" .Image "couchdb couchdb:*" }}' + expr: '{{ or (eq .PrivatePort "5984") (match "sp" .Image "couchdb couchdb:*") }}' - tags: "elasticsearch" - expr: '{{ match "sp" .Image "elasticsearch elasticsearch:* */elasticsearch */elasticsearch:*" }}' - - tags: "opensearch" - expr: '{{ match "sp" .Image "*/opensearch */opensearch:*" }}' + expr: '{{ or (eq .PrivatePort "9200") (match "sp" .Image "elasticsearch elasticsearch:* */elasticsearch */elasticsearch:* */opensearch */opensearch:*") }}' - tags: "lighttpd" expr: '{{ match "sp" .Image "*/lighttpd */lighttpd:*" }}' - tags: "mongodb" - expr: '{{ match "sp" .Image "mongo mongo:* */mongodb */mongodb:* */mongodb-community-server */mongodb-community-server:*" }}' + expr: '{{ or (eq .PrivatePort "27017") (match "sp" .Image "mongo mongo:* */mongodb */mongodb:* */mongodb-community-server */mongodb-community-server:*") }}' - tags: "mysql" - expr: '{{ match "sp" .Image "mysql mysql:* */mysql */mysql:* mariadb mariadb:* */mariadb */mariadb:* percona percona:* */percona-mysql */percona-mysql:*" }}' + expr: '{{ or (eq .PrivatePort "3306") (match "sp" .Image "mysql mysql:* */mysql */mysql:* mariadb mariadb:* */mariadb */mariadb:* percona percona:* */percona-mysql */percona-mysql:*") }}' - tags: "nginx" expr: '{{ match "sp" .Image "nginx nginx:*" }}' - tags: "pgbouncer" - expr: '{{ match "sp" .Image "*/pgbouncer */pgbouncer:*" }}' + expr: '{{ or (eq .PrivatePort "6432") (match "sp" .Image "*/pgbouncer */pgbouncer:*") }}' - tags: "pika" expr: '{{ match "sp" .Image "pikadb/pika pikadb/pika:*" }}' - tags: "postgres" - expr: '{{ match "sp" .Image "postgres postgres:* */postgres */postgres:* */postgresql */postgresql:*" }}' + expr: '{{ or (eq .PrivatePort "5432") (match "sp" .Image "postgres postgres:* */postgres */postgres:* */postgresql */postgresql:*") }}' - tags: "proxysql" - expr: '{{ match "sp" .Image "*/proxysql */proxysql:*" }}' + expr: '{{ or (eq .PrivatePort "6032") (match "sp" .Image "*/proxysql */proxysql:*") }}' - tags: "rabbitmq" - expr: '{{ match "sp" .Image "rabbitmq rabbitmq:* */rabbitmq */rabbitmq:*" }}' + expr: '{{ or (eq .PrivatePort "15672") (match "sp" .Image "rabbitmq rabbitmq:* */rabbitmq */rabbitmq:*") }}' - tags: "redis" - expr: '{{ match "sp" .Image "redis redis:* */redis */redis:*" }}' + expr: '{{ or (eq .PrivatePort "6379") (match "sp" .Image "redis redis:* */redis */redis:*") }}' - tags: "tengine" expr: '{{ match "sp" .Image "*/tengine */tengine:*" }}' - tags: "vernemq" expr: '{{ match "sp" .Image "*/vernemq */vernemq:*" }}' - tags: "zookeeper" - expr: '{{ match "sp" .Image "*/zookeeper */zookeeper:*" }}' + expr: '{{ or (eq .PrivatePort "2181") (match "sp" .Image "*/zookeeper */zookeeper:*") }}' compose: - name: "Applications" selector: "app" @@ -107,15 +105,14 @@ compose: template: | module: elasticsearch name: docker_{{.Name}} + {{ if glob .Image "*elastic*" -}} url: http://{{.Address}} - - selector: "opensearch" - template: | - module: elasticsearch - name: docker_{{.Name}} + {{ else -}} url: https://{{.Address}} tls_skip_verify: yes username: admin password: admin + {{ end -}} - selector: "lighttpd" template: | module: lighttpd