All Products
Search
Document Center

Alibaba Cloud Service Mesh:Monitor ASM instances by using a self-managed Prometheus instance

Last Updated:Jan 24, 2024

Prometheus is an open source tool that is used to monitor cloud-native applications. This topic shows you how to deploy a self-managed Prometheus instance to monitor Service Mesh (ASM) instances.

Prerequisites

Step 1: Configure metrics

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the cluster that you want to manage and choose Applications > Helm in the left-side navigation pane.

  3. On the Helm page, find ack-prometheus-operator and click Update in the Actions column.

  4. In the Update Release panel, modify the additionalScrapeConfigs field in the YAML code editor and click OK.

    The YAML file is large. You can press the Ctrl+F keyboard shortcut and then search for the additionalScrapeConfigs field. The following code shows the modified additionalScrapeConfigs field.

    additionalScrapeConfigs:
    # Scrape config for envoy stats
    - job_name: 'envoy-stats'
      metrics_path: /stats/prometheus
      kubernetes_sd_configs:
      - role: pod
      relabel_configs:
      - source_labels: [__meta_kubernetes_pod_container_port_name]
        action: keep
        regex: '.*-envoy-prom'
      - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
        action: replace
        regex: ([^:]+)(?::\d+)?;(\d+)
        replacement: $1:15090
        target_label: __address__
      - action: labeldrop
        regex: __meta_kubernetes_pod_label_(.+)
      - source_labels: [__meta_kubernetes_namespace]
        action: replace
        target_label: namespace
      - source_labels: [__meta_kubernetes_pod_name]
        action: replace
        target_label: pod_name

Step 2: Enable Prometheus

For more information, see Collect metrics to Managed Service for Prometheus.

Step 3: Generate monitoring data

Send requests to services on the data plane. In this example, the Bookinfo application is used. For more information, see Getting started. Go to the Productpage page of Bookinfo. Refresh the page multiple times. 监控数据

Verify the result

Check whether Envoy proxies collect the specified metrics

Run the following command and check the command output. Data in the command output indicates the metric data that is collected by Envoy proxies. If the command output contains no data, Envoy proxies do not collect metric data.

details=$(kubectl get pod -l app=details -o jsonpath={.items..metadata.name})
kubectl exec $details -c istio-proxy -- curl -s localhost:15090/stats/prometheus |grep istio

View the metrics that are monitored by Prometheus

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the cluster that you want to manage and choose Network > Services in the left-side navigation pane.

  3. On the Services page, click the public endpoint of Prometheus in the External IP column.

  4. On the Prometheus page, enter istio_requests_total in the search box and click Execute. The metrics that are monitored by Prometheus are displayed. peomethus

View the Grafana dashboard of the metric data

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the cluster that you want to manage and choose Network > Services in the left-side navigation pane.

  3. On the Services page, click the public endpoint of Grafana in the External IP column.

  4. On the Grafana page, select Istio Workload Dashboard in the upper-left corner. The following figure shows the Grafana dashboard that is displayed. 3