kube-state-metrics

Enjoy a richer custom dashboards experience

kube-state-metrics is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects. groundcover comes with a built-in deployment of kube-state-metrics, and exposes its metrics within our embedded Grafana in two potential ways described below.

groundcover selected metrics

groundcover's built-in deployment of kube-state-metrics comes with a minimal configuration, keeping only a pre-selected set of the metrics which are used in our native screens. This approach has the benefit of limiting the potentially huge cardinality of KSM metrics, while also allowing us to enrich the selected metrics with extra groundcover labels.

KSM metrics generated in this method will be prefixed with groundcover_ in order to separate them from other KSM deployments. For example, the metrickube_pod_status_phase will appear in groundcover as groundcover_kube_pod_status_phase.

Full KSM metrics

If you are interested in having the full scope of available KSM metrics, it's possible to configure groundcover's KSM deployment for the task.

This is achieved following these steps:

  1. Configuring the KSM deployment for full collection

  2. Turning on custom metrics scraping

  3. Setting up a scrape job to fetch the KSM metrics

Configuring the KSM deployment

groundcover uses a minimal set of KSM collectors. In order to configure our KSM deployment for full collection, use the following configuration:

kube-state-metrics:
  collectors:
    - certificatesigningrequests
    - configmaps
    - cronjobs
    - daemonsets
    - deployments
    - endpoints
    - horizontalpodautoscalers
    - ingresses
    - jobs
    - leases
    - limitranges
    - mutatingwebhookconfigurations
    - namespaces
    - networkpolicies
    - nodes
    - persistentvolumeclaims
    - persistentvolumes
    - poddisruptionbudgets
    - pods
    - replicasets
    - replicationcontrollers
    - resourcequotas
    - secrets
    - services
    - statefulsets
    - storageclasses
    - validatingwebhookconfigurations
    - volumeattachments

Turning on custom metrics scraping

groundcover supports a flag to turn on automatic collection of custom metrics. If you haven't enabled custom metrics yet, do so using the steps in the link above.

Setting up a custom metrics scrape job

Add the following override to add a scrape job which will scrape the KSM deployment, making the metrics available in groundcover's embedded Grafana.

custom-metrics:
    extraScrapeConfigs:
    - job_name: groundcover-kube-state-metrics
      honor_timestamps: true
      honor_labels: true
      scrape_interval: 1m
      scrape_timeout: 1m
      metrics_path: /metrics
      scheme: http
      static_configs:
      - targets:
        - groundcover-kube-state-metrics.groundcover.svc.cluster.local:8080

Last updated