By installing a VPC data channel in Managed Service for Grafana, you can enable a Grafana workspace to access data sources in a VPC that do not have public internet access. This topic uses an example of accessing a self-managed Prometheus data source in a VPC to describe how to use a VPC data channel to allow Managed Service for Grafana to access data sources in a VPC.
-
This document applies only to Grafana workspaces created before September 1, 2023. For workspaces created after this date, see Private domain and whitelist settings.
-
This feature is available in the Grafana Expert and Advanced editions. If you use the Developer edition, you must upgrade to use this feature.
Background
A VPC typically does not have public internet access enabled for the following reasons:
-
Security: Public exposure increases the risk of attacks.
-
Cost: Assigning an elastic IP address incurs additional costs.
The vpc data channel feature of Managed Service for Grafana is ideal when data sources cannot be exposed to the public internet, or when you need to display data from multiple VPCs in a single Grafana workspace.
(Optional) Step 1: Install Prometheus in a VPC
If you already have a data source running in your VPC, you can skip this step.
This section uses Prometheus as an example. You can install other data sources on an ECS instance based on your requirements.
-
Log on to the ECS instance in your VPC.
-
Run the following commands to install Prometheus on the ECS instance.
# Download the Prometheus installation package. wget https://github.com/prometheus/prometheus/releases/download/v2.8.1/prometheus-2.8.1.linux-amd64.tar.gz # Extract the package. tar -zxvf prometheus-2.8.1.linux-amd64.tar.gz -C /usr/local/ # Rename the directory. cd /usr/local mv prometheus-2.8.1.linux-amd64/ prometheus cd prometheus/ # Check the Prometheus version. ./prometheus --version # (Optional) Modify prometheus.yml based on your requirements. You can skip this if you are only testing the VPC data channel feature. # Start Prometheus. ./prometheus & -
Access Prometheus by visiting the following URL in your browser.
http://[ECS public IP address]:9090/graphIn the Prometheus UI, query the
upmetric. If the query returns a result, the installation was successful.NoteThe
upmetric with the labeljob="prometheus"is a default Prometheus self-monitoring metric.The query result should show the value for
up{instance="localhost:9090",job="prometheus"}is 1.
Step 2: Install a VPC data channel
- Log on to the Managed Service for Grafana console. In the left-side navigation pane, click Workspaces.
-
On the Workspace management page, click the ID of your target workspace. In the navigation pane on the left, click VPC data source channel management.
-
On the VPC data source channel management page, click Install Data Source Channel. In the dialog box that appears, enter the region, VPC ID, VPC name, vSwitch, and security group, and then click Install.
After the installation completes, the channel appears on the VPC data source channel management page.
The table lists information about the installed channel, such as VPC, Region, Name, vSwitch, Security group, and Status. When the status changes to Installation successful, you can click Configure Data Source or Uninstall in the Actions column.
Step 3: Add the Prometheus data source
-
On the VPC data source channel management page, locate the target channel and click Configure Data Source in the Actions column. This redirects you to the Grafana configuration page.
-
On the Data sources tab, click Add data source, and then click Prometheus.
NoteYou can select a different data source type based on your setup.
-
On the Prometheus Settings page, configure the parameters.
For Network Type, select the vpc data channel created in Step 2. For the URL parameter, use the format
http://[ECS primary private IP address]:9090. For other parameters, see the official Grafana documentation.NoteYou can find the primary private IP address of your instance on the Instance details page in the ECS console. For more information, see the ECS documentation.
-
Click Save & test.
If the message
Data source is workingappears, it means the Prometheus data source was added successfully.
Verify the connection
After adding the VPC data source, go to the Explore page in Grafana to verify you can query metrics from it.
-
In the navigation pane on the left of the Grafana console, click the Explore
icon. -
From the drop-down list at the top of the Explore page, select the data source you added in Step 3.
-
In the Metrics field, enter
upand then click Run query.If the Grafana panel matches the Prometheus UI panel from Step 1, the Prometheus data source is successfully connected. The query result shows that the value for
up{instance="localhost:9090", job="prometheus"}is 1, which indicates that the Prometheus target instance is running normally. The Graph panel shows a horizontal line stable at 1, and the Table panel displays the corresponding timestamps and metric details.