////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-module-kubernetes]]
== Kubernetes module

This module fetches metrics from Kubernetes https://kubernetes.io/docs/admin/kubelet/[kubelet]
agent and https://github.com/kubernetes/kube-state-metrics[kube-state-metrics] service.

All metricsets with the `state_` prefix require `hosts` field pointing to kube-stat-metrics
service within the cluster, while the rest should be pointed to kubelet service. Check the
example configuration on how to do it.

The default metricsets are `container`, `node`, `pod`, `system` and `volume`.

[float]
=== Compability

The Kubernetes module is tested with Kubernetes 1.8.0, 1.9.4 and 1.10.0.


[float]
=== Example configuration

The Kubernetes module supports the standard configuration options that are described
in <<configuration-metricbeat>>. Here is an example configuration:

[source,yaml]
----
metricbeat.modules:
# Node metrics, from kubelet:
- module: kubernetes
  metricsets:
    - container
    - node
    - pod
    - system
    - volume
  period: 10s
  hosts: ["localhost:10255"]
  enabled: true
  #bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  #ssl.certificate_authorities:
  #  - /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
  #ssl.certificate: "/etc/pki/client/cert.pem"
  #ssl.key: "/etc/pki/client/cert.key"

  # Enriching parameters:
  add_metadata: true
  in_cluster: true
  # When used outside the cluster:
  #host: node_name
  #kube_config: ~/.kube/config

# State metrics from kube-state-metrics service:
- module: kubernetes
  enabled: true
  metricsets:
    - state_node
    - state_deployment
    - state_replicaset
    - state_statefulset
    - state_pod
    - state_container
  period: 10s
  hosts: ["kube-state-metrics:8080"]

  # Enriching parameters:
  add_metadata: true
  in_cluster: true
  # When used outside the cluster:
  #host: node_name
  #kube_config: ~/.kube/config

# Kubernetes events
- module: kubernetes
  enabled: true
  metricsets:
    - event

# Kubernetes API server
- module: kubernetes
  enabled: true
  metricsets:
    - apiserver
  hosts: ["https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}"]
----

This module supports TLS connections when using `ssl` config field, as described in <<configuration-ssl>>.
It also supports the options described in <<module-http-config-options>>.

[float]
=== Metricsets

The following metricsets are available:

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

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

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

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

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

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

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

* <<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_statefulset,state_statefulset>>

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

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

include::kubernetes/apiserver.asciidoc[]

include::kubernetes/container.asciidoc[]

include::kubernetes/event.asciidoc[]

include::kubernetes/node.asciidoc[]

include::kubernetes/pod.asciidoc[]

include::kubernetes/state_container.asciidoc[]

include::kubernetes/state_deployment.asciidoc[]

include::kubernetes/state_node.asciidoc[]

include::kubernetes/state_pod.asciidoc[]

include::kubernetes/state_replicaset.asciidoc[]

include::kubernetes/state_statefulset.asciidoc[]

include::kubernetes/system.asciidoc[]

include::kubernetes/volume.asciidoc[]

