Skip to content

Enabling cluster metrics#

Metrics are numerical measurements that estimate various performance aspects of applications running in the cluster. Lens K8S IDE provides a built-in solution. You can also use other Prometheus-based tools for collecting such data.

Enable Lens Metrics#

Lens Metrics is the built-in metrics provider. To enable Lens Metrics:

  1. Navigate to the cluster Settings > Lens Metrics menu.
  2. Toggle Prometheus to install the Prometheus stack on your cluster.
  3. Optional. Toggle Kube State Metrics to install the kube-state-metrics service. Choose this option only if the service is not installed on your cluster.
  4. Optional. Toggle Node Exporter to install Prometheus Node Exporter. Choose this option only if the exporter is not installed on your cluster.

Configuring cluster metrics#

The metrics collecting in Lens is based on the Prometheus monitoring system. By default, Lens K8S IDE allows collecting data from the cluster through the automatically detected built-in Prometheus instance (provider).

Prometheus providers#

You can manually select one of the Prometheus instances described in the table below.

Prometheus query format Description
Helm 14.x The 14.x version of the Helm chart that installs the kube-prometheus stack
Helm Other Helm chart versions with the kube-prometheus stack
Lens The built-in Lens metrics provider
Prometheus Operator The set of Kubernetes custom resources that enable deploying and configuring Prometheus
StackLight The Mirantis logging, monitoring, and alerting solution
VictoriaMetrics A VMSingle managed by the VictoriaMetrics operator, as installed by the victoria-metrics-k8s-stack chart
VictoriaMetrics (single) The standalone victoria-metrics-single Helm chart

In case of custom provider, you may need to specify the Prometheus Service Address, the path to an existing instance in the <namespace>/<service>:<port> format. By default, Lens K8S IDE automatically detects the instance address.

VictoriaMetrics#

If VictoriaMetrics monitors your cluster, Lens K8S IDE finds it and displays your metrics with no setup. Detection covers two deployments:

  • A VMSingle managed by the VictoriaMetrics operator. Lens finds the service labeled app.kubernetes.io/name=vmsingle and queries its query port, 8429 by default.
  • The standalone victoria-metrics-single Helm chart. Lens finds the service labeled app.kubernetes.io/name=victoria-metrics-single and queries its query port, 8428 by default.

The two deployments label their metrics differently, so Lens uses a different query dialect for each. Select the provider that matches your deployment if you set the provider manually.

Note

A cluster that runs both Prometheus and VictoriaMetrics uses Prometheus. A VMCluster is not detected, because its query API sits behind a per-tenant path prefix that Lens cannot know.

Hiding metrics in the UI#

The Cluster tab displays metrics-based information. You can exclude the cluster objects from the display. Select necessary cluster objects in the Hide Metrics from the UI drop-down list.

Enabling metrics for RBAC limited users#

You can enable Lens built-in metrics to users with limited access to a cluster. Create a Role and a corresponding RoleBinding similar to the following examples:

Note

Custom metrics setups may require different configurations for the Role and RoleBinding objects. However, the rules section of the Role example should still be applicable.

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  namespace: lens-metrics
  name: read-only-lens-metrics
rules:
- apiGroups:
  - ""
  - "apps"
  resources:
  - pods
  - events
  - services
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - "services/proxy"
  verbs:
  - create
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  annotations:
  namespace: lens-metrics
  name: vendor-read-metrics
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: read-only-lens-metrics
subjects:
- kind: Group
  name: ${SOMEGROUP1}
  apiGroup: rbac.authorization.k8s.io
- kind: Group
  name: ${SOMEGROUP2}
  apiGroup: rbac.authorization.k8s.io

See also

Adding clusters to Lens K8S IDE