Grafana connection
This topic shows you how to connect an AnalyticDB for PostgreSQL instance to Grafana for visual analysis.
Prerequisites
A Grafana service is required. You can quickly create a Grafana service on Alibaba Cloud.
Procedure
-
Log on to the Managed Service for Grafana console.
-
In the left-side navigation pane, under Grafana Service, click Workspace Management. Then, click the ID of your target workspace.
-
On the Workspace Management page, copy the Public IP Address or Private IP Address of Grafana and add it to the whitelist of the AnalyticDB for PostgreSQL instance to access the AnalyticDB for PostgreSQL instance. For more information, see Configure a whitelist. This example uses a public IP address to connect.
-
On the Workspace Management page, click Public Endpoint to access Grafana.
NoteLog on to Grafana with the Admin account and password you set when you created the workspace.
-
In the left-side navigation pane of Grafana, click the
icon and choose Data Source. -
Click Add data source, and then select PostgreSQL.
-
Enter the connection information. The following table describes the parameters.
Parameter
Description
Name
A display name for this data source.
Network type
The network type (public or private).
Host
The endpoint of the AnalyticDB for PostgreSQL instance. The format is
<host>:<port>. Example:gp-bp10vkbe1x1v3h****-master.gpdb.rds.aliyuncs.com:5432.Database
The name of the AnalyticDB for PostgreSQL database.
User
The username for the AnalyticDB for PostgreSQL database account.
Password
The password for the AnalyticDB for PostgreSQL database account.
TLS/SSL mode
Select disable. You can also configure this setting as needed.
Version
Select PostgreSQL version 9.4.
Other parameters
For descriptions of other parameters, see the Grafana PostgreSQL data source documentation.
-
At the bottom of the page, click Save & Test.
If the page displays
Database Connection OK, the connection is successful. -
You can now analyze your data in Grafana. For more information, see the Grafana getting started documentation.
In the Grafana panel editor, select PostgreSQL as the data source and configure the query. In the FROM section, select a data table, set Time column to
time, and set Metric column tonone. In the SELECT section, set Column tovalue. In the WHERE section, use the$_timeFiltermacro. For Format as, select Time series. After completing the configuration, the panel displays a time series line chart.