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.

Background information

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.

  1. Log on to an ECS instance in the VPC.
  2. Run the following command to install Prometheus on the ECS instance:
    # Download the Prometheus installation package. 
    # 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 &
  3. Access Prometheus by using the following endpoint.
    http://[Public IP address of the ECS instance]:9090/graph

    Query the up metric in Prometheus. If the following page is displayed, Prometheus is installed.

    Note The up metric of job="prometheus" is a metric that Prometheus uses to monitor its own performance.
    The Prometheus page

Step 2: Manage VPC data channels

  1. Log on to the ARMS console .
  2. In the left-side navigation pane, choose Grafana service > Workspace management.
  3. On the Workspace management page, click the ID of the workspace that you want to manage or click Management in the Operation column.
  4. In the left-side navigation pane, click VPC Data Source Channel Management.
  5. On the VPC Data Source Channel Management page, click Install Data Source Channel.
  6. 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.
    Install a data channel

    After the data channel is installed, you can view the data channel on the VPC Data Source Channel Management page.

    Prometheus data source

Step 3: Add a data source in Grafana

  1. 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.
  2. On the Data sources tab of the Configuration page, click Add data source.
  3. Click Prometheus.
    Note You can select a data source type based on your business requirements.
  4. 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]:9090 format. 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.
  5. Click Save & test.
    If Data source is working appears, the Prometheus data source is added to Grafana.

Result verification

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.

  1. In the left-side navigation pane of the Grafana console, click the Explore icon.
  2. Select the data source that you added in Step 3 from the drop-down list at the top of the Explore page.
  3. In the Metrics section, enter up and 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. The up metric of Prometheus