From b466b62bb5d9b740b2dbfe72b75e8bb377bf24f9 Mon Sep 17 00:00:00 2001 From: Michael Russell Date: Fri, 9 Aug 2019 12:23:23 +0200 Subject: [PATCH] [metricbeat] Fix default configuration for kubernetes module This configuration didn't work at all since the nodes localhost is not reachable from the kubernetes pod. The test has also been fixed up to make sure that the data coming in actually has proper fields in it. The test was passing because the events were coming in but just with errors. --- metricbeat/examples/default/test/goss-metrics.yaml | 3 ++- metricbeat/examples/default/test/goss.yaml | 2 +- metricbeat/examples/security/values.yaml | 3 ++- metricbeat/templates/daemonset.yaml | 4 ++++ metricbeat/values.yaml | 3 ++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/metricbeat/examples/default/test/goss-metrics.yaml b/metricbeat/examples/default/test/goss-metrics.yaml index 4cafce058..0e30826b1 100644 --- a/metricbeat/examples/default/test/goss-metrics.yaml +++ b/metricbeat/examples/default/test/goss-metrics.yaml @@ -22,7 +22,8 @@ http: timeout: 2000 body: - 'metricbeat-7.3.0' - http://elasticsearch-master:9200/_search?q=metricset.name:state_deployment: + + 'http://elasticsearch-master:9200/_search?q=metricset.name:state_container%20AND%20kubernetes.container.name:metricbeat': status: 200 timeout: 2000 body: diff --git a/metricbeat/examples/default/test/goss.yaml b/metricbeat/examples/default/test/goss.yaml index 5184c44f9..2306ee7d9 100644 --- a/metricbeat/examples/default/test/goss.yaml +++ b/metricbeat/examples/default/test/goss.yaml @@ -30,7 +30,7 @@ http: timeout: 2000 body: - 'metricbeat-7.3.0' - http://elasticsearch-master:9200/_search?q=metricset.name:container: + 'http://elasticsearch-master:9200/_search?q=metricset.name:container%20AND%20kubernetes.container.name:metricbeat': status: 200 timeout: 2000 body: diff --git a/metricbeat/examples/security/values.yaml b/metricbeat/examples/security/values.yaml index 5d3f92501..dfe90a10a 100644 --- a/metricbeat/examples/security/values.yaml +++ b/metricbeat/examples/security/values.yaml @@ -11,7 +11,8 @@ metricbeatConfig: - system - volume period: 10s - hosts: ["localhost:10255"] + host: "${NODE_NAME}" + hosts: ["${NODE_NAME}:10255"] processors: - add_kubernetes_metadata: in_cluster: true diff --git a/metricbeat/templates/daemonset.yaml b/metricbeat/templates/daemonset.yaml index 272c1fb01..a86850e50 100644 --- a/metricbeat/templates/daemonset.yaml +++ b/metricbeat/templates/daemonset.yaml @@ -105,6 +105,10 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName {{- if .Values.extraEnvs }} {{ toYaml .Values.extraEnvs | indent 8 }} {{- end }} diff --git a/metricbeat/values.yaml b/metricbeat/values.yaml index 7023436b3..c088a8793 100755 --- a/metricbeat/values.yaml +++ b/metricbeat/values.yaml @@ -14,7 +14,8 @@ metricbeatConfig: - system - volume period: 10s - hosts: ["localhost:10255"] + host: "${NODE_NAME}" + hosts: ["${NODE_NAME}:10255"] processors: - add_kubernetes_metadata: in_cluster: true