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 create a Logtail configuration in the Log Service console to collect metric data from Prometheus.

Prerequisites

A Metricstore is created. For more information, see Create a Metricstore.

Procedure

Notice A Logtail plug-in supports only one Logtail configuration for Prometheus. 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 Prometheus Metric Scrape.
  3. In the Specify Logstore step, select the project and the Metricstore that you want to use. Then, click Next.
  4. Create a machine group.
    • If a machine group is available, click Using 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 Execute Now.

        For more information, see Install Logtail on ECS instances.

        Note If you use a server in a self-managed cluster or a server on a third-party cloud, you must manually install Logtail V0.16.66 or later on the Linux server. For more information, see Install Logtail on a Linux server.
      2. After Logtail is installed, click Complete Installation.
      3. In the Create Machine Group step, configure Name 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 ID-based machine group.

  5. Select and move the new machine group from Source Server Groups to Applied Server Groups. Then, click Next.
    Notice If you immediately apply a machine group after it is created, the heartbeat status of the machine group may be FAIL. This issue occurs because the machine group is not connected to Log Service. In this case, 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 must configure inputs based on your data source.
      Notice
      • 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.
      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:
      {
        "processors":[
          {
            "type":"processor_appender",
            "detail": {
              "Key": "__labels__",
              "Value": "|host#$#{{__host__}}|ip#$#{{__ip__}}",
              "SortLabels": true
            }
          }
        ]
      }

      For more information, see Append data to a field.

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 time series 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 time series data to Grafana for visualization. For more information, see Send time series data from Log Service to Grafana.