diff --git a/charts/netdata/README.md b/charts/netdata/README.md
index 1554e90f..2acdb967 100644
--- a/charts/netdata/README.md
+++ b/charts/netdata/README.md
@@ -598,33 +598,6 @@ false
Description |
-
- | sd.image.repository |
- string |
-
-"netdata/agent-sd"
-
- |
- Container image repository |
-
-
- | sd.image.tag |
- string |
-
-"v0.2.10"
-
- |
- Container image tag |
-
-
- | sd.image.pullPolicy |
- string |
-
-"Always"
-
- |
- Container image pull policy |
-
| sd.child.enabled |
bool |
@@ -632,7 +605,7 @@ false
true
- Add service-discovery sidecar container to the netdata child pod definition |
+ Enable Kubernetes service discovery on each Netdata child |
| sd.child.configmap.name |
@@ -670,15 +643,6 @@ true
Value to use for child service-discovery configuration generation |
-
- | sd.child.resources |
- object |
-
-See values.yaml for defaults
-
- |
- Child service-discovery container CPU/Memory resource requests/limits |
-
Parent
@@ -2443,9 +2407,9 @@ pointing at the `netdata-otel` service.
### Service discovery and supported services
-Netdata's [service discovery](https://github.com/netdata/agent-service-discovery/), which is installed as part of the
-Helm chart installation, finds what services are running on a cluster's pods, converts that into configuration files,
-and exports them, so they can be monitored.
+Each Netdata child watches pods on its own node and creates collector jobs for matching containers.
+The chart mounts the discovery rules at `/etc/netdata/go.d/sd/k8s.conf`. The bundled rules require
+Netdata Agent v2.12.3 or later. [Kubernetes discovery documentation](https://github.com/netdata/netdata/blob/master/src/go/plugin/go.d/discovery/sdext/discoverer/k8ssd/README.md).
#### Applications
@@ -2478,42 +2442,27 @@ Service discovery currently supports the following applications via their associ
Service discovery supports Prometheus endpoints via
the [Prometheus](https://github.com/netdata/netdata/blob/master/src/go/plugin/go.d/collector/prometheus/README.md) collector.
-Annotations on pods allow a fine control of the scraping process:
+The generic Prometheus rule reads the following pod annotations.
-- `prometheus.io/scrape`: The default configuration will scrape all pods and, if set to false, this annotation excludes
- the pod from the scraping process.
-- `prometheus.io/path`: If the metrics path is not _/metrics_, define it with this annotation.
-- `prometheus.io/port`: Scrape the pod on the indicated port instead of the pod's declared ports.
+- `prometheus.io/scrape` opts a pod into scraping when set to `"true"`.
+- `prometheus.io/path` sets the metrics path. It defaults to `/metrics`.
+- `prometheus.io/port` selects a matching declared container port. Omit it to use each discovered port.
#### Configure service discovery
-If your cluster runs services on non-default ports or uses non-default names, you may need to configure service
-discovery to start collecting metrics from your services. You have to edit
-the [default ConfigMap](https://github.com/netdata/helmchart/blob/master/charts/netdata/sdconfig/child.yml) that is shipped with the
-Helmchart and deploy that to your cluster.
-
-First, copy `netdata-helmchart/charts/netdata/sdconfig/child.yml` to a new location outside the `netdata-helmchart` directory. The
-destination can be anywhere you like, but the following examples assume it resides next to the `netdata-helmchart`
-directory.
+To change an image match, port, or collector setting, copy the bundled rules from your chart checkout.
+[Default discovery rules](https://github.com/netdata/helmchart/blob/master/charts/netdata/sdconfig/k8s.yml).
```bash
-cp netdata-helmchart/charts/netdata/sdconfig/child.yml .
+cp netdata-helmchart/charts/netdata/sdconfig/k8s.yml .
```
-Edit the new `child.yml` file according to your needs. See
-the [Helm chart configuration](https://github.com/netdata/helmchart#configuration) and the file itself for details. You
-can then run
-`helm install`/`helm upgrade` with the `--set-file` argument to use your configured `child.yml` file instead of the
-default, changing the path if you copied it elsewhere.
+Edit `k8s.yml`, then pass it to Helm when installing or upgrading the release.
```bash
-helm install --set-file sd.child.configmap.from.value=./child.yml netdata ./netdata-helmchart/charts/netdata
-helm upgrade --set-file sd.child.configmap.from.value=./child.yml netdata ./netdata-helmchart/charts/netdata
+helm upgrade --install netdata ./netdata-helmchart/charts/netdata --set-file sd.child.configmap.from.value=./k8s.yml
```
-Now that you pushed an edited ConfigMap to your cluster, service discovery should find and set up metrics collection
-from your non-default service.
-
### Custom pod labels and annotations
Occasionally, you will want to add
diff --git a/charts/netdata/sdconfig/child.yml b/charts/netdata/sdconfig/child.yml
deleted file mode 100644
index 0a38dc0f..00000000
--- a/charts/netdata/sdconfig/child.yml
+++ /dev/null
@@ -1,243 +0,0 @@
-name: kubernetes
-discovery:
- k8s:
- - tags: unknown
- role: pod
- local_mode: true
-tag:
- - name: "Control-Plane"
- selector: unknown
- tags: -unknown control_plane
- match:
- - tags: kube_scheduler
- expr: '{{ glob .Image "k8s.gcr.io/kube-scheduler:*" }}'
- - tags: kube_controller_manager
- expr: '{{ glob .Image "k8s.gcr.io/kube-controller-manager:*" }}'
- - name: "Applications"
- selector: unknown
- tags: -unknown applications
- match:
- - tags: activemq
- expr: '{{ and (eq .Port "8161") (glob .Image "**/activemq*") }}'
- - tags: apache
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "httpd*" "**/httpd*") }}'
- - tags: bind
- expr: '{{ and (eq .Port "8653") (glob .Image "**/bind*") }}'
- - tags: cockroachdb
- expr: '{{ and (eq .Port "8080") (glob .Image "**/cockroach*") }}'
- - tags: consul
- expr: '{{ and (eq .Port "8500") (glob .Image "consul*" "**/consul*") }}'
- - tags: coredns
- expr: '{{ and (eq .Port "9153") (glob .Image "**/coredns*") }}'
- - tags: elasticsearch
- expr: '{{ and (eq .Port "9200") (glob .Image "elasticsearch:*" "**/elasticsearch:*") }}'
- - tags: fluentd
- expr: '{{ and (eq .Port "24220") (glob .Image "fluentd*" "**/fluentd*") }}'
- - tags: freeradius
- expr: '{{ and (eq .Port "18121") (glob .Image "**/freeradius*") }}'
- - tags: hdfs
- expr: '{{ and (eq .Port "50070") (glob .Image "**/hdfs*") }}'
- - tags: lighttpd
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "**/lighttpd*") }}'
- - tags: logstash
- expr: '{{ and (eq .Port "9600") (glob .Image "logstash*" "**/logstash*") }}'
- - tags: mysql
- expr: '{{ and (eq .Port "3306") (glob .Image "mysql*" "**/mysql*" "mariadb*" "**/mariadb*") }}'
- - tags: nginx
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "nginx*" "**/nginx*") }}'
- - tags: openvpn
- expr: '{{ and (eq .Port "7505") (glob .Image "**/openvpn") }}'
- - tags: phpfpm
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "**/phpfpm*" "**/php-fpm*") }}'
- - tags: rabbitmq
- expr: '{{ and (eq .Port "15672") (glob .Image "rabbitmq*" "**/rabbitmq*") }}'
- - tags: solr
- expr: '{{ and (eq .Port "8983") (glob .Image "solr*" "**/solr*") }}'
- - tags: tengine
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "**/tengine*") }}'
- - tags: unbound
- expr: '{{ and (eq .Port "8953") (glob .Image "**/unbound*") }}'
- - tags: vernemq
- expr: '{{ and (eq .Port "8888") (glob .Image "**/vernemq*") }}'
- - tags: zookeeper
- expr: '{{ and (eq .Port "2181") (glob .Image "zookeeper*" "**/zookeeper*") }}'
- - tags: consul_envoy
- expr: |
- {{ $imageOK := glob .Image "*/consul-dataplane*" -}}
- {{ $scrapeOK := eq (get .Annotations "prometheus.io/scrape") "true" -}}
- {{ $promPort := get .Annotations "prometheus.io/port" -}}
- {{ $portOK1 := and (eq .Port $promPort) (not (empty .Port)) -}}
- {{ $portOK2 := and (empty .Port) (not (empty $promPort)) -}}
- {{ and $imageOK $scrapeOK (or $portOK1 $portOK2) }}
- - name: "Prometheus Generic Applications"
- selector: unknown
- tags: -unknown prometheus_generic
- match:
- - tags: prometheus_generic
- expr: |
- {{ $scrapeOK := eq (get .Annotations "prometheus.io/scrape") "true" -}}
- {{ $portOK := eq (default .Port (get .Annotations "prometheus.io/port")) .Port -}}
- {{ $imageOK := not (glob .Image "netdata/netdata*" "**pulsar*" "**telegraf*") -}}
- {{ and $scrapeOK $portOK $imageOK }}
-build:
- - name: "Control-Plane"
- selector: '!unknown control_plane'
- tags: file
- apply:
- - selector: kube_scheduler
- template: |
- - module: prometheus
- name: prometheus-{{.TUID}}
- url: http://{{.PodIP}}:{{default "10251" .Port}}/metrics
- app: '{{.ContName}}'
- update_every: 10
- max_time_series: 1000
- - selector: kube_controller_manager
- template: |
- - module: prometheus
- name: prometheus-{{.TUID}}
- url: http://{{.PodIP}}:{{default "10252" .Port}}/metrics
- app: '{{.ContName}}'
- update_every: 10
- max_time_series: 2000
- - name: "Prometheus Generic Applications"
- selector: '!unknown prometheus_generic'
- tags: file
- apply:
- - selector: prometheus_generic
- template: |
- {{ $path := default "/metrics" (get .Annotations "prometheus.io/path") -}}
- - module: prometheus
- name: prometheus-{{.TUID}}
- url: http://{{.Address}}{{$path}}
- app: '{{.ContName}}'
- update_every: 10
- max_time_series: 4000
- - name: "Applications"
- selector: '!unknown applications'
- tags: file
- apply:
- - selector: activemq
- template: |
- - module: activemq
- name: activemq-{{.TUID}}
- url: http://{{.Address}}
- - selector: apache
- template: |
- - module: apache
- name: apache-{{.TUID}}
- url: http://{{.Address}}/server-status?auto
- - selector: bind
- template: |
- - module: bind
- name: bind-{{.TUID}}
- url: http://{{.Address}}/json/v1
- - selector: cockroachdb
- template: |
- - module: cockroachdb
- name: cockroachdb-{{.TUID}}
- url: http://{{.Address}}/_status/vars
- - selector: consul
- template: |
- - module: consul
- name: consul-{{.TUID}}
- url: http://{{.Address}}
- - selector: coredns
- template: |
- - module: coredns
- name: coredns-{{.TUID}}
- url: http://{{.Address}}/metrics
- - selector: elasticsearch
- template: |
- - module: elasticsearch
- name: elasticsearch-{{.TUID}}
- url: http://{{.Address}}
- - selector: consul_envoy
- template: |
- {{ $path := default "/metrics" (get .Annotations "prometheus.io/path") -}}
- {{ $promPort := get .Annotations "prometheus.io/port" -}}
- {{ $port := ternary .Port $promPort (not (empty .Port)) -}}
- - module: envoy
- name: {{.TUID}}
- url: http://{{ .PodIP }}:{{ $port }}{{ $path }}
- - selector: fluentd
- template: |
- - module: fluentd
- name: fluentd-{{.TUID}}
- url: http://{{.Address}}
- - selector: freeradius
- template: |
- - module: freeradius
- name: freeradius-{{.TUID}}
- address: {{.PodIP}}
- port: {{.Port}}
- - selector: hdfs
- template: |
- - module: hdfs
- name: hdfs-{{.TUID}}
- url: http://{{.Address}}/jmx
- - selector: lighttpd
- template: |
- - module: lighttpd
- name: lighttpd-{{.TUID}}
- url: http://{{.Address}}/server-status?auto
- - selector: logstash
- template: |
- - module: logstash
- name: logstash-{{.TUID}}
- url: http://{{.Address}}
- - selector: mysql
- template: |
- - module: mysql
- name: mysql-{{.TUID}}
- dsn: 'netdata@tcp({{.Address}})/'
- - selector: nginx
- template: |
- - module: nginx
- name: nginx-{{.TUID}}
- url: http://{{.Address}}/stub_status
- - selector: openvpn
- template: |
- - module: openvpn
- name: openvpn-{{.TUID}}
- address: {{.Address}}
- - selector: phpfpm
- template: |
- - module: phpfpm
- name: phpfpm-{{.TUID}}
- url: http://{{.Address}}/status?full&json
- - selector: rabbitmq
- template: |
- - module: rabbitmq
- name: rabbitmq-{{.TUID}}
- url: http://{{.Address}}
- - selector: solr
- template: |
- - module: solr
- name: solr-{{.TUID}}
- url: http://{{.Address}}
- - selector: tengine
- template: |
- - module: tengine
- name: tengine-{{.TUID}}
- url: http://{{.Address}}/us
- - selector: unbound
- template: |
- - module: unbound
- name: unbound-{{.TUID}}
- address: {{.Address}}
- use_tls: false
- - selector: vernemq
- template: |
- - module: vernemq
- name: vernemq-{{.TUID}}
- url: http://{{.Address}}/metrics
- - selector: zookeeper
- template: |
- - module: zookeeper
- name: zookeeper-{{.TUID}}
- address: {{.Address}}
-export:
- file:
- - selector: file
- filename: "/export/go.d.yml"
diff --git a/charts/netdata/sdconfig/k8s.yml b/charts/netdata/sdconfig/k8s.yml
index b2deabec..22854925 100644
--- a/charts/netdata/sdconfig/k8s.yml
+++ b/charts/netdata/sdconfig/k8s.yml
@@ -2,241 +2,175 @@ disabled: no
name: 'kubernetes'
-discover:
- - discoverer: k8s
- k8s:
- - tags: unknown
- role: pod
- pod:
- local_mode: yes
-classify:
- - name: "Control-Plane"
- selector: unknown
- tags: -unknown control_plane
- match:
- - tags: kube_scheduler
- expr: '{{ glob .Image "k8s.gcr.io/kube-scheduler:*" }}'
- - tags: kube_controller_manager
- expr: '{{ glob .Image "k8s.gcr.io/kube-controller-manager:*" }}'
- - name: "Applications"
- selector: unknown
- tags: -unknown applications
- match:
- - tags: activemq
- expr: '{{ and (eq .Port "8161") (glob .Image "*/activemq*") }}'
- - tags: apache
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "httpd*" "*/httpd*") }}'
- - tags: bind
- expr: '{{ and (eq .Port "8653") (glob .Image "*/bind*") }}'
- - tags: cockroachdb
- expr: '{{ and (eq .Port "8080") (glob .Image "*/cockroach*") }}'
- - tags: consul
- expr: '{{ and (eq .Port "8500") (glob .Image "consul*" "*/consul*") }}'
- - tags: coredns
- expr: '{{ and (eq .Port "9153") (glob .Image "*/coredns*") }}'
- - tags: elasticsearch
- expr: '{{ and (eq .Port "9200") (glob .Image "elasticsearch:*" "*/elasticsearch:*") }}'
- - tags: fluentd
- expr: '{{ and (eq .Port "24220") (glob .Image "fluentd*" "*/fluentd*") }}'
- - tags: freeradius
- expr: '{{ and (eq .Port "18121") (glob .Image "*/freeradius*") }}'
- - tags: hdfs
- expr: '{{ and (eq .Port "50070") (glob .Image "*/hdfs*") }}'
- - tags: lighttpd
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "*/lighttpd*") }}'
- - tags: logstash
- expr: '{{ and (eq .Port "9600") (glob .Image "logstash*" "*/logstash*") }}'
- - tags: mysql
- expr: '{{ and (eq .Port "3306") (glob .Image "mysql*" "*/mysql*" "mariadb*" "*/mariadb*") }}'
- - tags: nginx
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "nginx*" "*/nginx*") }}'
- - tags: openvpn
- expr: '{{ and (eq .Port "7505") (glob .Image "*/openvpn") }}'
- - tags: phpfpm
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "*/phpfpm*" "*/php-fpm*") }}'
- - tags: rabbitmq
- expr: '{{ and (eq .Port "15672") (glob .Image "rabbitmq*" "*/rabbitmq*") }}'
- - tags: solr
- expr: '{{ and (eq .Port "8983") (glob .Image "solr*" "*/solr*") }}'
- - tags: tengine
- expr: '{{ and (eq .Port "80" "8080") (glob .Image "*/tengine*") }}'
- - tags: unbound
- expr: '{{ and (eq .Port "8953") (glob .Image "*/unbound*") }}'
- - tags: vernemq
- expr: '{{ and (eq .Port "8888") (glob .Image "*/vernemq*") }}'
- - tags: zookeeper
- expr: '{{ and (eq .Port "2181") (glob .Image "zookeeper*" "*/zookeeper*") }}'
- - tags: consul_envoy
- expr: |
- {{ $imageOK := glob .Image "*/consul-dataplane*" -}}
- {{ $scrapeOK := eq (get .Annotations "prometheus.io/scrape") "true" -}}
- {{ $promPort := get .Annotations "prometheus.io/port" -}}
- {{ $portOK1 := and (eq .Port $promPort) (not (empty .Port)) -}}
- {{ $portOK2 := and (empty .Port) (not (empty $promPort)) -}}
- {{ and $imageOK $scrapeOK (or $portOK1 $portOK2) }}
- - name: "Prometheus Generic Applications"
- selector: unknown
- tags: -unknown prometheus_generic
- match:
- - tags: prometheus_generic
- expr: |
- {{ $scrapeOK := eq (get .Annotations "prometheus.io/scrape") "true" -}}
- {{ $portOK := eq (default .Port (get .Annotations "prometheus.io/port")) .Port -}}
- {{ $imageOK := not (glob .Image "netdata/netdata*" "*pulsar*" "*telegraf*") -}}
- {{ and $scrapeOK $portOK $imageOK }}
-compose:
- - name: "Control-Plane"
- selector: '!unknown control_plane'
- config:
- - selector: kube_scheduler
- template: |
- - module: prometheus
- name: prometheus-{{.TUID}}
- url: http://{{.PodIP}}:{{default "10251" .Port}}/metrics
- app: '{{.ContName}}'
- update_every: 10
- max_time_series: 1000
- - selector: kube_controller_manager
- template: |
- - module: prometheus
- name: prometheus-{{.TUID}}
- url: http://{{.PodIP}}:{{default "10252" .Port}}/metrics
- app: '{{.ContName}}'
- update_every: 10
- max_time_series: 2000
- - name: "Prometheus Generic Applications"
- selector: '!unknown prometheus_generic'
- config:
- - selector: prometheus_generic
- template: |
- {{ $path := default "/metrics" (get .Annotations "prometheus.io/path") -}}
- - module: prometheus
- name: prometheus-{{.TUID}}
- url: http://{{.Address}}{{$path}}
- app: '{{.ContName}}'
- update_every: 10
- max_time_series: 4000
- - name: "Applications"
- selector: '!unknown applications'
- tags: file
- config:
- - selector: activemq
- template: |
- - module: activemq
- name: activemq-{{.TUID}}
- url: http://{{.Address}}
- - selector: apache
- template: |
- - module: apache
- name: apache-{{.TUID}}
- url: http://{{.Address}}/server-status?auto
- - selector: bind
- template: |
- - module: bind
- name: bind-{{.TUID}}
- url: http://{{.Address}}/json/v1
- - selector: cockroachdb
- template: |
- - module: cockroachdb
- name: cockroachdb-{{.TUID}}
- url: http://{{.Address}}/_status/vars
- - selector: consul
- template: |
- - module: consul
- name: consul-{{.TUID}}
- url: http://{{.Address}}
- - selector: coredns
- template: |
- - module: coredns
- name: coredns-{{.TUID}}
- url: http://{{.Address}}/metrics
- - selector: elasticsearch
- template: |
- - module: elasticsearch
- name: elasticsearch-{{.TUID}}
- url: http://{{.Address}}
- - selector: consul_envoy
- template: |
- {{ $path := default "/metrics" (get .Annotations "prometheus.io/path") -}}
- {{ $promPort := get .Annotations "prometheus.io/port" -}}
- {{ $port := ternary .Port $promPort (not (empty .Port)) -}}
- - module: envoy
- name: {{.TUID}}
- url: http://{{ .PodIP }}:{{ $port }}{{ $path }}
- - selector: fluentd
- template: |
- - module: fluentd
- name: fluentd-{{.TUID}}
- url: http://{{.Address}}
- - selector: freeradius
- template: |
- - module: freeradius
- name: freeradius-{{.TUID}}
- address: {{.PodIP}}
- port: {{.Port}}
- - selector: hdfs
- template: |
- - module: hdfs
- name: hdfs-{{.TUID}}
- url: http://{{.Address}}/jmx
- - selector: lighttpd
- template: |
- - module: lighttpd
- name: lighttpd-{{.TUID}}
- url: http://{{.Address}}/server-status?auto
- - selector: logstash
- template: |
- - module: logstash
- name: logstash-{{.TUID}}
- url: http://{{.Address}}
- - selector: mysql
- template: |
- - module: mysql
- name: mysql-{{.TUID}}
- dsn: 'netdata@tcp({{.Address}})/'
- - selector: nginx
- template: |
- - module: nginx
- name: nginx-{{.TUID}}
- url: http://{{.Address}}/stub_status
- - selector: openvpn
- template: |
- - module: openvpn
- name: openvpn-{{.TUID}}
- address: {{.Address}}
- - selector: phpfpm
- template: |
- - module: phpfpm
- name: phpfpm-{{.TUID}}
- url: http://{{.Address}}/status?full&json
- - selector: rabbitmq
- template: |
- - module: rabbitmq
- name: rabbitmq-{{.TUID}}
- url: http://{{.Address}}
- - selector: solr
- template: |
- - module: solr
- name: solr-{{.TUID}}
- url: http://{{.Address}}
- - selector: tengine
- template: |
- - module: tengine
- name: tengine-{{.TUID}}
- url: http://{{.Address}}/us
- - selector: unbound
- template: |
- - module: unbound
- name: unbound-{{.TUID}}
- address: {{.Address}}
- use_tls: false
- - selector: vernemq
- template: |
- - module: vernemq
- name: vernemq-{{.TUID}}
- url: http://{{.Address}}/metrics
- - selector: zookeeper
- template: |
- - module: zookeeper
- name: zookeeper-{{.TUID}}
- address: {{.Address}}
+discoverer:
+ k8s:
+ - role: pod
+ pod:
+ local_mode: true
+
+services:
+ # The Prometheus rules keep max_time_series for Agent v2.12.3.
+ # Agent v2.13.0 uses the collector's default input and output limits.
+ - id: kube_scheduler
+ match: '{{ glob .Image "k8s.gcr.io/kube-scheduler:*" }}'
+ config_template: |
+ {{ job
+ "module" "prometheus"
+ "name" (printf "prometheus-%s" .TUID)
+ "url" (printf "http://%s:%s/metrics" .PodIP (default "10251" .Port))
+ "app" .ContName
+ "update_every" 10
+ "max_time_series" 1000
+ }}
+
+ - id: kube_controller_manager
+ match: '{{ glob .Image "k8s.gcr.io/kube-controller-manager:*" }}'
+ config_template: |
+ {{ job
+ "module" "prometheus"
+ "name" (printf "prometheus-%s" .TUID)
+ "url" (printf "http://%s:%s/metrics" .PodIP (default "10252" .Port))
+ "app" .ContName
+ "update_every" 10
+ "max_time_series" 2000
+ }}
+
+ - id: prometheus_generic
+ match: |
+ {{ $scrapeOK := eq (get .Annotations "prometheus.io/scrape") "true" -}}
+ {{ $portOK := eq (default .Port (get .Annotations "prometheus.io/port")) .Port -}}
+ {{ $imageOK := not (glob .Image "netdata/netdata*" "*pulsar*" "*telegraf*") -}}
+ {{ and $scrapeOK $portOK $imageOK }}
+ config_template: |
+ {{ $path := default "/metrics" (get .Annotations "prometheus.io/path") }}
+ {{ job
+ "module" "prometheus"
+ "name" (printf "prometheus-%s" .TUID)
+ "url" (printf "http://%s%s" .Address $path)
+ "app" .ContName
+ "update_every" 10
+ "max_time_series" 4000
+ }}
+
+ - id: activemq
+ match: '{{ and (eq .Port "8161") (glob .Image "*/activemq*") }}'
+ config_template: |
+ {{ job "name" (printf "activemq-%s" .TUID) "url" (printf "http://%s" .Address) }}
+
+ - id: apache
+ match: '{{ and (eq .Port "80" "8080") (glob .Image "httpd*" "*/httpd*") }}'
+ config_template: |
+ {{ job "name" (printf "apache-%s" .TUID) "url" (printf "http://%s/server-status?auto" .Address) }}
+
+ - id: bind
+ match: '{{ and (eq .Port "8653") (glob .Image "*/bind*") }}'
+ config_template: |
+ {{ job "name" (printf "bind-%s" .TUID) "url" (printf "http://%s/json/v1" .Address) }}
+
+ - id: cockroachdb
+ match: '{{ and (eq .Port "8080") (glob .Image "*/cockroach*") }}'
+ config_template: |
+ {{ job "name" (printf "cockroachdb-%s" .TUID) "url" (printf "http://%s/_status/vars" .Address) }}
+
+ - id: consul
+ match: '{{ and (eq .Port "8500") (glob .Image "consul*" "*/consul*") }}'
+ config_template: |
+ {{ job "name" (printf "consul-%s" .TUID) "url" (printf "http://%s" .Address) }}
+
+ - id: coredns
+ match: '{{ and (eq .Port "9153") (glob .Image "*/coredns*") }}'
+ config_template: |
+ {{ job "name" (printf "coredns-%s" .TUID) "url" (printf "http://%s/metrics" .Address) }}
+
+ - id: elasticsearch
+ match: '{{ and (eq .Port "9200") (glob .Image "elasticsearch:*" "*/elasticsearch:*") }}'
+ config_template: |
+ {{ job "name" (printf "elasticsearch-%s" .TUID) "url" (printf "http://%s" .Address) }}
+
+ - id: consul_envoy
+ match: |
+ {{ $imageOK := glob .Image "*/consul-dataplane*" -}}
+ {{ $scrapeOK := eq (get .Annotations "prometheus.io/scrape") "true" -}}
+ {{ $promPort := get .Annotations "prometheus.io/port" -}}
+ {{ $portOK1 := and (eq .Port $promPort) (not (empty .Port)) -}}
+ {{ $portOK2 := and (empty .Port) (not (empty $promPort)) -}}
+ {{ and $imageOK $scrapeOK (or $portOK1 $portOK2) }}
+ config_template: |
+ {{ $path := default "/metrics" (get .Annotations "prometheus.io/path") }}
+ {{ $port := default (get .Annotations "prometheus.io/port") .Port }}
+ {{ job "module" "envoy" "name" .TUID "url" (printf "http://%s:%s%s" .PodIP $port $path) }}
+
+ - id: fluentd
+ match: '{{ and (eq .Port "24220") (glob .Image "fluentd*" "*/fluentd*") }}'
+ config_template: |
+ {{ job "name" (printf "fluentd-%s" .TUID) "url" (printf "http://%s" .Address) }}
+
+ - id: freeradius
+ match: '{{ and (eq .Port "18121") (glob .Image "*/freeradius*") }}'
+ config_template: |
+ {{ job "name" (printf "freeradius-%s" .TUID) "address" .PodIP "port" (int .Port) }}
+
+ - id: hdfs
+ match: '{{ and (eq .Port "50070") (glob .Image "*/hdfs*") }}'
+ config_template: |
+ {{ job "name" (printf "hdfs-%s" .TUID) "url" (printf "http://%s/jmx" .Address) }}
+
+ - id: lighttpd
+ match: '{{ and (eq .Port "80" "8080") (glob .Image "*/lighttpd*") }}'
+ config_template: |
+ {{ job "name" (printf "lighttpd-%s" .TUID) "url" (printf "http://%s/server-status?auto" .Address) }}
+
+ - id: logstash
+ match: '{{ and (eq .Port "9600") (glob .Image "logstash*" "*/logstash*") }}'
+ config_template: |
+ {{ job "name" (printf "logstash-%s" .TUID) "url" (printf "http://%s" .Address) }}
+
+ - id: mysql
+ match: '{{ and (eq .Port "3306") (glob .Image "mysql*" "*/mysql*" "mariadb*" "*/mariadb*") }}'
+ config_template: |
+ {{ job "name" (printf "mysql-%s" .TUID) "dsn" (printf "netdata@tcp(%s)/" .Address) }}
+
+ - id: nginx
+ match: '{{ and (eq .Port "80" "8080") (glob .Image "nginx*" "*/nginx*") }}'
+ config_template: |
+ {{ job "name" (printf "nginx-%s" .TUID) "url" (printf "http://%s/stub_status" .Address) }}
+
+ - id: openvpn
+ match: '{{ and (eq .Port "7505") (glob .Image "*/openvpn") }}'
+ config_template: |
+ {{ job "name" (printf "openvpn-%s" .TUID) "address" .Address }}
+
+ - id: phpfpm
+ match: '{{ and (eq .Port "80" "8080") (glob .Image "*/phpfpm*" "*/php-fpm*") }}'
+ config_template: |
+ {{ job "name" (printf "phpfpm-%s" .TUID) "url" (printf "http://%s/status?full&json" .Address) }}
+
+ - id: rabbitmq
+ match: '{{ and (eq .Port "15672") (glob .Image "rabbitmq*" "*/rabbitmq*") }}'
+ config_template: |
+ {{ job "name" (printf "rabbitmq-%s" .TUID) "url" (printf "http://%s" .Address) }}
+
+ - id: solr
+ match: '{{ and (eq .Port "8983") (glob .Image "solr*" "*/solr*") }}'
+ config_template: |
+ {{ job "name" (printf "solr-%s" .TUID) "url" (printf "http://%s" .Address) }}
+
+ - id: tengine
+ match: '{{ and (eq .Port "80" "8080") (glob .Image "*/tengine*") }}'
+ config_template: |
+ {{ job "name" (printf "tengine-%s" .TUID) "url" (printf "http://%s/us" .Address) }}
+
+ - id: unbound
+ match: '{{ and (eq .Port "8953") (glob .Image "*/unbound*") }}'
+ config_template: |
+ {{ job "name" (printf "unbound-%s" .TUID) "address" .Address "use_tls" false }}
+
+ - id: vernemq
+ match: '{{ and (eq .Port "8888") (glob .Image "*/vernemq*") }}'
+ config_template: |
+ {{ job "name" (printf "vernemq-%s" .TUID) "url" (printf "http://%s/metrics" .Address) }}
+
+ - id: zookeeper
+ match: '{{ and (eq .Port "2181") (glob .Image "zookeeper*" "*/zookeeper*") }}'
+ config_template: |
+ {{ job "name" (printf "zookeeper-%s" .TUID) "address" .Address }}
diff --git a/charts/netdata/templates/_helpers.tpl b/charts/netdata/templates/_helpers.tpl
index 39d76b61..f5ff29b0 100644
--- a/charts/netdata/templates/_helpers.tpl
+++ b/charts/netdata/templates/_helpers.tpl
@@ -38,17 +38,6 @@ Return the target Kubernetes version
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
{{- end -}}
-{{/*
-The function determines if the Netdata version is less than 3.0-0.
-*/}}
-{{- define "netdata.verLess22" -}}
-{{- if semverCompare "<2.2-0" .Chart.AppVersion -}}
-{{- "true" -}}
-{{- else -}}
-{{- "" -}}
-{{- end -}}
-{{- end -}}
-
{{/*
Return the appropriate apiVersion for ingress.
*/}}
diff --git a/charts/netdata/templates/child/configmap.yaml b/charts/netdata/templates/child/configmap.yaml
index 63337c2a..8664979c 100644
--- a/charts/netdata/templates/child/configmap.yaml
+++ b/charts/netdata/templates/child/configmap.yaml
@@ -35,12 +35,7 @@ data:
{{- else if .value }}
{{- toYaml .value | nindent 4 }}
{{- else }}
- {{- if .file }}
- {{- $.Files.Get .file | nindent 4 }}
- {{- else }}
- {{- $configFile := ternary "sdconfig/child.yml" "sdconfig/k8s.yml" (eq (include "netdata.verLess22" $) "true") }}
- {{- $.Files.Get $configFile | nindent 4 }}
- {{- end }}
+ {{- $.Files.Get (default "sdconfig/k8s.yml" .file) | nindent 4 }}
{{- end}}
{{- end}}
{{- end }}
diff --git a/charts/netdata/templates/child/daemonset.yaml b/charts/netdata/templates/child/daemonset.yaml
index eabacb97..355ca8e2 100644
--- a/charts/netdata/templates/child/daemonset.yaml
+++ b/charts/netdata/templates/child/daemonset.yaml
@@ -112,12 +112,6 @@ spec:
fieldPath: metadata.namespace
- name: NETDATA_LISTENER_PORT
value: '{{ tpl (.Values.child.port | toString) . }}'
- {{- if .Values.sd.child.enabled }}
- {{- if include "netdata.verLess22" . }}
- - name: NETDATA_PLUGINS_GOD_WATCH_PATH
- value: "/etc/netdata/go.d/sd/go.d.yml"
- {{- end }}
- {{- end }}
{{- range $key, $value := .Values.child.env }}
- name: {{ $key }}
value: {{ $value | quote }}
@@ -178,15 +172,10 @@ spec:
mountPath: /var/lib/netdata
{{- end }}
{{- if .Values.sd.child.enabled }}
- {{- if include "netdata.verLess22" . }}
- - name: sd-shared
- mountPath: "/etc/netdata/go.d/sd/"
- {{- else }}
- name: sdconfigmap
mountPath: "/etc/netdata/go.d/sd/k8s.conf"
subPath: {{ .Values.sd.child.configmap.key }}
{{- end }}
- {{- end }}
{{- if .Values.child.extraVolumeMounts -}}
{{ toYaml .Values.child.extraVolumeMounts | nindent 12 }}
{{- end }}
@@ -197,29 +186,6 @@ spec:
- SYS_ADMIN
resources:
{{ toYaml .Values.child.resources | indent 12 }}
- {{- if .Values.sd.child.enabled }}
- {{- if include "netdata.verLess22" . }}
- - name: sd
- image: "{{ .Values.sd.image.repository }}:{{ .Values.sd.image.tag }}"
- imagePullPolicy: {{ .Values.sd.image.pullPolicy }}
- volumeMounts:
- - name: sd-shared
- mountPath: "/export/"
- resources:
- {{- toYaml .Values.sd.child.resources | nindent 12 }}
- env:
- - name: NETDATA_SD_CONFIG_MAP
- value: "{{ .Values.sd.child.configmap.name }}:{{ .Values.sd.child.configmap.key }}"
- - name: MY_POD_NAMESPACE
- valueFrom:
- fieldRef:
- fieldPath: metadata.namespace
- - name: MY_NODE_NAME
- valueFrom:
- fieldRef:
- fieldPath: spec.nodeName
- {{- end }}
- {{- end }}
{{- with .Values.child.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
@@ -263,16 +229,11 @@ spec:
{{- end }}
{{- end }}
{{- if .Values.sd.child.enabled }}
- {{- if include "netdata.verLess22" . }}
- - name: sd-shared
- emptyDir: { }
- {{- else }}
- name: sdconfigmap
configMap:
name: {{ .Values.sd.child.configmap.name }}
optional: true
{{- end }}
- {{- end }}
{{- if .Values.child.extraVolumes }}
{{ toYaml .Values.child.extraVolumes | indent 8}}
{{- end }}
diff --git a/charts/netdata/values.yaml b/charts/netdata/values.yaml
index dadabdc5..56a630bc 100644
--- a/charts/netdata/values.yaml
+++ b/charts/netdata/values.yaml
@@ -22,18 +22,8 @@ image:
pullPolicy: Always
sd:
- image:
- # -- Container image repository
- # @section -- Service Discovery
- repository: netdata/agent-sd
- # -- Container image tag
- # @section -- Service Discovery
- tag: v0.2.10
- # -- Container image pull policy
- # @section -- Service Discovery
- pullPolicy: Always
child:
- # -- Add service-discovery sidecar container to the netdata child pod definition
+ # -- Enable Kubernetes service discovery on each Netdata child
# @section -- Service Discovery
enabled: true
configmap:
@@ -51,16 +41,6 @@ sd:
# -- Value to use for child service-discovery configuration generation
# @section -- Service Discovery
value: {}
- # -- Child service-discovery container CPU/Memory resource requests/limits
- # @default -- See values.yaml for defaults
- # @section -- Service Discovery
- resources:
- limits:
- cpu: 50m
- memory: 150Mi
- requests:
- cpu: 50m
- memory: 100Mi
initContainersImage:
# -- Init containers' image repository
diff --git a/templates/netdata-README.md.gotmpl b/templates/netdata-README.md.gotmpl
index ce691e92..d7f90c3f 100644
--- a/templates/netdata-README.md.gotmpl
+++ b/templates/netdata-README.md.gotmpl
@@ -342,9 +342,9 @@ pointing at the `netdata-otel` service.
### Service discovery and supported services
-Netdata's [service discovery](https://github.com/netdata/agent-service-discovery/), which is installed as part of the
-Helm chart installation, finds what services are running on a cluster's pods, converts that into configuration files,
-and exports them, so they can be monitored.
+Each Netdata child watches pods on its own node and creates collector jobs for matching containers.
+The chart mounts the discovery rules at `/etc/netdata/go.d/sd/k8s.conf`. The bundled rules require
+Netdata Agent v2.12.3 or later. [Kubernetes discovery documentation](https://github.com/netdata/netdata/blob/master/src/go/plugin/go.d/discovery/sdext/discoverer/k8ssd/README.md).
#### Applications
@@ -377,42 +377,27 @@ Service discovery currently supports the following applications via their associ
Service discovery supports Prometheus endpoints via
the [Prometheus](https://github.com/netdata/netdata/blob/master/src/go/plugin/go.d/collector/prometheus/README.md) collector.
-Annotations on pods allow a fine control of the scraping process:
+The generic Prometheus rule reads the following pod annotations.
-- `prometheus.io/scrape`: The default configuration will scrape all pods and, if set to false, this annotation excludes
- the pod from the scraping process.
-- `prometheus.io/path`: If the metrics path is not _/metrics_, define it with this annotation.
-- `prometheus.io/port`: Scrape the pod on the indicated port instead of the pod's declared ports.
+- `prometheus.io/scrape` opts a pod into scraping when set to `"true"`.
+- `prometheus.io/path` sets the metrics path. It defaults to `/metrics`.
+- `prometheus.io/port` selects a matching declared container port. Omit it to use each discovered port.
#### Configure service discovery
-If your cluster runs services on non-default ports or uses non-default names, you may need to configure service
-discovery to start collecting metrics from your services. You have to edit
-the [default ConfigMap](https://github.com/netdata/helmchart/blob/master/charts/netdata/sdconfig/child.yml) that is shipped with the
-Helmchart and deploy that to your cluster.
-
-First, copy `netdata-helmchart/charts/netdata/sdconfig/child.yml` to a new location outside the `netdata-helmchart` directory. The
-destination can be anywhere you like, but the following examples assume it resides next to the `netdata-helmchart`
-directory.
+To change an image match, port, or collector setting, copy the bundled rules from your chart checkout.
+[Default discovery rules](https://github.com/netdata/helmchart/blob/master/charts/netdata/sdconfig/k8s.yml).
```bash
-cp netdata-helmchart/charts/netdata/sdconfig/child.yml .
+cp netdata-helmchart/charts/netdata/sdconfig/k8s.yml .
```
-Edit the new `child.yml` file according to your needs. See
-the [Helm chart configuration](https://github.com/netdata/helmchart#configuration) and the file itself for details. You
-can then run
-`helm install`/`helm upgrade` with the `--set-file` argument to use your configured `child.yml` file instead of the
-default, changing the path if you copied it elsewhere.
+Edit `k8s.yml`, then pass it to Helm when installing or upgrading the release.
```bash
-helm install --set-file sd.child.configmap.from.value=./child.yml netdata ./netdata-helmchart/charts/netdata
-helm upgrade --set-file sd.child.configmap.from.value=./child.yml netdata ./netdata-helmchart/charts/netdata
+helm upgrade --install netdata ./netdata-helmchart/charts/netdata --set-file sd.child.configmap.from.value=./k8s.yml
```
-Now that you pushed an edited ConfigMap to your cluster, service discovery should find and set up metrics collection
-from your non-default service.
-
### Custom pod labels and annotations
Occasionally, you will want to add