tip-369.md

April 3, 2025 ยท View on GitHub

tip: 369
title: Node support prometheus metrics	
author: halibobo1205@gmail.com
discussions to: https://github.com/tronprotocol/TIPs/issues/369
status: Final
type: Standards Track
category: Core
created: 2022-03-05

Simple Summary

Monitor your Java-tron server with Prometheus and Grafana.

Abstract

Use prometheus, we can monitor node status, block information, transactions, api calls, method calls, mining block status, etc, then use grafana to show infos, make alerts, and be able to better maintain node running.

Motivation

Currently, the popular blockchain basically supports open-source monitoring prometheus, java-tron has its own monitoring api, but it is not compatible with prometheus.If you want to use the current monitoring, you need to build your own front-end visualization. It is very unfriendly for users to monitor their own nodes.

Specification

1. What Is Prometheus?

Prometheus is an open-source systems monitoring and alerting toolkit .Prometheus collects and stores its metrics as time series data, i.e. metrics information is stored with the timestamp at which it was recorded, alongside optional key-value pairs called labels.

2. What Are Metrics?

In layperson terms, metrics are numeric measurements, time series mean that changes are recorded over time. What users want to measure differs from application to application. For a web server it might be request times, for a database it might be number of active connections or number of active queries etc.

Metrics play an important role in understanding why your application is working in a certain way. Let's assume you are running a web application and find that the application is slow. You will need some information to find out what is happening with your application. For example the application can become slow when the number of requests are high. If you have the request count metric you can spot the reason and increase the number of servers to handle the load.

3. How To Use?

Expose the mertic API using simpleclient and simpleclient_httpserver. Please visit client_java#readme for more details.

4. How To Enable?

Add two new settings to the config.conf file as follows.

net {
  type = mainnet
  # type = testnet
}
... ...
node {
  ... ...
  p2p {
    version = 11111 # 11111: mainnet; 20180622: testnet
  }
  ####### add for prometheus start.
 metrics{
  prometheus{
  enable=true 
  port="9527"
  }
}
####### add for prometheus end.
}

5. Exported Metrics

1. General Metrics

NameDescription
tron:header_statusNumber , timestamp and hash of the most recent block.
tron::header_heightNumber of the most recent block.
tron:header_timeTimestamp of the most recent block.
tron:http_service_latency_secondsLatency for http api each url.
tron:grpc_service_latency_secondsLatency for grpc api each endpoint .
tron:miner_latency_secondsLatency from SR produce block to other node push block for every SR.
tron:http_bytesNetwork traffic for http api each url.
tron:tcp_bytesNetwork traffic for node TCP.
tron:udp_bytesNetwork traffic for node UDP.
tron:manager_queue_sizeThe number of transactions in pending.
tron:txsThe number of transactions for node has executed through pushBlock,or bad transactions .
tron:block_forkNumber of fork.
tron:p2p_errorNumber of P2P error.
tron:p2p_disconnectNumber of P2P disconnect.
tron:miner_latencyEstimated number of highest block.
tron:minerNumber of mined block for every SR.
tron:peersNumber of peers.
tron:db_size_bytesDB size for every db.
tron:db_sst_levelDB sst level file distribution .

2. JVM Metrics

this is use Hotspot collectors api

Export NameDescription
StandardExportsExports the standard exports common across all prometheus clients.This includes stats like CPU time spent and memory usage.
MemoryPoolsExportsExports metrics about JVM memory areas.
MemoryAllocationExportsTotal bytes allocated in a given JVM memory pool. Only updated after GC, not continuously.
BufferPoolsExportsExports metrics about JVM buffers.
GarbageCollectorExportsExports metrics about JVM garbage collectors.
ThreadExportsExports metrics about JVM thread areas.
ClassLoadingExportsExports metrics about JVM classloading.
VersionInfoExportsExports JVM version info.

3. System Metrics

NameDescription
system_available_cpusthe number of processors available to the java virtual machine.
system_cpu_loadthe system cpu load.
system_load_averagethe system load average for the last minute.
system_total_physical_memory_bytestotal physical memory bytes.
system_free_physical_memory_bytesfree physical memory.
system_total_swap_spaces_bytestotal swap spaces.
system_free_swap_spaces_bytesfree swap spaces.

6. Metrics API

We provide the standard prometheus http API, please visit prometheus for more detail.

Rationale

Using open source monitoring prometheus, and data dashboards grafana,monitor and expose metrics with prometheus, use simpleclient to record metrics, simpleclient_httpserver to expose api. Query, visualize, alert on, and understand metrics with grafana.

Implementation

TODO


## Copyright

Copyright and related rights waived via [CC0](LICENSE.md).