Import PBX Data from a Database into Grafana

When PBX data is synchronized to a third-party database, you can add the database as a data source in Grafana, then use the Yeastar-provided dashboard template to import and visualize your data on Grafana.

Requirements

Platform Requirement
Grafana An account with Organization administrator role.
Third-party Database
  • Version: The database version is supported by Grafana.
  • Network: The network connectivity between database and Grafana is established.
  • Account: An account with read-only access (SELECT permissions) on the required schemas and tables.
    Note: Grafana does not validate the safety of queries, so users could run potentially harmful SQL. We recommend that you create a dedicated user with restricted permissions to limit risk.

Prerequisites

You have synchronized PBX data to a third-party database.

Procedure

Note: This topic takes PostgreSQL as an example to demonstrate how to import PBX data from a PostgreSQL-compatible database into Grafana. For Microsoft SQL and MySQL, the operations are basically the same.

Step 1. Connect Grafana to database

  1. Log in to Grafana portal, go to Connections > Add new connection.

  2. Add a data source.
    1. Search for the target database type and select it from the list of available data sources.

      In this example, select PostgreSQL data source.

    2. At the top-right corner, click Add new data source.

  3. Fill in the following information to connect to the database.
    1. In the Connection section, fill in the database connection information.
      Item Description
      Host URL Enter the IP address or domain name of the host on which the database is installed, as well as the database port.
      Database name Enter the name of the database.
    2. In the Authentication section, fill in the authentication information.
      Item Description
      Username Enter the username used to connect to the database.
      Password Enter the password used to connect to the database.
  4. Optional: Configure additional settings as needed.
  5. Scroll down to the bottom of the page, click Save & test to test and save the data source connection.

    If "Database Connection OK" is displayed, it indicates that the connection to the database is successful.

Step 2. Import a dashboard from the database using a template

  1. In the browser's address bar, copy the data source UID (the last segment of the URL) for template configuration.

    In this example, the value we retrieve is bfkbvupmpwe0wb.

  2. Download and update the dashboard JSON template.
    1. Download and unzip the dashboard template package, which includes templates for different databases, and select the appropriate one based on your database.

      In this example, we will use the template for PostgreSQL.

    2. Replace all uid values under datasource in each panel with the retrieved values.

      Note: Leave the uid values in annotations and dashboard settings unchanged.

    3. Optional: Update the title value, which will be used as the dashboard name in Grafana.

  3. Import the dashboard template to Grafana.
    1. On the left navigation bar, click Dashboards.
    2. At the top-right corner, click and select Import dashboard.

    3. Click Upload dashboard JSON file and upload the .json file.
    4. Click Import.

Result

The dashboard is successfully imported and data is visualized in the Dashboard.

What to do next

Add or modify the SQL queries to customize the data to be displayed.
Note: By default, the Yeastar-provided dashboard template for Grafana displays data only for the following call reports, as Grafana dashboard doesn't support incorporating multiple queries from a single source.
  • Extension Call Accounting

  • Extension Call Accounting Details

  • AI Receptionist Call Activity

  • Agent Missed Call Activity

  • Queue Callback Activity

  • Satisfaction Survey

  • Satisfaction Survey Details

  • IVR Report

  • DID/Outbound Caller ID Activity

To display additional call reports, you can add SQL queries as needed. Refer to Call Report Calculations with Multiple SQL Queries for more details on the related data logic.