Device monitoring

You can use Prometheus together with Grafana to monitor devices in Digital Lab, so that you can identify issues as soon as they arise. Metrics currently available for monitoring are device connection status, iOS Thermal state, Android battery health, free disk space, device WiFi connection status and signal strength, and device temperature. This section is relevant only for UFT Digital Lab.

Configure Prometheus and connect to Digital Lab

The following steps explain how to install and configure Prometheus on Windows to work with Digital Lab. For full details about installing, configuring, and using Prometheus refer to the Prometheus documentation.

Install Prometheus:

  1. Download Prometheus for Windows from the Prometheus website.
  2. Run the prometheus.exe file.
    To ensure that Prometheus always starts automatically, run it as a Windows service as follows:
    1. Download and extract the latest NSSM build. NSSM enables regular executables to be created as Windows services.
    2. Add the service by running the following command:
      nssm.exe install Prometheus <path to prometheus.exe>
      Note that the service uses the nssm.exe file when started, so make sure not to move or delete the file after adding the service.

Configure Digital Lab to integrate with Prometheus:

You can manage the metrics of all connected connectors centrally at the server level, by configuring the Digital Lab server for Prometheus. In Administration settings > General, enable the integration with Prometheus.

Alternatively, you can collect metrics only for a specific remote connector.

  1. On the Digital Lab connector, open the metrics-config.properties file for editing. Set the value for METRICS_PROMETHEUS_ENABLE to true and save.

    Default location:
  2. WindowsC:\Program Files\UFT Digital Lab Connector\connector\conf\metrics-config.properties
    Linux /opt/UFTDigitalLab/connector/conf/metrics-config.properties
  3. Set the environment variable:
    Windows: Add a system variable with the name METRICS_PROMETHEUS_ENABLE and set the value to true.
    Linux: Open <path to installation folder>/server/conf/setenv_common.sh (Default /opt/UFTDigitalLab/server/conf/setenv_common.sh) for editing and add the following line:
    export METRICS_PROMETHEUS_ENABLE=true
  4. Restart the connector:

    Windows

    Use the shortcut in the Digital Lab folder on the desktop.

    Linux

    service UFTM restart

Configure Prometheus

  1. On the Prometheus server, open the prometheus.yml file for editing.
  2. If you are managing metrics centrally at the server level, add the following job which includes metrics from all remote connectors:
    - job_name: 'UFTDigitalLab _metrics_central_management'
    scrape_interval: 5s
    metrics_path: /rest/prometheus
    scheme: <http/https>
    static_configs:
    - targets: ['<UFTDigitalLab_server_address>:<UFTDigitalLab_server_port>']

  3. Alternatively, if you are collecting metrics only for a specific connector, you need only add the following job to the scrape_configs section:

    - job_name: 'UFTDigitalLab_remote_connector_metrics''
    scrape_interval: 5s
    metrics_path: /hp4m-connector/rest/prometheus
    scheme: <http/https>
    static_configs:
    - targets: ['<UFTDigitalLab_remote_connector_address>:<UFTDigitalLab_remote_connector_port>']

  4. SSL only. When using a secure connection to Digital Lab with a self-signed certificate, the certificate needs to be imported to your Windows machine so that Prometheus trusts it:
    1. Export the UFT Digital Lab certificate.
      Using Chrome for example, navigate to the Digital Lab console. Click the Not secure or the lock icon in the address bar and select to view the certificate. Go to the Details tab and select Copy to file (use the defaults).
    2. On the Prometheus machine, select to install the certificate file for the Local Machine and in the Trusted Root Certification Authorities.

    3. Open the Windows Services console and restart the Prometheus service. If the service fails to start, run the prometheus.exe file from the command line to view the error.

  5. Verify the Prometheus integration.
    1. Open the Prometheus web interface. The default port is 9090.
    2. Select Status > Targets and make sure that the Digital Lab targets have been added and the State is Up.
    3. Select Graph > scrape_samples_scraped metric and execute. Make sure that the targets expose samples, and that the value for the element of the Digital Lab job is higher than 0.

Configure Grafana and connect to Digital Lab

The following steps explain how to install and configure Grafana to work with Digital Lab. For full details about installing, configuring, and using Grafana refer to the Grafana documentation.

  1. Download and install Grafana for Windows from the Grafana website.
  2. In the Grafana conf folder, copy the sample.ini configuration file and rename the new file custom.ini. By default, the conf file is located in : C:\Program Files\GrafanaLabs\grafana\.

  3. Add Prometheus as a data source.
    1. Open the Grafana web interface. The default port is 3000.
    2. Login with username: admin and password: admin.
    3. Select Configuration > Data Sources > Add data source > Prometheus and provide the URL (e.g. http://localhost: 9090 if running Prometheus and Grafana on the same machine).
    4. Click Save & Test.
  4. Grafana supports different types of notifications. To receive email notifications, add an SMTP (mail) server to the custom.ini file.

    Example: [smtp]

    enabled = true

    host = smtp.swinfra.net:25

    from_address = grafana@microfocus.com

    from_name = Grafana

  5. Add a notification channel to Grafana. If you defined SMTP in the custom.ini file , you can use email for notifications.
    1. Select Alerting > Notification channels. Click Add channel.
    2. In the Notification Channel screen provide a Name (e.g. email), select Email for the Type, and set the other options as preferred. Enter the email address/es and click Save.
  6. Import the preconfigured Digital Lab dashboard.
    1. Download the json file.
    2. To import the file into Grafana, select Create > Import > Upload .json file. Upload the UFTDigitalLab json.file and click Import.
  7. If you configured a notification channel and would like to receive alert notifications, for each of the graphs in the imported dashboard, select Edit > Alert > Notifications > Send to. Select the channel and save the dashboard.

You can now monitor UFT Digital Lab metrics from Grafana.