Installing and Configuring Metrics for Prometheus and Grafana on Windows
Introduction
This page documents the steps involved in installing and configuring metrics for Weave and have those metrics recorded in Prometheus and displayed in Grafana.
The installation is on Windows: the basic steps can be followed to install on a different operating system.
Installation
Here is the existing documentation for installing Weave System Metrics
New Instance.
When installing Weave from the required jar file, e.g.,
java -jar weave-installer-2.6.9.r23195.jar
Make sure to tick the metrics box as shown.
Only one system metric bundle out of JAMon, Datadog, InfluxDB or Prometheus should be selected.
Update an Existing Weave instance
Firstly, we need to check if the required bundles exist in the Weave platform/plugins folder. The required bundles are shown below.
Weave Metrics Bundles
The following bundles are required for Weave to implement metrics (ignore bundle version number):
platform\plugins\com.cohga.server.metric.client_1.2.2.r26.jar
platform\plugins\com.cohga.server.metric.impl_2.3.4.r26.jar
platform\plugins\com.cohga.server.metric.registry.api_1.1.0.r26.jar
platform\plugins\com.cohga.server.metric.registry.micrometer_2.2.3.r26.jar
platform\plugins\com.cohga.server.metric.registry.prometheus_2.2.1.r26.jar
platform\plugins\com.cohga.server.metric.system_1.1.8.r26.jar
platform\plugins\io.micrometer.core_1.0.11.jar
While there are other bundles for Jamon, Datadog and InfluxDB (not shown) exist, only one bundle out of JAMon, Datadog, InfluxDB or Prometheus should exist in the plugins directory depending on which metrics tool one is using: in this case, Prometheus.
If these bundles exist, Weave metrics are already installed.
If these bundles do not exist, we can add them via the Weave installer. Run the installer as usual:
java -jar weave-installer-2.6.9.r23195.jar
Enter the location (Target Path) of Weave where you want to add the packages and press Yes to the question “The directory already exists…” as shown below.
Then press Yes and at the “Select Installation Packages” page, deselect “Main Components”, select “Extensions>System Metrics>Prometheus” and press Next.
The required bundles will then be installed.
When updating an existing Weave install, make sure that only one system metric bundle out of JAMon, Datadog, InfluxDB or Prometheus is selected and installed.
Once Weave has had the correct bundles installed, we should check that the metrics are working.
1. Check Metrics Bundles are Active
Open the Weave Admin tool, click on the Bundles app, then type “metric” into the input box of the Bundles app. If the Metrics bundles are correctly installed, they will appear as follows.
2. Check metrics End Point
Open a browser and type in the following URL:
This should generate data as in the following image:
Once data appears we can proceed to install Prometheus.
Install Prometheus
Firstly, download Prometheus from the official website. Once downloaded, unzip the file and place the folder in an appropriate location.
Next, Prometheus needs to be configured via a configuration file. (The configuration file should contain information about the targets that Prometheus should monitor.) Edit the prometheus.yml file as per the instructions located here.
Once the yml file is created, run the Prometheus executable (in a manner appropriate to your platform).
Grafana
Grafana is a dashboad that provides visualisation (e.g. pie charts, histograms etc) of the metrics gathered by Prometheus.
Grafana can be downloaded from Grafana Labs. For Windows, download the msi file (e.g. grafana-enterprise-10.0.0.windows-amd64.msi).
For Linux Grafana can be downloaded using:
wget https://grafana.com/grafana/download/10.0.0?pg=oss-graf&platform=linux&plcmt=hero-btn-1
Once the download has completed, run the appropriate executable to install Grafana.
Once Grafana is installed, use the default URL to connect to Grafana: http://localhost:3000
Sign in to Grafana using this information.
Connect Grafana to Prometheus
Once you have signed in, we first need to create a connection to Prometheus.
Click on Home and select Connections.
Type in Prom to the search bar to find the Prometheus connection:
Click on Prometheus.
Then click on Create a Prometheus data source.
Accept the defaults and press Save & Test at the bottom of the page. A message Successfully queried the Prometheus API should appear.
In the next page, enter http://localhost:9090 as the Prometheus server URL and enter 1 for Timeout. Scroll down to the bottom of the page and press Save & Test.
Now that we have a Prometheus connection, we can create a Grafana dashboard to display our statistics.
A basic dashboard for Grafana that has been created for Weave metrics that uses Prometheus is available for import from here. To import this dashboard, go to Build your first dashboard, click on New>Import, then click on “Upload dashboard JSON file”.
Find the JSON file in the file system, then select the Prometheus data connection, and press Import.
A Weave internals dashboard should now appear.
No statistics are visible. Execute some activity in Weave (e.g. pan/zoom, query an entity..) to generate some. Activity may look like this: