Reading and writing Yandex Managed Service for Kubernetes cluster metrics with the Prometheus Operator
Prometheus Operator with Yandex Monitoring support makes it easy to install and manage the Yandex Managed Service for Prometheus® monitoring system. You can use it to collect, store, and read metrics from your containers, applications, and infrastructure. The system uses the Prometheus data model and the PromQL
Getting started
-
Make sure that the security groups for the Managed Service for Kubernetes cluster and its node groups are configured correctly. If any rule is missing, add it.
Warning
The configuration of security groups determines the performance and availability of the cluster and the services and applications running in it.
-
On the Yandex Monitoring home page
, select Prometheus in the left-hand panel. -
In the Writing metrics tab, find the URL of the endpoint to write metrics to:
https://monitoring.api.cloud.yandex.net/prometheus/workspaces/<Prometheus_Workspace_ID>/api/v1/write
Save the Prometheus Workspace ID (a substring in
mon*****************
format); you will need it later during setup. -
Create a service account for Prometheus Operator.
-
Create an API key for the service account and save its secret part.
Installation using Yandex Cloud Marketplace
- Go to the folder page
and select Managed Service for Kubernetes. - Click the Kubernetes cluster name and select the Marketplace tab.
- Under Applications available for installation, select Prometheus Operator with Yandex Monitoring support and click Use.
- Configure the application:
- Namespace: Select a namespace or create a new one.
- Application name: Enter a name for the application.
- Workspace ID: Enter the Prometheus Workspace ID (
mon*****************
). - API key: Enter the secret part of the API key.
- Click Install.
- Wait for the application to change its status to
Deployed
.
Installation using a Helm chart
-
Install Helm
v3.7.0 or higher. -
Install kubectl
and configure it to work with the created cluster. -
To install a Helm chart
with Prometheus Operator, run this command:export HELM_EXPERIMENTAL_OCI=1 && \ helm pull oci://cr.yandex/yc-marketplace/yandex-cloud/prometheus/kube-prometheus-stack \ --version 57.2.0-1 \ --untar && \ helm install \ --namespace <namespace_for_Prometheus_Operator> \ --create-namespace \ --set prometheusWorkspaceId=<Prometheus_Workspace_ID> \ --set apiKeySecret=<secret_part_of_API_key> \ prometheus ./kube-prometheus-stack/
The command will also create a new namespace required for Prometheus Operator.
-
Make sure the Prometheus Operator pods have changed their status to
Running
:kubectl get pods --namespace=<Prometheus_Operator_namespace> \ | grep prometheus
Connecting to a Grafana dashboard
To connect to a Grafana dashboard:
-
Install kubectl
and configure it to work with the created cluster. -
Get the name of the pod with the running Grafana application:
kubectl get pods --namespace=<Prometheus_Operator_namespace> \ | grep grafana
-
Configure
grafana
service port forwarding to the local computer:kubectl port-forward --namespace=<Prometheus_Operator_namespace> \ <Grafana_pod_name> 8080:3000
Note
If you close the terminal window or abort the command port forwarding will be stopped.
-
In your browser, open the Grafana dashboard at
http://localhost:8080
. -
Log in as
admin
using theprom-operator
password.
See also
© 2024 Linux Foundation. All rights reserved. The Linux Foundation owns and uses registered trademarks. For a list of Linux Foundation trademarks, see Trademark Usage