How to Customize Metrics to Monitor Business Data

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 如何自定义metrics,监控业务数据

| username: 江湖故人

I would like to ask how to customize a metric in Prometheus to monitor the result of a specific business SQL query?
I have previously customized similar monitoring items in Zabbix, but I am not familiar with Prometheus.

| username: 小龙虾爱大龙虾 | Original post link

You can continue to use your Zabbix to achieve this function. Business monitoring should be done by the business itself, why put it in the TiDB cluster’s Prometheus?

| username: 江湖故人 | Original post link

Mainly want to learn about Prometheus.

| username: 小龙虾爱大龙虾 | Original post link

There are multiple ways to obtain business monitoring data. You can refer to Overview | Prometheus

| username: Fly-bird | Original post link

Write the data in this format:

HELP node_tcp_CLOSED tcp states used by some directories

TYPE node_tcp_CLOSED gauge

node_tcp_CLOSED 147

Prometheus can read it.

| username: TiDBer_小阿飞 | Original post link

The practical implementation of Prometheus monitoring with custom metrics

  1. Why do we need custom metrics?
    Prometheus’s monitoring indicators are already quite comprehensive, covering almost all standardized scenarios. However, in actual work environments, there are often many non-standard indicators that Prometheus does not adapt to. Therefore, custom metrics need to be defined and pushed to Prometheus to achieve monitoring purposes.

  2. Implementation methods

  3. Combining with pushgateway
    3.1 Installing pushgateway