Monitoring Session Servers using Prometheus and Grafana
You can monitor Host Access for the Cloud session servers using Prometheus and Grafana. Both of these tools are free, open source, and can be run in Docker containers which makes for easy deployment. Each session server provides a Prometheus endpoint that exposes metrics about that server. Prometheus can be configured to scrape data from this endpoint and store the metrics on an ongoing basis, even from multiple session servers. Grafana then provides a dashboard to query and visualize this data, with very little setup.
Prerequisites:
You must have Docker and Docker Compose installed.
Steps:
-
Create a Docker Compose file (.yml) that contains both Grafana and Prometheus images.
-
Link Prometheus to your session server Prometheus endpoint.
-
Configure your Grafana data source to communicate with Prometheus and import the pre-configured dashboards.
-
Configure the Grafana dashboards.
-
Access Grafana.
Step 1. Create a Docker Compose file
Create a docker-compose.yml
file containing Grafana and Prometheus images.
version: "3.1"
services:
grafana:
build: grafana
ports:
- '3000:3000'
prometheus:
image: prom/prometheus:v2.6.1
ports:
- '9090:9090'
volumes:
- ./config/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus:/prometheus
networks:
monitoring:
aliases:
- prometheus
networks:
monitoring:
Step 2. Link Prometheus to your HACloud Prometheus endpoint
To link Prometheus to your endpoint, generate a prometheus.yml
file.
-
In our example, the
prometheus.yml
file is saved in the config directory. -
This example config allows you to scrape the Prometheus endpoint using either HTTP or HTTPS (TLS).
-
If TLS is disabled on the session server, remove tls_config and change the scheme to http in the example config.
-
Configure the session-server-hostname.
!!! note "note" Due to Docker networking, this must be the actual IP or hostname of your session server host computer. This IP can typically be obtained using ifconfig/ipconfig.
-
Adjust ports if needed.
Example config/prometheus.yml
scrape_configs:
- job_name: ' HACloud Session Server with TLS'
scrape_interval: 15s
scheme: https
tls_config:
insecure_skip_verify: true
metrics_path: actuator/prometheus
static_configs:
- targets: ['session-server-hostname:7443']
Step 3. Configure communication between Prometheus and the data source
Communication can be configured within the Grafana Docker image between the local instance of Prometheus and your Grafana data source. Pre-loaded dashboards are also available to you at startup.
Example grafana/Dockerfile
FROM grafana/grafana:8.0.5
ADD ./provisioning /etc/grafana/provisioning
ADD ./config.ini /etc/grafana/config.ini
ADD ./dashboards /var/lib/grafana/dashboards
[paths]
provisioning = /etc/grafana/provisioning
Example grafana/provisioning/datasources/all.yml
datasources:
- name: 'Prometheus'
type: 'prometheus'
access: 'browser'
url: 'http://localhost:9090'
is_default: true
editable: false
Example grafana/provisioning/dashboards/all.yml
- name: 'default'
org_id: 1
folder: ''
type: 'file'
options:
folder: '/var/lib/grafana/dashboards'
Step 4. Configure the Grafana dashboards
There is a sample JSON file to help you get started configuring your Grafana dashboards.
To have your Docker container load the dashboard on startup:
-
Locate
HACloudSessionservers.json
in thehacloud/utilities/grafana
directory. -
Copy
HACloudSessionservers.json
to yourgrafana/dashboards
directory.
Step 5. Access Grafana
-
Start the Docker container with the command docker-compose up -d.
-
Verify Prometheus targets are successfully scraping the session servers using
http://localhost:9090/targets
. -
Access Grafana using
http://localhost:3000
. -
Both the user name and password = admin. The user name and password can be configured using Docker environment variables.
-
Use the command docker-compose down to stop the Docker container.