Skip to content

Enabling cluster metrics#

Metrics are numerical measurements that estimate various performance aspects of applications running in the cluster. Lens Desktop 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 Desktop 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

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 Desktop automatically detects the instance address.

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