You can install a virtual private cloud (VPC) data channel in Grafana Service. This way, the Grafana workspace can access a data source in a VPC that is inaccessible over the Internet. This topic describes how to use a VPC data channel to allow Grafana Service to access a VPC data source. A self-managed Prometheus data source in a VPC is used in this example.
A VPC may be inaccessible over the Internet for the following reasons:
- Security: Exposure to the Internet increases the risk of attacks.
- Costs: You must pay for elastic IP addresses (EIPs).
The VPC data channel management feature of Grafana Service is applicable to scenarios in which you want to display data sources that you do not want to expose to the Internet or multiple VPC data sources in the same Grafana workspace.
(Optional) Step 1: Install a Prometheus data source in a VPC
If your VPC contains a data source, skip this step.
In this example, a Prometheus data source is installed on an Elastic Compute Service (ECS) instance. You can install other data sources in the ECS instance based on your business requirements.
- Log on to an ECS instance in the VPC.
- Run the following command 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 # Decompress the Prometheus installation package. tar -zxvf prometheus-2.8.1.linux-amd64.tar.gz -C /usr/local/ # Rename the folder in which the installation package resides. cd /usr/local mv prometheus-2.8.1.linux-amd64/ prometheus cd prometheus/ # Check the Prometheus version. ./prometheus --version # Modify the prometheus.yml configuration file based on your business requirements. If you want only to test the VPC management feature of Grafana, you can skip this step. # Start Prometheus. ./prometheus &
- Access Prometheus by using the following endpoint.
http://[Public IP address of the ECS instance]:9090/graph
upmetric in Prometheus. If the following page is displayed, Prometheus is installed.Note The
job="prometheus"is a metric that Prometheus uses to monitor its own performance.
Step 2: Manage VPC data channels
- Log on to the ARMS console .
- In the left-side navigation pane, choose .
- On the Workspace management page, click the ID of the workspace that you want to manage or click Management in the Operation column.
- In the left-side navigation pane, click VPC Data Source Channel Management.
- On the VPC Data Source Channel Management page, click Install Data Source Channel.
- In the Install Data Source Channel dialog box, specify the region, VPC ID, VPC name, vSwitch, and security group of
the data source, and then click Install.
After the data channel is installed, you can view the data channel on the VPC Data Source Channel Management page.
Step 3: Add a data source in Grafana
- On the VPC Data Source Channel Management page of Grafana Service, click Configure Data Source to the right of the data channel to go to the Configuration page of Grafana.
- On the Data sources tab of the Configuration page, click Add data source.
- Click Prometheus. Note You can select a data source type based on your business requirements.
- On the Settings page, configure the parameters as required. The URL parameter follows the
[VPC ID]:http://[Primary private IP address of the ECS instance]:9090format. For more information about other parameters, see the Grafana documentation.Note You can view the primary private IP address of an ECS instance on the Instance Details page. For more information, see the ECS documentation.
- Click Save & test. If
Data source is workingappears, the Prometheus data source is added to Grafana.
After you add a VPC data source, you can check whether you can use the data source to configure monitoring metrics on the Explore page of Grafana.
- In the left-side navigation pane of the Grafana console, click the icon.
- Select the data source that you added in Step 3 from the drop-down list at the top of the Explore page.
- In the Metrics section, enter
upand click Run query.If the Prometheus monitoring panel displayed in Grafana is the same as the monitoring panel on the Prometheus page in Step 1, the Prometheus data source is connected.