Configure Prometheus to scrape MSR metrics¶
To collect MSR metrics, you must install a Prometheus server on your MSR cluster.
Kubernetes deployments¶
To install a Prometheus server:
Add the Prometheus repository:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
Update the Prometheus repository:
helm repo update
Obtain the target IP address and port for the
msr-api
service:kubectl get svc
The IP address is listed under
CLUSTER-IP
and the port is listed underPORT(S)
.Create a
prometheus-values.yaml
file with the following configuration detail:extraScrapeConfigs: | - job_name: '<metrics-job-name>' metrics_path: /api/v0/admin/metrics static_configs: - targets: ['<msr-api-service-cluster-ip>:<port>'] basic_auth: username: '<user-name>' password: '<password>' scheme: https tls_config: <tls-detail>
Note
For more information on how to fill out this configuration detail, refer to <scrape_config> in the official Prometheus documentation.
To learn how to generate and add your own certs to MSR, refer to Add a custom TLS certificate.
Note
The Helm chart used herein includes the
prometheus-node-exporter
, which may crash at start up on some local environments.To resolve this issue, include the following configuration detail in the
prometheus-values.yaml
file:prometheus-node-exporter: hostRootFsMount: enabled: false
Install the Prometheus server:
helm install -f prometheus-values.yaml prometheus prometheus-community/prometheus
To verify that your Prometheus server is running and scraping the MSR metrics endpoint:
Forward the Prometheus server to port
9090
:kubectl port-forward `kubectl get pods | grep prometheus-server | tr -s ' ' | cut -d' ' -f1` 9090
In a web browser, navigate to
http://<prometheus-host>:9090
.Select Status > Targets in the Prometheus UI menu bar.
Verify that the MSR metrics endpoint is listed on the page with the up status.
The metrics endpoint is labeled with the
job-name
entered in theextraScrapeConfigs
section of theprometheus-values.yaml
file.
Swarm deployments¶
To install a Prometheus server:
SSH into a manager node on your Swarm cluster.
Create a
prometheus.yml
file that includes the following values:scrape_configs: - job_name: '<metrics-job-name>' metrics_path: /api/v0/admin/metrics static_configs: - targets: ['msr-api-server:443'] basic_auth: username: '<user-name>' password: '<password>' scheme: https tls_config: <tls-detail>
Note
For more information on how to fill out this configuration detail, refer to <scrape_config> in the official Prometheus documentation.
To learn how to generate and add your own certs to MSR, refer to Add a custom TLS certificate.
Create the following
docker-stack.yaml
file to configure a Swarm service for deploying the Prometheus server:version: '3.7' volumes: prometheus_data: services: prometheus: image: prom/prometheus:v2.45.0 volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml - prometheus_data:/prometheus ports: - <prometheus-ui-port>:9090 networks: - msr_msr-ol deploy: placement: constraints: - node.role==manager networks: msr_msr-ol: name: msr_msr-ol external: true
Note
For the
<prometheus-ui-port>
value in theports
section, select a port that is currently available in your Swarm cluster.Deploy the Prometheus server onto your Swarm cluster:
docker stack deploy -c docker-stack.yaml prometheus
To verify that your Prometheus server is running and scraping the MSR metrics endpoint:
Verify that your Prometheus service is running:
docker service ls
In a web browser, navigate to
http://<manager-node-ip>:<prometheus-ui-port>
. This is the same<prometheus-ui-port>
that you included in theports
section of thedocker-stack.yaml
file.Select Status > Targets in the Prometheus UI menu bar.
Verify that the MSR metrics endpoint is listed on the page with the up status. You may need to wait approximately 30 seconds for this to occur.
The metrics endpoint is labeled with the
<metrics-job-name>
entered in thescrape_configs
section of theprometheus.yml
file.