Chapter 8. Setting up graphical representation of PCP metrics


Using a combination of pcp, grafana, valkey, pcp bpftrace, and pcp vector provides graphical representation of the live data or data collected by PCP.

8.1. Setting up PCP with pcp-zeroconf

You can set up PCP on a system with the pcp-zeroconf package. Once the pcp-zeroconf package is installed, the system records the default set of metrics into archived files.

Procedure

  • Install the pcp-zeroconf package:

    # dnf install pcp-zeroconf
    Copy to Clipboard Toggle word wrap

Verification

  • Ensure that the pmlogger service is active, and starts archiving the metrics:

    # pcp | grep pmlogger
    pmlogger: primary logger: /var/log/pcp/pmlogger/localhost.localdomain/20200401.00.12
    Copy to Clipboard Toggle word wrap

8.2. Setting up a grafana-server

Grafana generates graphs that are accessible from a browser. The grafana-server is a back-end server for the Grafana dashboard. It listens, by default, on all interfaces, and provides web services accessed through the web browser. The grafana-pcp plugin interacts with the pmproxy daemon in the backend.

Prerequisites

Procedure

  1. Install the following packages:

    # dnf install grafana grafana-pcp
    Copy to Clipboard Toggle word wrap
  2. Restart and enable grafana-server:

    # systemctl restart grafana-server
    # systemctl enable grafana-server
    Copy to Clipboard Toggle word wrap
  3. Open the server’s firewall for network traffic to the Grafana service.

    # firewall-cmd --permanent --add-service=grafana
    success
    # firewall-cmd --reload
    success
    Copy to Clipboard Toggle word wrap

Verification

  • Ensure that the grafana-server is listening and responding to requests:

    # ss -ntlp | grep 3000
    LISTEN  0  128  :3000 *:  users:(("grafana-server",pid=19522,fd=7))
    Copy to Clipboard Toggle word wrap
  • Ensure that the grafana-pcp plugin is installed:

    # grafana-cli plugins ls | grep performancecopilot-pcp-app
    performancecopilot-pcp-app @ 5.2.2
    Copy to Clipboard Toggle word wrap

8.3. Configuring valkey

You can use the valkey data source to:

  • View data archives
  • Query time series using pmseries language
  • Analyze data across multiple hosts

Prerequisites

Procedure

  1. Install the valkey package:

    # dnf install valkey
    Copy to Clipboard Toggle word wrap
  2. Start and enable the pmproxy and valkey services:

    # systemctl start pmproxy valkey
    # systemctl enable pmproxy valkey
    Copy to Clipboard Toggle word wrap
  3. Restart grafana-server:

    # systemctl restart grafana-server
    Copy to Clipboard Toggle word wrap

Verification

  • Ensure that the pmproxy and valkey are working:

    # pmseries disk.dev.read
    2eb3e58d8f1e231361fb15cf1aa26fe534b4d9df
    Copy to Clipboard Toggle word wrap

    This command does not return any data if the valkey package is not installed.

    For more information, see the pmseries(1) man page on your system.

8.4. Accessing the Grafana web UI

You can access the Grafana web interface. Using the Grafana web interface, you can:

  • add Valkey, PCP bpftrace, and PCP Vector data sources
  • create a dashboard
  • view an overview of any useful metrics
  • create alerts in Valkey

Prerequisites

Procedure

  1. On the client system, open a browser and access the grafana-server on port 3000 by using the http://192.0.2.0:3000 link.

    Replace 192.0.2.0 with your machine IP when accessing Grafana web UI from a remote machine, or with localhost when accessing the web UI locally.

  2. For the first login, enter admin in both the Email or username and Password fields.
  3. Grafana prompts to set a New password to create a secured account. If you want to set it later, click Skip.
  4. From the hamburger icon (☰) on the top left, click Administration > Plugins.
  5. In the Plugins tab, type performance co-pilot in the Search by name or type text box and then click the Performance Co-Pilot (PCP) plugin.
  6. In the Plugins / Performance Co-Pilot pane, click Enable.
  7. Click the Grafana icon. The Grafana Home page is displayed.

    Figure 8.1. Home Dashboard

    Note

    The top corner of the screen has a Settings icon, but it controls the general Dashboard settings.

  8. In the Grafana Home page, click Add your first data source to add Valkey, PCP bpftrace, and PCP Vector data sources.

  9. Optional: From the menu, hover over the admin profile icon to change the Preferences including Edit Profile, Change Password, or to Sign out.

    For more information, see the grafana-cli and grafana-server man pages on your system.

You can establish secure connections between Performance Co-Pilot (PCP), Grafana, and Valkey. Establishing secure connections between these components helps prevent unauthorized parties from accessing or modifying the data being collected and monitored.

Prerequisites

  • PCP is installed. For more information, see Installing and enabling PCP.
  • The Grafana server is configured. For more information, see Setting up a grafana-server.
  • Valkey is installed. For more information, see Configuring Valkey.
  • The private client key is stored in the /etc/valkey/client.key file. If you use a different path, modify the path in the corresponding steps of the procedure. For details about creating a private key and certificate signing request (CSR), as well as how to request a certificate from a certificate authority (CA), see your CA’s documentation.
  • The TLS client certificate is stored in the /etc/valkey/client.crt file. If you use a different path, modify the path in the corresponding steps of the procedure.
  • The TLS server key is stored in the /etc/valkey/valkey.key file. If you use a different path, modify the path in the corresponding steps of the procedure.
  • The TLS server certificate is stored in the /etc/valkey/valkey.crt file. If you use a different path, modify the path in the corresponding steps of the procedure.
  • The CA certificate is stored in the /etc/valkey/ca.crt file. If you use a different path, modify the path in the corresponding steps of the procedure.
  • For the pmproxy daemon, the private server key is stored in the /etc/pcp/tls/server.key file. If you use a different path, modify the path in the corresponding steps of the procedure.

Procedure

  1. As a root user, open the /etc/valkey/valkey.conf file and adjust the TLS/SSL options to reflect the following properties:

    port 0
    tls-port 6379
    tls-cert-file /etc/valkey/valkey.crt
    tls-key-file /etc/valkey/valkey.key
    tls-client-key-file /etc/valkey/client.key
    tls-client-cert-file /etc/valkey/client.crt
    tls-ca-cert-file /etc/valkey/ca.crt
    Copy to Clipboard Toggle word wrap
  2. Ensure valkey can access the TLS certificates:

    # su valkey -s /bin/bash -c \
      'ls -1 /etc/valkey/ca.crt /etc/valkey/valkey.key /etc/valkey/valkey.crt'
    /etc/valkey/ca.crt
    /etc/valkey/valkey.crt
    /etc/valkey/valkey.key
    Copy to Clipboard Toggle word wrap
  3. Restart the valkey server to apply the configuration changes:

    # systemctl restart valkey
    Copy to Clipboard Toggle word wrap

Verification

  • Confirm the TLS configuration works:

    # valkey-cli --tls --cert /etc/valkey/client.crt \
        --key /etc/valkey/client.key \
        --cacert /etc/valkey/ca.crt <<< "PING"
    PONG
    Unsuccessful TLS configuration might result in the following error message:
    Could not negotiate a TLS connection: Invalid CA Certificate File/Directory
    Copy to Clipboard Toggle word wrap

After adding the PCP Valkey data source, you can view the dashboard with an overview of useful metrics, add a query to visualize the load graph, and create alerts that help you to view the system issues after they occur.

Prerequisites

Procedure

  1. Log into the Grafana web UI.
  2. In the Grafana Home page, click Add your first data source.
  3. In the Add data source pane, type valkey in the Filter by name or type text box and then click Valkey.
  4. In the Data Sources / Valkey pane, perform the following:

    1. Add http://localhost:44322 in the URL field and then click Save & Test.
    2. Click Dashboards tab > Import > Valkey: Host Overview to see a dashboard with an overview of any useful metrics.

      Figure 8.2. Valkey: Host Overview

  5. Add a new panel:

    1. From the menu, hover over the Create icon > Dashboard > Add new panel icon to add a panel.
    2. In the Query tab, select the Valkey from the query list instead of the selected default option and in the text field of A, enter metric, for example, kernel.all.load to visualize the kernel load graph.
    3. Optional: Add Panel title and Description, and update other options from the Settings.
    4. Click Save to apply changes and save the dashboard. Add Dashboard name.
    5. Click Apply to apply changes and go back to the dashboard.

      Figure 8.3. Valkey query panel

  6. Create an alert rule:

    1. In the Valkey query panel, click Alert and then click Create Alert.
    2. Edit the Name, Evaluate query, and For fields from the Rule, and specify the Conditions for your alert.
    3. Click Save to apply changes and save the dashboard. Click Apply to apply changes and go back to the dashboard.

      Figure 8.4. Creating alerts in the Valkey panel

    4. Optional: In the same panel, scroll down and click Delete icon to delete the created rule.
    5. Optional: From the menu, click Alerting icon to view the created alert rules with different alert statuses, to edit the alert rule, or to pause the existing rule from the Alert Rules tab. To add a notification channel for the created alert rule to receive an alert notification from Grafana, see Adding notification channels for alerts.

8.7. Adding notification channels for alerts

By adding notification channels, you can receive an alert notification from Grafana whenever the alert rule conditions are met and the system needs further monitoring. You can receive these alerts after selecting any one type from the supported list of notifiers, which includes DingDing, Discord, Email, Google Hangouts Chat, HipChat, Kafka REST Proxy, LINE, Microsoft Teams, OpsGenie, PagerDuty, Prometheus Alertmanager, Pushover, Sensu, Slack, Telegram, Threema Gateway, VictorOps, and webhook.

Prerequisites

  • The grafana-server is accessible. For more information, see Accessing the Grafana web UI.
  • An alert rule is created. For more information, see Creating panels and alerts in PCP valkey data source.
  • Configure SMTP and add a valid sender’s email address in the grafana/grafana.ini file:

    # vi /etc/grafana/grafana.ini
    [smtp]
    enabled = true
    from_address = abc@gmail.com
    Copy to Clipboard Toggle word wrap

    Replace abc@gmail.com by a valid email address.

    Restart grafana-server

    # systemctl restart grafana-server.service
    Copy to Clipboard Toggle word wrap

Procedure

  1. From the menu, hover over the Alerting icon > click Notification channels > Add channel.
  2. In the Add notification channel details pane, perform the following:

    1. Enter your name in the Name text box.
    2. Select the communication Type, for example, Email and enter the email address. You can add multiple email addresses using the ; separator.
    3. Optional: Configure Optional Email settings and Notification settings.
  3. Click Save.
  4. Select a notification channel in the alert rule:

    1. From the menu, hover over the Alerting icon and then click Alert rules.
    2. From the Alert Rules tab, click the created alert rule.
    3. On the Notifications tab, select your notification channel name from the Send to option, and then add an alert message.
  5. Click Apply.

You can set up authentication using the scram-sha-256 authentication mechanism, which is supported by PCP through the Simple Authentication Security Layer (SASL) framework.

Procedure

  1. Install the SASL framework for the scram-sha-256 authentication mechanism:

    # dnf install cyrus-sasl-scram cyrus-sasl-lib
    Copy to Clipboard Toggle word wrap
  2. Specify the supported authentication mechanism and the user database path in the pmcd.conf file:

    # vi /etc/sasl2/pmcd.conf
    mech_list: scram-sha-256
    sasldb_path: /etc/pcp/passwd.db
    Copy to Clipboard Toggle word wrap
  3. Create a new user:

    # useradd -r metrics
    Copy to Clipboard Toggle word wrap

    Replace metrics by your user name.

  4. Add the created user in the user database:

    # saslpasswd2 -a pmcd metrics
    Password:
    Again (for verification):
    Copy to Clipboard Toggle word wrap

    To add the created user, it is required to enter the metrics account password.

  5. Set the permissions of the user database:

    # chown root:pcp /etc/pcp/passwd.db
    # chmod 640 /etc/pcp/passwd.db
    Copy to Clipboard Toggle word wrap
  6. Restart the pmcd service:

    # systemctl restart pmcd
    Copy to Clipboard Toggle word wrap

Verification

  • Verify the SASL configuration:

    # pminfo -f -h "pcp://127.0.0.1?username=metrics" disk.dev.read
    Password:
    disk.dev.read
    inst [0 or "sda"] value 19540
    Copy to Clipboard Toggle word wrap

8.9. Installing PCP bpftrace

You can install the PCP bpftrace agent to introspect a system and to gather metrics from the kernel and user-space tracepoints. The bpftrace agent uses bpftrace scripts to gather the metrics. The bpftrace scripts use the enhanced Berkeley Packet Filter (eBPF).

Prerequisites

Procedure

  1. Install the pcp-pmda-bpftrace package:

    # dnf install pcp-pmda-bpftrace
    Copy to Clipboard Toggle word wrap
  2. Edit the bpftrace.conf file and add the user that you have created in Setting up authentication between PCP components:

    # vi /var/lib/pcp/pmdas/bpftrace/bpftrace.conf
    [dynamic_scripts]
    enabled = true
    auth_enabled = true
    allowed_users = root,metrics
    Copy to Clipboard Toggle word wrap

    Replace metrics by your user name.

  3. Install bpftrace PMDA:

    # cd /var/lib/pcp/pmdas/bpftrace/
    # ./Install
    Updating the Performance Metrics Name Space (PMNS) ...
    Terminate PMDA if already installed ...
    Updating the PMCD control file, and notifying PMCD …
    Check bpftrace metrics have appeared ... 7 metrics and 6 values
    Copy to Clipboard Toggle word wrap

    The pmda-bpftrace is now installed, and can only be used after authenticating your user. For more information, see Viewing the PCP bpftrace System Analysis dashboard.

Using the PCP bpftrace data source, you can access the live data from sources which are not available as normal data from the pmlogger or archives. In the PCP bpftrace data source, you can view the dashboard with an overview of useful metrics.

Prerequisites

Procedure

  1. Log into the Grafana web UI.
  2. In the Grafana Home page, click Add your first data source.
  3. In the Add data source pane, type bpftrace in the Filter by name or type text box and then click PCP bpftrace.
  4. In the Data Sources / PCP bpftrace pane, perform the following:

    1. Add http://localhost:44322 in the URL field.
    2. Toggle the Basic Auth option and add the created user credentials in the User and Password field.
    3. Click Save & Test.

      Figure 8.5. Adding PCP bpftrace in the data source

    4. Click Dashboards tab > Import > PCP bpftrace: System Analysis to see a dashboard with an overview of any useful metrics.

      Figure 8.6. PCP bpftrace: System Analysis

8.11. Installing PCP Vector

You must install pcp vector before you start using it.

Prerequisites

Procedure

  • Install the bcc PMDA:

    # cd /var/lib/pcp/pmdas/bcc
    # ./Install
    [Wed Apr  1 00:27:48] pmdabcc(22341) Info: Initializing, currently in 'notready' state.
    [Wed Apr  1 00:27:48] pmdabcc(22341) Info: Enabled modules:
    [Wed Apr  1 00:27:48] pmdabcc(22341) Info: ['biolatency', 'sysfork',
    [...]
    Updating the Performance Metrics Name Space (PMNS) ...
    Terminate PMDA if already installed ...
    Updating the PMCD control file, and notifying PMCD …
    Check bcc metrics have appeared ... 1 warnings, 1 metrics and 0 values
    Copy to Clipboard Toggle word wrap

8.12. Viewing the PCP Vector Checklist

The PCP Vector data source displays live metrics and uses the pcp metrics. It analyzes data for individual hosts. After adding the PCP Vector data source, you can view the dashboard with an overview of useful metrics and view the related troubleshooting or reference links in the checklist.

Prerequisites

Procedure

  1. Log into the Grafana web UI.
  2. In the Grafana Home page, click Add your first data source.
  3. In the Add data source pane, type vector in the Filter by name or type text box and then click PCP Vector.
  4. In the Data Sources / PCP Vector pane, perform the following:

    1. Add http://localhost:44322 in the URL field and then click Save & Test.
    2. Click Dashboards tab > Import * PCP Vector: Host Overview to see a dashboard with an overview of any useful metrics.

      Figure 8.7. PCP Vector: Host Overview

  5. From the menu, hover over the Performance Co-Pilot plugin and then click PCP Vector Checklist.

    In the PCP checklist, click help or warning icon to view the related troubleshooting or reference links.

    Figure 8.8. Performance Co-Pilot / PCP Vector Checklist

8.13. Using heatmaps in Grafana

You can use heatmaps in Grafana to view histograms of your data over time, identify trends and patterns in your data, and see how they change over time. Each column within a heatmap represents a single histogram with different colored cells representing the different densities of observation of a given value within that histogram.

Prerequisites

Procedure

  1. Hover the cursor over the Dashboards tab and click + New dashboard.
  2. In the Add panel menu, click Add a new panel.
  3. In the Query tab:

    1. Select Valkey from the query list instead of the selected default option.
    2. In the text field of A, enter a metric, for example, kernel.all.load to visualize the kernel load graph.
  4. Click the visualization dropdown menu, which is set to Time series by default, and then click Heatmap.
  5. Optional: In the Panel Options dropdown menu, add a Panel Title and Description.
  6. In the Heatmap dropdown menu, under the Calculate from data setting, click Yes.

    Figure 8.9. Heatmap

  7. Optional: In the Colors dropdown menu, change the Scheme from the default Orange and select the number of steps (color shades).
  8. Optional: In the Tooltip dropdown menu, under the Show histogram (Y Axis) setting, click the toggle to display a cell’s position within its specific histogram when hovering your cursor over a cell in the heatmap. For example:

    Show histogram (Y Axis) cell display

8.14. Managing SELinux booleans for Grafana

The grafana-selinux subpackage includes several SELinux booleans that control Grafana’s access to external services. These booleans are off by default. You can turn them on or off based on your system requirements.

Prerequisites

  • You have installed grafana-selinux subpackage.
  • You have root privileges.

Procedure

  1. View all Grafana-related SELinux booleans:

    # semanage boolean -l | grep grafana
    Copy to Clipboard Toggle word wrap
  2. Enable a SELinux boolean:

    # setsebool [-P] <boolean_name> on
    Copy to Clipboard Toggle word wrap
    • Replace <boolean_name> with the name of the SELinux boolean you want to enable.
    • Use the -P option to make the change persistent across system reboots.
  3. Optional: Turn off any SELinux option:

    # setsebool [-P] <boolean_name> off
    Copy to Clipboard Toggle word wrap

8.15. Troubleshooting Grafana issues

At times, it is necessary to troubleshoot Grafana issues, such as, Grafana does not display any data, the dashboard is black, or similar issues.

Procedure

  • Verify that the pmlogger service is up and running by executing the following command:

    $ systemctl status pmlogger
    Copy to Clipboard Toggle word wrap
  • Verify if files were created or modified to the disk by executing the following command:

    $ ls /var/log/pcp/pmlogger/$(hostname)/ -rlt
    total 4024
    -rw-r--r--. 1 pcp pcp   45996 Oct 13  2019 20191013.20.07.meta.xz
    -rw-r--r--. 1 pcp pcp     412 Oct 13  2019 20191013.20.07.index
    -rw-r--r--. 1 pcp pcp   32188 Oct 13  2019 20191013.20.07.0.xz
    -rw-r--r--. 1 pcp pcp   44756 Oct 13  2019 20191013.20.30-00.meta.xz
    [..]
    Copy to Clipboard Toggle word wrap
  • Verify that the pmproxy service is running by executing the following command:

    $ systemctl status pmproxy
    Copy to Clipboard Toggle word wrap
  • Verify that pmproxy is running, time series support is enabled, and a connection to valkey is established by viewing the /var/log/pcp/pmproxy/pmproxy.log file and ensure that it contains the following text:

    pmproxy(1716) Info: valkey slots, command keys, schema version setup
    Here, 1716 is the PID of pmproxy, which will be different for every invocation of pmproxy.
    Verify if the valkey database contains any keys by executing the following command:
    $ valkey-cli dbsize
    (integer) 34837
    Copy to Clipboard Toggle word wrap
  • Verify if any PCP metrics are in the valkey database and pmproxy is able to access them by executing the following commands:

    $ pmseries disk.dev.read
    2eb3e58d8f1e231361fb15cf1aa26fe534b4d9df
    $ pmseries "disk.dev.read[count:10]"
    2eb3e58d8f1e231361fb15cf1aa26fe534b4d9df
        [Mon Jul 26 12:21:10.085468000 2021] 117971 70e83e88d4e1857a3a31605c6d1333755f2dd17c
        [Mon Jul 26 12:21:00.087401000 2021] 117758 70e83e88d4e1857a3a31605c6d1333755f2dd17c
        [Mon Jul 26 12:20:50.085738000 2021] 116688 70e83e88d4e1857a3a31605c6d1333755f2dd17c
    [...]
    $ valkey-cli --scan --pattern "*$(pmseries 'disk.dev.read')"
    pcp:metric.name:series:2eb3e58d8f1e231361fb15cf1aa26fe534b4d9df
    pcp:values:series:2eb3e58d8f1e231361fb15cf1aa26fe534b4d9df
    pcp:desc:series:2eb3e58d8f1e231361fb15cf1aa26fe534b4d9df
    pcp:labelvalue:series:2eb3e58d8f1e231361fb15cf1aa26fe534b4d9df
    pcp:instances:series:2eb3e58d8f1e231361fb15cf1aa26fe534b4d9df
    pcp:labelflags:series:2eb3e58d8f1e231361fb15cf1aa26fe534b4d9df
    Copy to Clipboard Toggle word wrap
  • Verify if there are any errors in the Grafana logs by executing the following command:

    $ journalctl -e -u grafana-server
    -- Logs begin at Mon 2021-07-26 11:55:10 IST, end at Mon 2021-07-26 12:30:15 IST. --
    Jul 26 11:55:17 localhost.localdomain systemd[1]: Starting Grafana instance...
    Jul 26 11:55:17 localhost.localdomain grafana-server[1171]: t=2021-07-26T11:55:17+0530 lvl=info msg="Starting Grafana" logger=server version=7.3.6 c>
    Jul 26 11:55:17 localhost.localdomain grafana-server[1171]: t=2021-07-26T11:55:17+0530 lvl=info msg="Config loaded from" logger=settings file=/usr/s>
    Jul 26 11:55:17 localhost.localdomain grafana-server[1171]: t=2021-07-26T11:55:17+0530 lvl=info msg="Config loaded from" logger=settings file=/etc/g>
    [...]
    Copy to Clipboard Toggle word wrap
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat