Scenario: Creating a Prometheus REST API Dashboard

You can use the Prometheus REST API Connector that is already provided in Cloud Application Business Insights to connect to a Prometheus System. You can then create a manual data definition to retrieve data from the system and display it on a dashboard.

Use case description

As a dashboard designer, I want to create a custom dashboard to view CPU utilization by an instance for a service at a specific time.

Query used

The dashboard for this use case displays the following data from the Prometheus REST API Service:
  • process_cpu_seconds_total
  • timestamp
To create a dashboard, you need to complete the following tasks:
  1. Configure a Prometheus REST API Service.
  2. Create a manual data definition to query the Prometheus REST API Service.
  3. Create a dashboard that displays the data that is retrieved from the Prometheus REST API Service.

Configuring a Prometheus REST API Service

Complete the following steps to configure a Prometheus service named Prometheus_service:
  1. Access the Dashboard Designer tool.

    For more information, see Accessing the IBM Cloud Application Business Insights web interface.

  2. Configure the Prometheus REST API Service.

    For example, create Prometheus_service Connector Source.

    Use the following information to create the Prometheus_service Connector Source:
    Fields Value
    Connector Type Prometheus
    Connector Source Name Prometheus_service
    Endpoint URL https://server_IP_or_HOSTNAME:port

    Or

    http://server_IP_or_HOSTNAME:port

    Where:
    • server_IP_or_HOSTNAME is the IP address or hostname of the server where the REST API service is hosted.
    • port is the default port for the REST API service. The default port is 9090.
    Authentication type Select Basic Authentication

    Select None, if username and password were not configured during the REST API service installation.

    User Name Username to access the Prometheus REST API service.
    Password Password to access the Prometheus REST API service.
  3. Click Next.
  4. From the Method list, select a GET method, and in the URI field, enter the uniform resource identified (URI) for the source:

    For example, /api/v1/query_range?query=go_memstats_alloc_bytes&start=2019-07-04T08:00:19.699Z&end=2019-07-04T18:30:19.699Z&step=5m

    The URI must contain the metric name and the start and end time in Universal Time Coordinated (UTC) format or Epoch format. For more information about URI formats, see https://prometheus.io/docs/prometheus/latest/querying/api/.

  5. To make sure that the connection to the data source is successful, click Test Connection.

    If the source details and the sample request are valid and complete, then a message indicating that the connection is successful is displayed.

    For more information, see Configuring Prometheus Connector Sources.

  6. Click Save.

Creating a manual data definition

Complete the following steps to create a manual data definition named Prometheus_query for Prometheus_service:
  1. In the navigation pane of Dashboard Designer, click Data Definition > Custom > Create New Data Definition.

    The New Data Definition tab opens.

  2. Create a manual data definition, Prometheus_query for Prometheus_service.
    Use the following information to create Prometheus_query for Prometheus_service connector source:
    Field Value
    Connector Type Prometheus
    Connector Source Name Prometheus_service
    Method GET
    URI /api/v1/query_range?query=process_cpu_seconds_total&start=2019-07-04T08:00:19.699Z&end=2019-07-04T18:30:19.699Z&step=5m
  3. To view and validate the response received from the manual data definition that you created, click the Preview Preview icon.

    The response from the manual data definitions is displayed in a tabular format. You need the column names to define chart properties when you create a dashboard.

  4. Save the manual data definition as Prometheus_query.

Creating a dashboard

Complete the following steps to create a dashboard named Prometheus:

  1. In the navigation pane of Dashboard Designer, click Dashboards, and then click Create New Dashboard.
  2. In the Create a New Dashboard: Select a layout window, click a 1x1 layout, and then click Select.

    For more information, see Layouts.

  3. In the navigation pane of Dashboard Designer, click Chart, and drag a Clustered Columns chart to the widget or chart area.

    For more information about the various chart types, see Charts.

  4. Click the Set Data Definition Set Data Definition icon icon
  5. In the Set Data Definition window, click Select from saved Data Definition, and then click Continue.
  6. In the Set Data Definition window, click Prometheus_query that is listed under Data Definition (select one or more) pane, and click Move to selected Move to selected icon to add the data definition to Selected Data Definition pane.
  7. Click the Set Properties Set Properties icon icon.
  8. In the Set Properties window, click Series. In the Series Type tab, click Define a Dynamic Series.
  9. Click the Series tab, and enter a column name that is displayed in the manual data definition preview.
    For example,
    • In the X-axis Labels field, enter timestamp.
    • In the Y-axis Values field, enter process_cpu_seconds_total.
    • In the Legends field, enter instance
    Note:
  10. To save the dashboard, click Save. Save the dashboard as Prometheus.
  11. Build a menu and add the dashboard to the menu by using the following tasks:
    1. From the navigation pane, click Menu Access > Create New Menu.
    2. Enter the name for the first menu. For example, Prometheus_menu1.
    3. Right-click Prometheus_menu1 and select Add Child.
    4. Click the Dashboard dashboard icon icon and drag Prometheus dashboard that you created from the list on the Dashboard tab, which is on the right of the window.
    5. Click the User Groups tab and assign the user groups who can view this dashboard.
    6. Save and publish the dashboard.

      For more information, see Menu Access.

  12. Access the Engine user interface.
  13. Go to Promethus_menu1 > Prometheus to view your dashboard.