Developer Documentation Library > Interviewer - Server > Monitoring and tuning system performance > Monitoring and tuning the system > Monitoring the system by using Prometheus and Grafana > Installing and configuring Prometheus
 
Installing and configuring Prometheus
Prometheus gets metric information from mrIWeb, mrIEngWS, and the Web API.
1 Download Prometheus from the following location:
https://prometheus.io/download/
2 Extract the contents of the downloaded file to a new folder, for example:
C:\Monitoring\prometheus-2.45.3.windows-amd64
Configuration for mrIWeb
In the prometheus.yml file, set the following parameters:
credentials
Specify the MetricsCredentials = <string> value that is set in the mrIWeb web.config file.
targets
Specify the internal hostname of the server, without the scheme being specified. Multiple targets can be specified. Give all mrIWeb targets the same MetricsCredentials = <string> value.
The relabel_configs section divides the target values to extract the __address__ and __metrics_path__ values which are used by Prometheus to get the metrics and the server and the instance values which are used to label all metrics retrieved by that job.
Example configuration for mrIWeb
- job_name: mrIWeb
scheme: http
authorization:
type: Bearer
credentials: <secret_value_from_the_web.config_file>
static_configs:
- targets: ['<local_hostname>/mrIWeb/mrIWeb.dll']
params:
Handler: ["Metrics"]
IncludeEngineMetrics: ["True"]
relabel_configs:
- source_labels: [__address__]
regex: '([^/]+)/([^\/]+).*' # capture the hostname and the mrIWeb instance
replacement: '${1}_${2}' # create an instance name from the hostname and mrIWeb instance name
target_label: instance # change the instance label
- source_labels: [__address__]
regex: '([^/]+).*'
target_label: server
- source_labels: [__address__]
regex: '[^/]+(/.*)' # capture the '/...' part
target_label: __metrics_path__ # change the metrics path label
- source_labels: [__address__]
regex: '([^/]+)/.*' # capture the host:port
target_label: __address__ # change the target label
Configuration for mrIEngWS
targets
Specify the local hostname of the server.
Add a targets entry for each engine on each server.
There are no credentials for mrIEngWS, because it is not normally publicly accessible.
The relabel_configs section splits the target values into information required by Prometheus for the scraping, and into server, engine, and instance labels which are applied to the metric series.
- job_name: mrIEngWS
scheme: http
static_configs:
- targets: ['engine1:<local_hostname>/mrIEngWS/mrIEngWS.dll', 'engine2:<LocalHostName>/mrIEngWS1/mrIEngWS.dll']
params:
Handler: ["Metrics"]
IncludeProjectMetrics: ["True"]
relabel_configs:
- source_labels: [__address__]
regex: '([^:]+):([^/]+)/([^/]+).*' # capture the hostname (without domain) and the mrIEngWS instance
replacement: '${2}_${3}' # create an instance name from the hostname and mrIEngWS instance name
target_label: instance # change the instance label
- source_labels: [__address__]
regex: '[^:]+:([^/]+).*'
target_label: server
- source_labels: [__address__]
regex: '([^:]+):.*'
target_label: engine
- source_labels: [__address__]
regex: '[^/]+(/.*)' # capture '/...' part
target_label: __metrics_path__ # change the metrics path label
- source_labels: [__address__]
regex: '[^:]+:([^/]+)/.*' # capture the host:port
target_label: __address__ # change the target label
Configuration for the Web API
client_secret
Specify the Prometheus client secret value that was previously configured in DPM.
token_url
Specify the publicly accessible address of the OIDC application.
The targets value must be the internal or local address of the Prometheus metrics endpoint, without including the scheme, which is specified separately.
- job_name: WebApi
scheme: http
oauth2:
client_id: Prometheus
client_secret: '<client_secret_value_in_DPM>'
scopes:
- intelligence_web_api
token_url: https://<public_hostname>/SPSSMR/Oidc/connect/token
static_configs:
- targets: ['<local_hostname>/SPSSMR/WebApi/Metrics/Prometheus']
relabel_configs:
- source_labels: [__address__]
regex: '([^/]+)/SPSSMR/([^/]*).*' # capture the hostname (without domain) and the WebApi instance
replacement: '${1}_${2}' # create an instance name from the hostname and WebApi instance name
target_label: instance # change instance label
- source_labels: [__address__]
regex: '([^/]+).*'
target_label: server
- source_labels: [__address__]
regex: '[^/]+(/.*)' # capture '/...' part
target_label: __metrics_path__ # change metrics path label
- source_labels: [__address__]
regex: '([^/]+)/.*' # capture host:port
target_label: __address__ # change target label
If you installed the Windows Exporter (see Enabling Windows operating system metrics), you can use the following configuration:
- job_name: "Windows"
static_configs:
- targets: ["<local_hostname>:9182"]
relabel_configs:
- source_labels: [__address__]
regex: "([^:]+):\\d+"
target_label: instance
Testing the configuration
1 Run the following command from the command line:
prometheus.exe [--log.level=debug]
Include --log.level=debug to produce additional logging, for example, to see if requests are failing.
2 Go to the following URL:
http://localhost:9090/
The Prometheus interface appears.
3 Click Status > Targets.
The page displayed shows the configured jobs with the correct endpoint for each job. The status of each endpoint is “Up”.
Running Prometheus as a service
One way of running Prometheus as a service is by using NSSM.
1 Download NSSM from the following location:
https://nssm.cc/download
2 Extract the 64-bit nssm.exe to a folder, for example: C:\Monitoring.
3 Run the following commands:
nssm install Prometheus C:\Monitoring\prometheus-2.45.3.windows-amd64\prometheus.exe
nssm.exe set Prometheus AppStdout C:\Monitoring\prometheus-2.45.3.windows-amd64\logs\std_out.log
nssm.exe set Prometheus AppStdoutCreationDisposition 2
nssm.exe set Prometheus AppStderr C:\Monitoring\prometheus-2.45.3.windows-amd64\logs\std_err.log
nssm.exe set Prometheus AppStderrCreationDisposition 2
nssm.exe set Prometheus Description Time series database of application metrics
nssm.exe set Prometheus ObjectName .\RunningUser RunningUserPassword
4 Use the Window services control panel to start the service.
5 Go to the following URL:
http://localhost:9090/
The Prometheus interface appears.
Prometheus retrieves the metrics from each endpoint at a rate which is determined by its “scrape interval”; the default value is 15 seconds. The metrics are stored and can be queried later.
Querying the metrics
The queries are usually executed by another tool, for example Grafana (see Using Grafana), to retrieve data for display. You can also execute queries by using the Prometheus web interface.
1 In the Prometheus web interface, click the Open metrics explorer icon.
The Metrics Explorer displays a list of all metrics that have been read by Prometheus. The Web API metrics are near the end of the list. The metrics that are included depend on the Web API requests that have been made and which metrics have been collected.
webapi_application_heartbeat_duration
Indicates whether reporting is working properly. Every 10 seconds, the Web API runs a timer for 100ms, and then records how long the timer took: it should be slightly more than 100ms.
webapi_application_heartbeat_duration_sum
The sum (in seconds) of the periods that have been timed.
webapi_application_heartbeat_duration_count
The number of periods that have been timed.
2 To display each “sum” value that Prometheus has captured for the last 5 minutes, enter the following query:
webapi_application_heartbeat_duration_sum[5m]
Prometheus should have captured a value every 15 seconds.
3 To display the number of times the heartbeat event has occurred, enter the following query:
webapi_application_heartbeat_count[5m]
The count usually increases by 1 between each scrape, because the heartbeat interval is 10 seconds and the Prometheus scape interval is 15 seconds; sometimes, it might increase by 2.
4 To calculate the change in the total over a 5 minute period, enter the following query:
rate(webapi_application_heartbeat_duration_sum[5m])/rate(webapi_application_heartbeat_duration_count[5m])
The “rate” function calculates the change in a value over the specified period. This query calculates the sum of each heartbeat length over a 5 min period divided by the number of heartbeats that have occurred.
The result should be slightly more than 0.1 (seconds; that is, 100ms).
For more information about using “sum” and “count”, see the Prometheus documentation at: https://prometheus.io/docs/practices/histograms/.
See also
Using Grafana
Monitoring the system by using Prometheus and Grafana