Type to search.

Kubernetes apiserver metricset

Serverless

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Serverless interfaces and procedures might differ from classic Elastic Stack deployments.

Stack

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

This is the apiserver metricset of the Kubernetes module, in charge of retrieving metrics from the Kubernetes API (available at /metrics).

This metricset needs access to the apiserver component of Kubernetes, accessible typically by any POD via the kubernetes.default service or via environment variables (KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT).

When the API uses https, the pod will need to authenticate using its default token and trust the server using the appropiate CA file.

Configuration example using https and token based authentication:

YAML
- module: kubernetes
  enabled: true
  metricsets:
    - apiserver
  hosts: ["https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}"]
  #hosts: ["https://kubernetes.default"]
  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ssl.certificate_authorities:
    - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
  period: 30s

In order to access the /metrics path of the API service, some Kubernetes environments might require the following permission to be added to a ClusterRole.

YAML
rules:
- nonResourceURLs:
  - /metrics
  verbs:
  - get

The previous configuration and RBAC requirement is available in the complete example manifest proposed in Running Metricbeat on Kubernetes document.

For a description of each field in the metricset, see the exported fields section.

Here is an example document generated by this metricset:

JSON
{
    "@timestamp": "2019-03-01T08:05:34.853Z",
    "event": {
        "dataset": "kubernetes.apiserver",
        "duration": 115000,
        "module": "kubernetes"
    },
    "kubernetes": {
        "apiserver": {
            "major": {
                "version": "1"
            },
            "minor": {
                "version": "21"
            },
            "request": {
                "code": "0",
                "component": "apiserver",
                "count": 14,
                "resource": "endpoints",
                "scope": "cluster",
                "verb": "WATCH",
                "version": "v1"
            }
        }
    },
    "metricset": {
        "name": "apiserver",
        "period": 10000
    },
    "service": {
        "address": "127.0.0.1:55555",
        "type": "kubernetes"
    }
}