Create a custom observability page

Updated at:

The ARMS console fully embraces open source. For highly customized scenarios, such as creating a custom observability dashboard, this topic provides a solution based on Grafana and Prometheus, including examples of how to create custom query statements to retrieve data.

Background information

Alibaba Cloud Managed Service for Prometheus integrates the Application Monitoring data source by default. You can directly use Managed Service for Prometheus to obtain Application Monitoring data, view pre-built dashboards, and further customize it as needed.

Prerequisites

Application Monitoring automatically creates a free Alibaba Cloud Prometheus instance based on the region. As shown in the following figure, all metrics for an application in the China (Hangzhou) region are stored in the arms_metrics_cn-hangzhou_cloud_hangzhou instance under Managed Service for Prometheus for the China (Hangzhou) region.

image

Scenarios

  • You want to create a new dashboard based on metrics from Application Monitoring.

  • During daily O&M, you want to combine metrics from Application Monitoring with metrics from specific components of other data sources to create a custom dashboard.

  • Before traffic peaks, you want to combine metrics from Application Monitoring with metrics from upstream and downstream components of other data sources to create a scenario-specific dashboard.

  • You want to display Application Monitoring data from Managed Service for Prometheus in your self-managed Grafana.

  • You want to use Application Monitoring data from Managed Service for Prometheus for custom development.

Prerequisites

Create a custom dashboard

Step 1: Add the Application Monitoring data source

Since Managed Service for Prometheus integrates the Application Monitoring data source by default, you only need to add the corresponding data source from Managed Service for Prometheus to Grafana.

Self-managed Grafana

  1. Obtain the Prometheus HTTP API.

    1. In the ARMS console, navigate to the Prometheus Monitoring > Instance List page and select the region where your application is deployed from the top navigation bar.

      The default integrated instance for Application Monitoring has the type Prometheus for Application Monitoring.

    2. Click the name of the Application Monitoring instance and then click Settings in the left-side navigation pane to view the HTTP API address.

      In the HTTP API Address (Grafana Read) section, you can obtain public and internal network access addresses. You can also click Generate token to enhance data read security.

    3. (Optional) To enhance the security of data reads from Grafana, click Generate Token to obtain an authentication token for the Prometheus instance.

      Important

      After you generate a token, you must configure it when you add the data source in Grafana. Otherwise, Grafana cannot read the monitoring data from Prometheus.

  2. Add the Prometheus data source in Grafana.

    This example uses Grafana 10.x. For information about how to add a data source in other Grafana versions, see the official Grafana documentation.

    1. Log on to your self-managed Grafana as an administrator.

    2. In the upper-left corner, click the image icon and choose Management > Data Source.

    3. Click + Add new data source and select Prometheus as the data source type.

    4. On the Settings tab, enter a custom name in the Name field. In the Prometheus server URL field, paste the HTTP API address that you obtained in the previous step.

    5. (Optional) In the Custom HTTP Headers section, click +Add header, set Header to Authorization, and set Value to the authentication token that you obtained.

    6. At the bottom of the tab, click Save & Test.

Managed Service for Grafana

Alibaba Cloud Managed Service for Grafana allows you to integrate data sources and dashboards from Application Monitoring with a single click.

  1. In the ARMS console, navigate to the Grafana Service > Workspace Management page and click a workspace ID.

  2. On the Workspace Information page, click ARMS Application Monitoring in the Cloud Service Integration section. Find the instance in the corresponding region and click Integrations in the Actions column.

  3. In the dialog box that appears, click Confirm.

  4. After the synchronization is complete, click Folder on the right.

  5. On the Dashboards tab in Grafana, you can click a dashboard name to view the pre-built default dashboard for Application Monitoring.

    The default dashboards include DB, Application, Interface, and Machine.

  6. In the upper-left corner, click the image icon and choose Management > Data Source to view the added Application Monitoring data source.

    In the data source list, you can see an Application Monitoring data source whose name starts with arms_metrics_cn-hangzhou_cloud and type is Prometheus. Its URL points to the ARMS Prometheus API endpoint.

Step 2: Configure a custom dashboard

  1. In Grafana, click the image icon in the upper-left corner and then click Dashboards.

  2. On the Dashboards page, choose New > New dashboard. On the New dashboard page, click Add visualization to create a panel.

  3. In the Select data source dialog box that appears, select the Application Monitoring data source. By default, the data source name is in the arms_metrics_{regionid}_cloud format.

    Important

    Make sure that data is available in the current data source.

  4. In the collapsible section A, configure the query.

    PromQL queries

    In Code mode, enter a PromQL query statement to the right of the Metrics browser. Below the query editor, you can configure options such as Legend, Format (for example, Time series), and Type (for example, Range or Instant).

    In the ARMS console, on the monitoring details page for an application, you can click the image icon to view the PromQL statement for a metric. For more information, see Query statements.

    For example, on the Application Overview page, in the Request Count metric card, click the icon to view the corresponding PromQL query expression, such as sum by (callType)(sum_over_time(arms_app_requests_count{pid="..."}[1m])). Set Legend to {{label_name}}, select Time series for Format, and select Range for Type.

    For more information about how to use PromQL query statements, see the official Prometheus documentation.

    Application monitoring metrics

    In Builder mode, select a specific metric from the Metric drop-down list, such as arms_jvm_threads_count, to query the number of JVM threads. For more information about the metrics supported by Application Monitoring, see Application Monitoring metric reference.

    In the Label filters section, select labels and label values for specific dimensions. You can further filter data by using labels. For example, set a condition for the host label to filter metrics for a specific host.

  5. In the right-side pane, set the panel title and select a chart type.

    Note

    For the same metric, you can select different chart types to obtain data charts with different granularities.

    Set the visualization type to Time series. In the Panel options section, set the Title to JVM Threads Count, and then click Apply to save the configuration.

  6. After you complete the configuration, click Apply in the upper-right corner.

Customize query statements

Based on the Prometheus HTTP API and PromQL statements obtained from the ARMS console, you can make HTTP requests by using a shell script or Java code to retrieve data for further custom processing.

For example, if the Prometheus HTTP API address is https://cn-hangzhou.arms.aliyuncs.com:9443/api/v1/prometheus/7a8f8e783c66a44a0f6a1dc9a0b8f1/1277589232893727/arms-metrics-99214ff7de7d0b2d/cn-hangzhou, combine it with a PromQL statement in the following format:

{{Prometheus HTTP API}}/api/v1/query_range?query={{PromQL}}&start={{startTime}}&end={{endTime}}&step={{step}}.

The resulting query statement is as follows:

https://cn-hangzhou.arms.aliyuncs.com:9443/api/v1/prometheus/7a8f8e783c66a44a0f6a1dc9a0b8f1/1277589232893727/arms-metrics-99214ff7de7d0b2d/cn-hangzhou/api/v1/query_range?query=sum by (callType,)(sum_over_time_lorc(arms_app_requests_count_ign_destid_endpoint_ppid_prpc{pid="ckv8e2vzfj@7e393063f3fd6ad",serverIp=~".*",callKind=~"http|rpc|custom_entry|server|consumer|schedule",source="apm", }[1m]))&start=1728719399&end=1728722999&step=60s

Example of queried data:

{"status":"success","data":{"resultType":"matrix","result":[{"metric":{"callType":"http"},"values":[[1728719399,"1575"],[1728719459,"1599"],[1728719519,"1593"],[1728719579,"1584"],[1728719639,"1578"],[1728719699,"1568"],[1728719759,"1561"],[1728719819,"1555"],[1728719879,"1547"],[1728719939,"1540"],[1728719999,"1533"],[1728720059,"1524"],[1728720119,"1518"],[1728720179,"1512"],[1728720239,"1503"],[1728720299,"1497"],[1728720359,"1491"],[1728720419,"1482"],[1728720479,"1476"],[1728720539,"1467"],[1728720599,"1464"],[1728720659,"1453"],[1728720719,"1448"],[1728720779,"1443"],[1728720839,"1434"],[1728720899,"1428"],[1728720959,"1419"],[1728721019,"1416"],[1728721079,"1407"],[1728721139,"1401"],[1728721199,"1395"],[1728721259,"1389"],[1728721319,"1383"],[1728721379,"1374"],[1728721439,"1366"],[1728721499,"1367"],[1728721559,"1350"],[1728721619,"1350"],[1728721679,"1344"],[1728721739,"1335"],[1728721799,"1331"],[1728721859,"1324"],[1728721919,"1320"],[1728721979,"1314"],[1728722039,"1305"],[1728722099,"1302"],[1728722159,"1296"],[1728722219,"1287"],[1728722279,"1284"],[1728722339,"1273"],[1728722399,"1272"],[1728722459,"1155"],[1728722519,"1116"],[1728722579,"1110"],[1728722639,"1107"],[1728722699,"1098"],[1728722759,"1095"],[1728722819,"1086"],[1728722879,"1083"],[1728722939,"1077"],[1728722999,"1184"]]}]}}

FAQ

Are queries free of charge?

Yes, queries are free of charge.

Are PromQL queries throttled?

Throttling is based on query consumption, not a fixed queries-per-second (QPS) limit. We recommend avoiding high-consumption queries, such as querying all interfaces or data over a 30-day range, and keep the incoming query rate within 50 QPS. If you have unavoidable and continuous high-consumption queries, you can submit a ticket in advance to request a quota increase.