From 7def3333fc6d8b4503a14259ac845bb72c2e0fa5 Mon Sep 17 00:00:00 2001 From: Pablo Mercado Date: Thu, 6 Feb 2020 19:39:54 +0100 Subject: [PATCH 1/3] add ksm storage class support --- metricbeat/docs/fields.asciidoc | 52 +++++++++++ metricbeat/docs/modules/kubernetes.asciidoc | 4 + .../kubernetes/state_storageclass.asciidoc | 17 ++++ metricbeat/docs/modules_list.asciidoc | 3 +- metricbeat/include/list_docker.go | 1 + metricbeat/module/kubernetes/fields.go | 2 +- .../state_storageclass/_meta/docs.asciidoc | 2 + .../state_storageclass/_meta/fields.yml | 21 +++++ .../_meta/test/ksm.unit.v1.8.0 | 11 +++ .../_meta/test/ksm.unit.v1.8.0.expected | 27 ++++++ .../_meta/test/ksm.v1.8.0.expected | 27 ++++++ .../state_storageclass/state_storageclass.go | 89 +++++++++++++++++++ .../state_storageclass_test.go | 41 +++++++++ 13 files changed, 295 insertions(+), 2 deletions(-) create mode 100644 metricbeat/docs/modules/kubernetes/state_storageclass.asciidoc create mode 100644 metricbeat/module/kubernetes/state_storageclass/_meta/docs.asciidoc create mode 100644 metricbeat/module/kubernetes/state_storageclass/_meta/fields.yml create mode 100644 metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.unit.v1.8.0 create mode 100644 metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.unit.v1.8.0.expected create mode 100644 metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.v1.8.0.expected create mode 100644 metricbeat/module/kubernetes/state_storageclass/state_storageclass.go create mode 100644 metricbeat/module/kubernetes/state_storageclass/state_storageclass_test.go diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 3961c8901a1..103a563e2a9 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -22495,6 +22495,58 @@ type: long -- +[float] +=== storageclass + +kubernetes storage class metrics + + + +*`kubernetes.storageclass.name`*:: ++ +-- +Storage class name. + +type: keyword + +-- + +*`kubernetes.storageclass.provisioner`*:: ++ +-- +Volume provisioner for the storage class. + +type: keyword + +-- + +*`kubernetes.storageclass.reclaim_policy`*:: ++ +-- +Reclaim policy for dynamically created volumes + +type: keyword + +-- + +*`kubernetes.storageclass.volume_binding_mode`*:: ++ +-- +Mode for default provisioning and binding + +type: keyword + +-- + +*`kubernetes.storageclass.created`*:: ++ +-- +Storage class creation date + +type: date + +-- + [float] === system diff --git a/metricbeat/docs/modules/kubernetes.asciidoc b/metricbeat/docs/modules/kubernetes.asciidoc index 5d322520b0c..0b19f15e03e 100644 --- a/metricbeat/docs/modules/kubernetes.asciidoc +++ b/metricbeat/docs/modules/kubernetes.asciidoc @@ -196,6 +196,8 @@ The following metricsets are available: * <> +* <> + * <> * <> @@ -236,6 +238,8 @@ include::kubernetes/state_service.asciidoc[] include::kubernetes/state_statefulset.asciidoc[] +include::kubernetes/state_storageclass.asciidoc[] + include::kubernetes/system.asciidoc[] include::kubernetes/volume.asciidoc[] diff --git a/metricbeat/docs/modules/kubernetes/state_storageclass.asciidoc b/metricbeat/docs/modules/kubernetes/state_storageclass.asciidoc new file mode 100644 index 00000000000..c375fa3e807 --- /dev/null +++ b/metricbeat/docs/modules/kubernetes/state_storageclass.asciidoc @@ -0,0 +1,17 @@ +//// +This file is generated! See scripts/mage/docs_collector.go +//// + +[[metricbeat-metricset-kubernetes-state_storageclass]] +=== Kubernetes state_storageclass metricset + +experimental[] + +include::../../../module/kubernetes/state_storageclass/_meta/docs.asciidoc[] + + +==== Fields + +For a description of each field in the metricset, see the +<> section. + diff --git a/metricbeat/docs/modules_list.asciidoc b/metricbeat/docs/modules_list.asciidoc index 010c9c40b9f..903e39307c2 100644 --- a/metricbeat/docs/modules_list.asciidoc +++ b/metricbeat/docs/modules_list.asciidoc @@ -121,7 +121,7 @@ This file is generated! See scripts/mage/docs_collector.go .2+| .2+| |<> |<> |<> |image:./images/icon-yes.png[Prebuilt dashboards are available] | -.20+| .20+| |<> +.21+| .21+| |<> |<> |<> |<> @@ -139,6 +139,7 @@ This file is generated! See scripts/mage/docs_collector.go |<> |<> experimental[] |<> +|<> experimental[] |<> |<> |<> beta[] |image:./images/icon-no.png[No prebuilt dashboards] | diff --git a/metricbeat/include/list_docker.go b/metricbeat/include/list_docker.go index b1cc337aa80..f0015d31b3b 100644 --- a/metricbeat/include/list_docker.go +++ b/metricbeat/include/list_docker.go @@ -51,6 +51,7 @@ import ( _ "github.com/elastic/beats/metricbeat/module/kubernetes/state_resourcequota" _ "github.com/elastic/beats/metricbeat/module/kubernetes/state_service" _ "github.com/elastic/beats/metricbeat/module/kubernetes/state_statefulset" + _ "github.com/elastic/beats/metricbeat/module/kubernetes/state_storageclass" _ "github.com/elastic/beats/metricbeat/module/kubernetes/system" _ "github.com/elastic/beats/metricbeat/module/kubernetes/volume" ) diff --git a/metricbeat/module/kubernetes/fields.go b/metricbeat/module/kubernetes/fields.go index 7e772a7534b..49a0893d0ad 100644 --- a/metricbeat/module/kubernetes/fields.go +++ b/metricbeat/module/kubernetes/fields.go @@ -32,5 +32,5 @@ func init() { // AssetKubernetes returns asset data. // This is the base64 encoded gzipped contents of ../metricbeat/module/kubernetes. func AssetKubernetes() string { - return "eJzsXU9z27iSv+dToHLKbHl02NraQw5bNeN5r54rmTyv7cwctrY0MNmSMCYBDgDa0fv0rwD+g0gABEVIdmzykIolsfuH7gbQ3QAaP6IH2H9ED+U9cAoSxDuEJJEZfETvP7Ufvn+HUAoi4aSQhNGP6H/eIYRQ9wOUg+QkUW9zyAAL+Ii2+B1CAqQkdCs+ov97L0T2/gK930lZvP9/9d2OcblOGN2Q7Ue0wZmAdwhtCGSp+KgZ/IgozqEHTz1yXygOnJVF/YkFnnqu6IbxHKuPEaYpEhJLIiRJBGIbVLBUoBxTvIUU3e8NPquagonGRIQLIoA/Am+/sYHyAOvJ76frK1QRNETZPIcibZ4+NBMeh79KEHKVZASoPPhJg/MB9k+Mp73vPGjVc6npI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H2qsf6jB/uHYPywDP2F8mpwWZWV+uCgyAgJJNgxU/f90B7ZqOSBJrIyLoeabKBcOUe8NIk9CJSuFBH6aO35DJXCKM3Rz29i9EYKdG3ytvjArLK4HVRNDv3y6d8+DhqVjhKcwdAQYGcPpeoMzTBO3RAP4fWQ4RT8bOo1VOZjOmef1wAY0mrCQ7rgKxk8fy01FwYW+ZqDiNqdNjBlhxeEfNhK9fce+4o807a+l1LycbvnCCUuPxBK2ZRYvEKgpRosEfEIbyyQNHZ3P+44Im2fz0TtQG3q1b96bEfS9xQuEJkfCa3yuk6KTM/uznRYhtTt75CO6hIi+QZgyKLLwAazBtQ77ufXcCQ06zs7zUnej5A7Y56HmWrkBwHp5137add6q183CPiPX6wiX2wErOHskgjA6iDwnHzi1lFpvrIvCdXqgj3PWlrrVSV67pmKqX6t79geKc5JgFc2arcScZdiPv8yJyYbolOSsA4BfWVoVJqbV47KtbAjdIUxTZLjEdxaO1G53GZrZoF9CijUPqmeVOq3io7gAlst0kzRheRalKX93l31f+JWlV/HoS8L4+V9wG3QrG7IZeXss8LogMrK+ZhyMwCmmjlvdPYzP4/WbM5VHLW+gdPe2F/5uwfIc/vFneQ4/DM/4Mw5RS9GO689mOSRzXPKhVDr1ZlZuy/vk5hM4/5b3yacKaHmfvP28yvfJvwS+Sn6BR8D/7nj6uw/lEg+kV06eAfPvAAAA//8C3+pF" } diff --git a/metricbeat/module/kubernetes/state_storageclass/_meta/docs.asciidoc b/metricbeat/module/kubernetes/state_storageclass/_meta/docs.asciidoc new file mode 100644 index 00000000000..5ad3f81cfdb --- /dev/null +++ b/metricbeat/module/kubernetes/state_storageclass/_meta/docs.asciidoc @@ -0,0 +1,2 @@ +The `state_storageclass` metricset for kubernetes storage class related metrics from `kube-state-metrics`. + diff --git a/metricbeat/module/kubernetes/state_storageclass/_meta/fields.yml b/metricbeat/module/kubernetes/state_storageclass/_meta/fields.yml new file mode 100644 index 00000000000..2f3adac5747 --- /dev/null +++ b/metricbeat/module/kubernetes/state_storageclass/_meta/fields.yml @@ -0,0 +1,21 @@ +- name: storageclass + type: group + description: > + kubernetes storage class metrics + release: experimental + fields: + - name: name + type: keyword + description: Storage class name. + - name: provisioner + type: keyword + description: Volume provisioner for the storage class. + - name: reclaim_policy + type: keyword + description: Reclaim policy for dynamically created volumes + - name: volume_binding_mode + type: keyword + description: Mode for default provisioning and binding + - name: created + type: date + description: Storage class creation date diff --git a/metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.unit.v1.8.0 b/metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.unit.v1.8.0 new file mode 100644 index 00000000000..0a7712e74b7 --- /dev/null +++ b/metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.unit.v1.8.0 @@ -0,0 +1,11 @@ +# HELP kube_storageclass_info Information about storageclass. +# TYPE kube_storageclass_info gauge +kube_storageclass_info{storageclass="test_storageclass",provisioner="kubernetes.io/rbd",reclaimPolicy="Delete",volumeBindingMode="Immediate"} 1 +# HELP kube_storageclass_created Unix creation timestamp +# TYPE kube_storageclass_created gauge +kube_storageclass_created{storageclass="test_storageclass"} 1.501569018e+09 +# HELP kube_storageclass_labels Kubernetes labels converted to Prometheus labels. +# TYPE kube_storageclass_labels gauge +kube_storageclass_labels{storageclass="test_storageclass",label_foo="bar"} 1 + + diff --git a/metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.unit.v1.8.0.expected b/metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.unit.v1.8.0.expected new file mode 100644 index 00000000000..cd0595a14f4 --- /dev/null +++ b/metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.unit.v1.8.0.expected @@ -0,0 +1,27 @@ +[ + { + "RootFields": {}, + "ModuleFields": { + "labels": { + "foo": "bar" + } + }, + "MetricSetFields": { + "created": "2017-08-01T06:30:18.000Z", + "name": "test_storageclass", + "provisioner": "kubernetes.io/rbd", + "reclaim_policy": "Delete", + "volume_binding_mode": "Immediate" + }, + "Index": "", + "ID": "", + "Namespace": "kubernetes.storageclass", + "Timestamp": "0001-01-01T00:00:00Z", + "Error": null, + "Host": "", + "Service": "", + "Took": 0, + "Period": 0, + "DisableTimeSeries": false + } +] \ No newline at end of file diff --git a/metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.v1.8.0.expected b/metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.v1.8.0.expected new file mode 100644 index 00000000000..346cc2cf104 --- /dev/null +++ b/metricbeat/module/kubernetes/state_storageclass/_meta/test/ksm.v1.8.0.expected @@ -0,0 +1,27 @@ +[ + { + "RootFields": {}, + "ModuleFields": { + "labels": { + "addonmanager_kubernetes_io_mode": "EnsureExists" + } + }, + "MetricSetFields": { + "created": "2020-01-07T16:11:11.000Z", + "name": "standard", + "provisioner": "k8s.io/minikube-hostpath", + "reclaim_policy": "Delete", + "volume_binding_mode": "Immediate" + }, + "Index": "", + "ID": "", + "Namespace": "kubernetes.storageclass", + "Timestamp": "0001-01-01T00:00:00Z", + "Error": null, + "Host": "", + "Service": "", + "Took": 0, + "Period": 0, + "DisableTimeSeries": false + } +] \ No newline at end of file diff --git a/metricbeat/module/kubernetes/state_storageclass/state_storageclass.go b/metricbeat/module/kubernetes/state_storageclass/state_storageclass.go new file mode 100644 index 00000000000..356485d49a1 --- /dev/null +++ b/metricbeat/module/kubernetes/state_storageclass/state_storageclass.go @@ -0,0 +1,89 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package state_storageclass + +import ( + p "github.com/elastic/beats/metricbeat/helper/prometheus" + "github.com/elastic/beats/metricbeat/mb" +) + +func init() { + mb.Registry.MustAddMetricSet("kubernetes", "state_storageclass", + NewStorageClassMetricSet, + mb.WithHostParser(p.HostParser)) +} + +// StorageClassMetricSet is a prometheus based MetricSet that fetches +// and reports kube-state-metrics storage class metrics +type StorageClassMetricSet struct { + mb.BaseMetricSet + prometheus p.Prometheus + mapping *p.MetricsMapping +} + +// NewStorageClassMetricSet returns a prometheus based metricset for Storage classes +func NewStorageClassMetricSet(base mb.BaseMetricSet) (mb.MetricSet, error) { + prometheus, err := p.NewPrometheusClient(base) + if err != nil { + return nil, err + } + + return &StorageClassMetricSet{ + BaseMetricSet: base, + prometheus: prometheus, + mapping: &p.MetricsMapping{ + Metrics: map[string]p.MetricMap{ + "kube_storageclass_info": p.InfoMetric(), + "kube_storageclass_labels": p.ExtendedInfoMetric( + p.Configuration{ + StoreNonMappedLabels: true, + NonMappedLabelsPlacement: mb.ModuleDataKey + ".labels", + MetricProcessingOptions: []p.MetricOption{p.OpLabelKeyPrefixRemover("label_")}, + }), + "kube_storageclass_created": p.Metric("created", p.OpUnixTimestampValue()), + }, + Labels: map[string]p.LabelMap{ + "storageclass": p.KeyLabel("name"), + "provisioner": p.Label("provisioner"), + "reclaimPolicy": p.Label("reclaim_policy"), + "volumeBindingMode": p.Label("volume_binding_mode"), + }, + }, + }, nil +} + +// Fetch prometheus metrics and treats those prefixed by mb.ModuleDataKey as +// module rooted fields at the event that gets reported +func (m *StorageClassMetricSet) Fetch(reporter mb.ReporterV2) { + events, err := m.prometheus.GetProcessedMetrics(m.mapping) + if err != nil { + m.Logger().Error(err) + reporter.Error(err) + return + } + + for _, event := range events { + event[mb.NamespaceKey] = "storageclass" + reported := reporter.Event(mb.TransformMapStrToEvent("kubernetes", event, nil)) + if !reported { + m.Logger().Debug("error trying to emit event") + return + } + } + return +} diff --git a/metricbeat/module/kubernetes/state_storageclass/state_storageclass_test.go b/metricbeat/module/kubernetes/state_storageclass/state_storageclass_test.go new file mode 100644 index 00000000000..524121ce6fa --- /dev/null +++ b/metricbeat/module/kubernetes/state_storageclass/state_storageclass_test.go @@ -0,0 +1,41 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// +build !integration + +package state_storageclass + +import ( + "testing" + + "github.com/elastic/beats/metricbeat/helper/prometheus/ptest" +) + +func TestEventMapping(t *testing.T) { + ptest.TestMetricSet(t, "kubernetes", "state_storageclass", + ptest.TestCases{ + { + MetricsFile: "../_meta/test/ksm.v1.8.0", + ExpectedFile: "./_meta/test/ksm.v1.8.0.expected", + }, + { + MetricsFile: "./_meta/test/ksm.unit.v1.8.0", + ExpectedFile: "./_meta/test/ksm.unit.v1.8.0.expected", + }, + }, + ) +} From 7bcbc17c3aacd87f2ed422db92be44ea8062f9b9 Mon Sep 17 00:00:00 2001 From: Pablo Mercado Date: Fri, 7 Feb 2020 18:22:50 +0100 Subject: [PATCH 2/3] add readme, data.json and other assets --- metricbeat/docs/modules/kubernetes.asciidoc | 1 + .../kubernetes/state_storageclass.asciidoc | 6 +++ metricbeat/metricbeat.reference.yml | 1 + .../kubernetes/_meta/config.reference.yml | 1 + metricbeat/module/kubernetes/_meta/config.yml | 1 + .../kubernetes/state_storageclass/README.md | 47 +++++++++++++++++++ .../state_storageclass/_meta/data.json | 47 +++++++++++++++++++ metricbeat/modules.d/kubernetes.yml.disabled | 1 + x-pack/metricbeat/metricbeat.reference.yml | 1 + 9 files changed, 106 insertions(+) create mode 100644 metricbeat/module/kubernetes/state_storageclass/README.md create mode 100644 metricbeat/module/kubernetes/state_storageclass/_meta/data.json diff --git a/metricbeat/docs/modules/kubernetes.asciidoc b/metricbeat/docs/modules/kubernetes.asciidoc index 0b19f15e03e..c15a096c398 100644 --- a/metricbeat/docs/modules/kubernetes.asciidoc +++ b/metricbeat/docs/modules/kubernetes.asciidoc @@ -99,6 +99,7 @@ metricbeat.modules: - state_service - state_persistentvolume - state_persistentvolumeclaim + - state_storageclass period: 10s hosts: ["kube-state-metrics:8080"] diff --git a/metricbeat/docs/modules/kubernetes/state_storageclass.asciidoc b/metricbeat/docs/modules/kubernetes/state_storageclass.asciidoc index c375fa3e807..02aec973cd9 100644 --- a/metricbeat/docs/modules/kubernetes/state_storageclass.asciidoc +++ b/metricbeat/docs/modules/kubernetes/state_storageclass.asciidoc @@ -15,3 +15,9 @@ include::../../../module/kubernetes/state_storageclass/_meta/docs.asciidoc[] For a description of each field in the metricset, see the <> section. +Here is an example document generated by this metricset: + +[source,json] +---- +include::../../../module/kubernetes/state_storageclass/_meta/data.json[] +---- diff --git a/metricbeat/metricbeat.reference.yml b/metricbeat/metricbeat.reference.yml index 246a8d71bc3..390a5408e58 100644 --- a/metricbeat/metricbeat.reference.yml +++ b/metricbeat/metricbeat.reference.yml @@ -482,6 +482,7 @@ metricbeat.modules: - state_service - state_persistentvolume - state_persistentvolumeclaim + - state_storageclass period: 10s hosts: ["kube-state-metrics:8080"] diff --git a/metricbeat/module/kubernetes/_meta/config.reference.yml b/metricbeat/module/kubernetes/_meta/config.reference.yml index 6abf381e6da..10de0447725 100644 --- a/metricbeat/module/kubernetes/_meta/config.reference.yml +++ b/metricbeat/module/kubernetes/_meta/config.reference.yml @@ -39,6 +39,7 @@ - state_service - state_persistentvolume - state_persistentvolumeclaim + - state_storageclass period: 10s hosts: ["kube-state-metrics:8080"] diff --git a/metricbeat/module/kubernetes/_meta/config.yml b/metricbeat/module/kubernetes/_meta/config.yml index f242454913b..0325d0891e1 100644 --- a/metricbeat/module/kubernetes/_meta/config.yml +++ b/metricbeat/module/kubernetes/_meta/config.yml @@ -38,6 +38,7 @@ # - state_service # - state_persistentvolume # - state_persistentvolumeclaim +# - state_storageclass # period: 10s # hosts: ["kube-state-metrics:8080"] # add_metadata: true diff --git a/metricbeat/module/kubernetes/state_storageclass/README.md b/metricbeat/module/kubernetes/state_storageclass/README.md new file mode 100644 index 00000000000..8223563fefc --- /dev/null +++ b/metricbeat/module/kubernetes/state_storageclass/README.md @@ -0,0 +1,47 @@ +# Kube-state-metrics/StorageClass + +This metricset connects to kube-state-metrics endpoint to retrieve and report Storage Class metrics. + +Interestingly enough kube-state-metrics does not repport annotations, we are unable to inform which storage class is default. We can consider enriching adding that info, or contributing back to kube-state-metrics to add annotations. + +## Version history + +- February 2020, first release using kube-state-metrics `v1.8.0`. + +## Configuration + +See the metricset documentation for the configuration reference. + +## Manual testing + +Probably your kubernetes cluster already has a storage class. You can add extra SCs: + +Example: + +```bash +kubectl apply -f - << EOF +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: beats-test-sc1 + labels: + testl1: value1 + testl2: value2 +provisioner: kubernetes.io/non-existing1 +reclaimPolicy: Retain +volumeBindingMode: WaitForFirstConsumer +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: beats-test-sc2 + labels: + testl3: value3 + testl4: value4 +provisioner: kubernetes.io/non-existing2 +reclaimPolicy: Delete +volumeBindingMode: Immediate +EOF +``` + +Then run metricbeat pointing to the kube-state-metrics endpoint. diff --git a/metricbeat/module/kubernetes/state_storageclass/_meta/data.json b/metricbeat/module/kubernetes/state_storageclass/_meta/data.json new file mode 100644 index 00000000000..f8dcdfb1bdb --- /dev/null +++ b/metricbeat/module/kubernetes/state_storageclass/_meta/data.json @@ -0,0 +1,47 @@ +{ + "@timestamp": "2020-02-07T17:10:12.124Z", + "@metadata": { + "beat": "metricbeat", + "type": "_doc", + "version": "8.0.0" + }, + "service": { + "address": "192.168.39.32:32042", + "type": "kubernetes" + }, + "kubernetes": { + "storageclass": { + "volume_binding_mode": "Immediate", + "name": "beats-test-sc2", + "created": "2020-02-07T10:14:28.000Z", + "provisioner": "kubernetes.io/non-existing2", + "reclaim_policy": "Delete" + }, + "labels": { + "testl3": "value3", + "testl4": "value4" + } + }, + "event": { + "duration": 13684387, + "dataset": "kubernetes.storageclass", + "module": "kubernetes" + }, + "ecs": { + "version": "1.4.0" + }, + "host": { + "name": "pl51" + }, + "agent": { + "version": "8.0.0", + "type": "metricbeat", + "ephemeral_id": "f4458304-dc2e-4831-be7a-45cd34126fd2", + "hostname": "tamag8", + "id": "e9952df4-592e-4102-84a6-ad0b333b3b98" + }, + "metricset": { + "name": "state_storageclass", + "period": 10000 + } +} diff --git a/metricbeat/modules.d/kubernetes.yml.disabled b/metricbeat/modules.d/kubernetes.yml.disabled index 5f6fa9efce3..358dc58bf83 100644 --- a/metricbeat/modules.d/kubernetes.yml.disabled +++ b/metricbeat/modules.d/kubernetes.yml.disabled @@ -41,6 +41,7 @@ # - state_service # - state_persistentvolume # - state_persistentvolumeclaim +# - state_storageclass # period: 10s # hosts: ["kube-state-metrics:8080"] # add_metadata: true diff --git a/x-pack/metricbeat/metricbeat.reference.yml b/x-pack/metricbeat/metricbeat.reference.yml index b010788aa1b..d54b06a4f2e 100644 --- a/x-pack/metricbeat/metricbeat.reference.yml +++ b/x-pack/metricbeat/metricbeat.reference.yml @@ -659,6 +659,7 @@ metricbeat.modules: - state_service - state_persistentvolume - state_persistentvolumeclaim + - state_storageclass period: 10s hosts: ["kube-state-metrics:8080"] From 53e801a8e5b173edb55d4d84989f3752a47e335f Mon Sep 17 00:00:00 2001 From: Pablo Mercado Date: Fri, 7 Feb 2020 18:25:38 +0100 Subject: [PATCH 3/3] add changelog entry --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index dcefdc09d7e..024f957299a 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -142,6 +142,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Add collecting AuroraDB metrics in rds metricset. {issue}14142[14142] {pull}16004[16004] - Reuse connections in SQL module. {pull}16001[16001] - Improve the `logstash` module (when `xpack.enabled` is set to `true`) to use the override `cluster_uuid` returned by Logstash APIs. {issue}15772[15772] {pull}15795[15795] +- Add kubernetes storage class support via kube-state-metrics. {pull}16145[16145] *Packetbeat*