Log Service allows you to collect various types of Prometheus metrics by using a Logtail plug-in. The metrics include Prometheus-format metrics from Node Exporter and Kafka Exporter, and Prometheus metrics collected from applications. This topic describes how to use Logtail to collect metric data from Prometheus.


A project and a Metricstore are created. For more information, see Create a project and Create a Metricstore.


Only Linux Logtail V0.16.66 and later can collect Prometheus metric data. If you have installed an earlier version of Logtail on your server, you must update Logtail to a supported version. For more information, see Update Logtail online.


Important A Logtail plug-in supports only one Logtail configuration for Prometheus at a time. If more than one configuration exists, Logtail uses one of the configurations at random.
  1. Log on to the Log Service console.
  2. In the Import Data section, click the Monitoring Data tab. Then, click Prometheus Metric Scrape.
  3. Select the project and Metricstore and click Next.
  4. Create a machine group.
    • If a machine group is available, click Use Existing Machine Groups.
    • If no machine groups are available, perform the following steps to create a machine group. In this example, an Elastic Compute Service (ECS) instance is used.
      1. On the ECS Instances tab, select Manually Select Instances. Then, select the ECS instance that you want to use and click Create.

        For more information, see Install Logtail on ECS instances.

        Important If you want to collect logs from an ECS instance that belongs to a different Alibaba Cloud account, a server in an on-premises data center, or a server of a third-party cloud service provider, you must manually install Logtail. For more information, see Install Logtail on a Linux server. After you manually install Logtail, you must configure a user identifier for the server. For more information, see Configure a user identifier.
      2. After Logtail is installed, click Complete Installation.
      3. In the Create Machine Group step, configure the Name parameter and click Next.

        Log Service allows you to create IP address-based machine groups and custom identifier-based machine groups. For more information, see Create an IP address-based machine group and Create a custom identifier-based machine group.

  5. Select the new machine group from Source Server Groups and move the machine group to Applied Server Groups. Then, click Next.
    Important If you apply a machine group immediately after you create the machine group, the heartbeat status of the machine group may be FAIL. This issue occurs because the machine group is not connected to Log Service. To resolve this issue, you can click Automatic Retry. If the issue persists, see What do I do if no heartbeat connections are detected on Logtail?
  6. In the Specify Data Source step, configure Config Name and Plug-in Config. Then, click Next.
    Plug-in Config includes inputs and processors. Log Service provides a template for inputs. The template includes only the global and scrape_configs sections.
    • inputs is required and is used to configure the data collection settings for the Logtail configuration.
      • You can configure fields only in the global and scrape_configs sections regardless of whether you collect Prometheus-format metrics or Prometheus metrics. For more information, see Prometheus configuration.
      • You can configure only one type of data source in inputs.
    • processors is optional and is used to configure the data processing settings for the Logtail configuration. For more information, see Append data to a field.
      If you want to append custom fields, such as the IP address of the server on which Logtail is installed and the hostname of the server, to the collected metric data, you must turn on Use Advanced Edit Mode to add processors settings. In this case, the processor_appender plug-in must be used. Example:
            "detail": {
              "Key": "__labels__",
              "Value": "|host#$#{{__host__}}|ip#$#{{__ip__}}",
              "SortLabels": true

What to do next

  • Query and analysis

    After metric data is collected, you can query and analyze the data on the query and analysis page of the Metricstore. For more information, see Query and analyze metric data.

  • Visualization on Log Service

    Log Service automatically creates a host monitoring dashboard in the project. In the dashboard, you can view query and analysis results, configure alerts, and perform other operations. For more information, see Overview.

  • Visualization on Grafana

    Log Service allows you to send metric data to Grafana for visualization. For more information, see Send time series data from Log Service to Grafana.