Metrics Configuration #
This document walks you through how to configure the Metrics feature.
What is a Metrics? #
The
Metrics is a
kwok Configuration that allows users to define and simulate metrics endpoints exposed by kubelet.
The YAML below shows all the fields of a Metrics resource:
kind: Metric
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
name: <string>
spec:
path: <string>
metrics:
- name: <string>
help: <string>
kind: <string>
dimension: <string>
labels:
- name: <string>
value: <string>
value: <string> # for counter and gauge
buckets: # for histogram
- le: <float64>
value: <string>
hidden: <bool>
There are total four metric-related endpoints in kubelet: /metrics, /metrics/resource, /metrics/probe and /metrics/cadvisor,
all of which are exposed with a Prometheus style. The Metrics resource is capable of simulating endpoints with such style.
The path field is required and must start with /metrics.
To distinguish the metrics of different nodes, the path includes a variable {nodeName} that is replaced by the node name.
The descriptions of each sub-field are available at Metric API. For readers’ convenience, we also mirror the documents here with some additional notes.
metrics is a list of specific configuration items, with each corresponding to a Prometheus style metric:
namedefines the metric name.labelsdefines the metric labels, with each item corresponding to a specific metric label.nameis a const string that provides the label name.valueis represented as a CEL expressions that dynamically determines the label value. For example: you can usenode.metadata.nameto reference the node name as the label value.
helpdefines the help string of a metric.kinddefines the type of the metric:counter,gauge, orhistogram.dimensiondefines where the data comes from. It could benode,pod, orcontainer.valueis a CEL expressions that defines the metric value ifkindiscounterorgauge.bucketsis exclusively for customizing the data of the metric of kindhistogram.le, which defines the histogram bucket’s upper threshold, has the same meaning as the one of Prometheus histogram bucket. That is, each bucket contains values less than or equal tole.valueis a CEL expression that provides the value of the bucket.hiddenindicates whether to show the bucket in the metric. But the value of the bucket will be calculated and cumulated into the next bucket.
Examples #
Please refer to
Metrics for kubelet’s /metrics/resource endpoint for a detailed.