Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metricbeat]Kubernetes: add resource quotas via kube-state-metrics #13693

Merged
2 changes: 2 additions & 0 deletions deploy/kubernetes/metricbeat-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ data:
- state_replicaset
- state_pod
- state_container
- state_cronjob
- state_resourcequota
# Uncomment this to get k8s events:
#- event
period: 10s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ data:
- state_replicaset
- state_pod
- state_container
- state_cronjob
- state_resourcequota
# Uncomment this to get k8s events:
#- event
period: 10s
Expand Down
52 changes: 52 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17272,6 +17272,58 @@ type: long

--

[float]
=== resourcequota

kubernetes resourcequota metrics



*`kubernetes.resourcequota.created.sec`*::
+
--
Epoch seconds since the ResourceQuota was created

type: double

--

*`kubernetes.resourcequota.quota`*::
+
--
Quota informed (hard or used) for the resource

type: double

--

*`kubernetes.resourcequota.name`*::
+
--
ResourceQuota name

type: keyword

--

*`kubernetes.resourcequota.type`*::
+
--
Quota information type, `hard` or `used`

type: keyword

--

*`kubernetes.resourcequota.resource`*::
+
--
Resource name the quota applies to

type: keyword

--

[float]
=== statefulset

Expand Down
5 changes: 5 additions & 0 deletions metricbeat/docs/modules/kubernetes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ metricbeat.modules:
- state_pod
- state_container
- state_cronjob
- state_resourcequota
period: 10s
hosts: ["kube-state-metrics:8080"]

Expand Down Expand Up @@ -179,6 +180,8 @@ The following metricsets are available:

* <<metricbeat-metricset-kubernetes-state_replicaset,state_replicaset>>

* <<metricbeat-metricset-kubernetes-state_resourcequota,state_resourcequota>>

* <<metricbeat-metricset-kubernetes-state_statefulset,state_statefulset>>

* <<metricbeat-metricset-kubernetes-system,system>>
Expand Down Expand Up @@ -213,6 +216,8 @@ include::kubernetes/state_pod.asciidoc[]

include::kubernetes/state_replicaset.asciidoc[]

include::kubernetes/state_resourcequota.asciidoc[]

include::kubernetes/state_statefulset.asciidoc[]

include::kubernetes/system.asciidoc[]
Expand Down
23 changes: 23 additions & 0 deletions metricbeat/docs/modules/kubernetes/state_resourcequota.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-metricset-kubernetes-state_resourcequota]]
=== Kubernetes state_resourcequota metricset

beta[]

include::../../../module/kubernetes/state_resourcequota/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-kubernetes,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/kubernetes/state_resourcequota/_meta/data.json[]
----
3 changes: 2 additions & 1 deletion metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ This file is generated! See scripts/mage/docs_collector.go
.2+| .2+| |<<metricbeat-metricset-kibana-stats,stats>>
|<<metricbeat-metricset-kibana-status,status>>
|<<metricbeat-module-kubernetes,Kubernetes>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.17+| .17+| |<<metricbeat-metricset-kubernetes-apiserver,apiserver>>
.18+| .18+| |<<metricbeat-metricset-kubernetes-apiserver,apiserver>>
|<<metricbeat-metricset-kubernetes-container,container>>
|<<metricbeat-metricset-kubernetes-controllermanager,controllermanager>> beta[]
|<<metricbeat-metricset-kubernetes-event,event>>
Expand All @@ -105,6 +105,7 @@ This file is generated! See scripts/mage/docs_collector.go
|<<metricbeat-metricset-kubernetes-state_node,state_node>>
|<<metricbeat-metricset-kubernetes-state_pod,state_pod>>
|<<metricbeat-metricset-kubernetes-state_replicaset,state_replicaset>>
|<<metricbeat-metricset-kubernetes-state_resourcequota,state_resourcequota>> beta[]
|<<metricbeat-metricset-kubernetes-state_statefulset,state_statefulset>>
|<<metricbeat-metricset-kubernetes-system,system>>
|<<metricbeat-metricset-kubernetes-volume,volume>>
Expand Down
1 change: 1 addition & 0 deletions metricbeat/include/list_docker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ metricbeat.modules:
- state_pod
- state_container
- state_cronjob
- state_resourcequota
period: 10s
hosts: ["kube-state-metrics:8080"]

Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/kubernetes/_meta/config.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- state_pod
- state_container
- state_cronjob
- state_resourcequota
period: 10s
hosts: ["kube-state-metrics:8080"]

Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/kubernetes/_meta/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# - state_pod
# - state_container
# - state_cronjob
# - state_resourcequota
# period: 10s
# hosts: ["kube-state-metrics:8080"]
# add_metadata: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# ResourceQuota tests

# This example will create a namespace and apply some resource restrictions on it, then
# some of those restrictions will be challenged

apiVersion: v1
kind: Namespace
metadata:
name: rqtest

---

apiVersion: v1
kind: ResourceQuota
metadata:
namespace: rqtest
name: resources
spec:
hard:
requests.cpu: 1
requests.memory: 1Gi
limits.cpu: 2
limits.memory: 2Gi

---

apiVersion: v1
kind: ResourceQuota
metadata:
namespace: rqtest
name: objects
spec:
hard:
pods: 3
configmaps: 1
persistentvolumeclaims: 0
replicationcontrollers: 1
secrets: 1
services: 2
services.loadbalancers: 1

---

# See presistent volume claims above. They are not allowed (count 0), which means
# that this request will fail
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: rqtest
name: willfail
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi

---

# ResourceQuota/objects above allows only for one Service element type LoadBalancer
# this call should succeed, but subsequent creations will fail.
#
# It doesn't matter if the LoadBalancer is really created, what counts is the API
# object creation. You can try this at your local kubernetes environment.

apiVersion: v1
kind: Service
metadata:
name: willsucceed
namespace: rqtest
spec:
selector:
app: something
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer

---

# As a continuation of the above case, this Service type LoadBalancer will exceed
# assigned quota for the namespace and will fail

apiVersion: v1
kind: Service
metadata:
name: willfail
namespace: rqtest
spec:
selector:
app: something
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading