Using Grafana
The Grafana application creates dashboards of Prometheus data, such as the application metrics that are configured in
Installing and configuring Prometheus.
The following instructions are for the standalone ZIP installation, which enables Grafana to be installed next to Prometheus, and using the same copy of NSSM as Prometheus.
1 Download Grafana from the following location:
https://grafana.com/grafana/download
2 Extract the contents of the ZIP file to a folder, for example: C:\Monitoring\grafana-v10.3.3.
3 In the conf folder, copy the sample.ini file, and then change its name to custom.ini.
4 Using the same NSSM instance as Prometheus, run the following commands:
nssm install Grafana C:\Monitoring\grafana-v10.3.3\bin\grafana-server.exe
nssm set Grafana AppDirectory C:\Monitoring\grafana-v10.3.3
nssm set Grafana Description Grafana dashboard server
nssm set Grafana AppEnvironmentExtra LOG_LEVEL=DEBUG
nssm set Grafana AppRotateBytes 104857600
nssm set Grafana AppRotateFiles 1
nssm set Grafana AppRotateOnline 1
nssm set Grafana AppStderr C:\Monitoring\grafana-v10.3.3\logs\grafana-service.log
nssm set Grafana AppStdout C:\Monitoring\grafana-v10.3.3\logs\grafana-service.lognssm set Grafana ObjectName .\RunningUser RunningUserPassword
Configuring Grafana
1 Go to the following URL:
http://localhost:3000
2 Login by using admin as the user name, and admin as the password.
3 Change the password.
4 Configure Prometheus as a data source:
Click Add new connection.
Click Prometheus, and then click Add new data source.
Leave the name as prometheus.
Type the following value in the URL field. You must overtype the value that is shown, even though it is the same.
http://localhost:9090
5 Click Save and Test.
6 Click Explore, and then click Code to change to Code mode.
7 Enter the following text in the main text field:
rate(webapi_application_heartbeat_duration_sum[$__rate_interval]) / rate(webapi_application_heartbeat_duration_count[$__rate_interval])
8 Click Run query.
A chart is displayed with a line that moves up and down around a value of about 0.1.
9 Click Add to dashboard, leave it set to New dashboard, and then click Open dashboard.
10 To add more charts, click Add > Visualization.
Accessing Grafana by using Microsoft IIS
If you need to make Grafana publicly accessible so that it can be used with UNICOM Interview Server Administration, complete the following steps. For more information, see
https://grafana.com/tutorials/iis/.
1 Edit the custom.ini file which is in C:\Monitoring\grafana-9.2.3\conf, and then set the following properties:
domain = <domain_name>
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana
(assuming that Grafana is being served from a “grafana” subpath.)
2 Download the IIS URL Rewrite extension from the following location, and then install it:
https://www.iis.net/downloads/microsoft/url-rewrite
3 Download the IIS Application Request Routing extension from the following location, and then install it:
https://www.iis.net/downloads/microsoft/application-request-routing
4 If Microsoft IIS Manager is open, restart it to display the new extensions.
5 In Microsoft IIS Manager, open Application Request Routing, click Server Proxy Settings.
6 Select Enable proxy and Include TCP port from client IP, and then click Apply.
7 Open “URL Rewrite”, and then add a new blank rule:
a Enter the following pattern:
grafana(/)?(.*)
This pattern assumes that you want a subpath of grafana.
b Select Ignore case.
c Set Rewrite URL to http://localhost:3000/{R:2}
d Select Append query string and Stop processing of subsequent rules.
8 Run the following command:
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost
9 Restart Microsoft IIS.
10 Go to the following URL to make sure that you can access Grafana:
http://<public_hostname>/grafana
See also