This topic describes how to connect Grafana to Hologres and analyze data in a visualized manner.
Procedure
Install Grafana.
For more information about how to install Grafana, see Install Grafana.
-
Connect Grafana to Hologres.
-
Log on to Grafana. In the left-side navigation pane, click Add new connection. Then, select Data source and click PostgreSQL.
-
Configure the PostgreSQL Connection settings. Key parameters include Host URL (for example,
localhost:5432), Database name, Username, Password, TLS/SSL Mode (for example,require), and TLS/SSL Method (for example,File system path). In the Additional settings section, select a PostgreSQL version, such as11, from the Version drop-down list.The following table describes the parameters.
Parameter
Description
Host URL
The public endpoint of the Hologres instance. You can find the endpoint in the Network Information section of the instance details page in the Hologres console.
Database name
The name of the Hologres database.
Username
The AccessKey ID of the Alibaba Cloud account. For more information about how to obtain the AccessKey ID, see the "Create an AccessKey pair" section in Create an Alibaba Cloud account.
Password
The AccessKey secret of your Alibaba Cloud account.
TLS/SSL Mode
The mode in which Grafana communicates with the Hologres instance. Configure this parameter based on the Secure Socket Layer (SSL) settings for the public endpoint of the Hologres instance.
Version
The version of PostgreSQL. In this example, select 11.
Other parameters
For more information about other parameters, see Grafana official documentation.
After the parameters are configured, click Save & Test in the lower part. If the
Database Connection OKmessage appears, the connection is valid.
-
-
Analyze data.
You can now use this data source to analyze your data. For details on data analysis, see the official Grafana documentation. In Grafana, create a new dashboard and edit a panel. Select grafana-postgresql-datasource as the data source and set Format to Table. Then, enter the following SQL query:
SELECT l_shipdate as "time", sum(l_quantity) FROM lineitem WHERE $__timeFilter(l_shipdate) GROUP BY l_shipdate ORDER BY 1. Select Time series as the visualization type. The panel then displays a time series line chart showing the quantity of items from thelineitemtable aggregated by shipping date.