#metrics #packets #collect #ibc #monitoring #tool #relayer

app chainpulse

Chainpulse 是 IBC 路由器的监控工具

10 个不稳定版本 (3 个破坏性版本)

0.4.1 2023年11月14日
0.4.0 2023年10月31日
0.3.2 2023年7月26日
0.3.0 2023年6月6日
0.1.2 2023年5月25日

#13 in #relayer

每月22次下载

Apache-2.0

54KB
1K SLoC

Cosmos ecosystem

Crates.io Build Status Apache 2.0 Licensed Rust Stable Rust 1.69+

Chain Pulse

收集发送到和从指定区块链的包,计算哪些包受到影响以及谁转发了它们。

收集的数据存储在 SQLite 数据库中,度量数据导出到 Prometheus。

安装

  1. 克隆此仓库

    $ git clone https://github.com/informalsystems/chainpulse
    
  2. 构建 chainpulse 可执行文件

    $ cargo build --release
    
  3. chainpulse 可执行文件现在可在 target/release 中找到

配置

chainpulse.toml 创建一个配置文件,内容如下

[chains]
endpoints = [
  { name = "neutron", comet_version = "0.34", url = "wss://neutron-rpc.lavenderfive.com/websocket" },
  { name = "osmosis", comet_version = "0.34", url = "wss://rpc.osmosis.zone/websocket" },
]

[database]
path = "data.db"

[metrics]
enabled = true
port    = 3000

注意:字段 comet_version 是可选的,默认为 "0.34"。

用法

Collect and analyze txs containing IBC messages, export the collected metrics for Prometheus

Usage: chainpulse [OPTIONS]

Options:
  -c, --config <CONFIG>  Path to the configuration file [default: chainpulse.toml]
  -h, --help             Print help

使用上面的配置文件运行收集器,以收集 Osmosis 和 Neutron 的包度量

$ chainpulse --config chainpulse.toml
2023-05-26T10:17:28.378380Z  INFO Metrics server listening at https://127.0.0.1:3000/metrics
2023-05-26T10:17:28.386299Z  INFO collect{chain=neutron}: Connecting to wss://neutron-rpc.lavenderfive.com/websocket...
2023-05-26T10:17:28.386951Z  INFO collect{chain=osmosis}: Connecting to wss://rpc.osmosis.zone/websocket...
2023-05-26T10:17:28.932084Z  INFO collect{chain=neutron}: Subscribing to NewBlock events...
2023-05-26T10:17:29.012893Z  INFO collect{chain=neutron}: Waiting for new blocks...
2023-05-26T10:17:29.078725Z  INFO collect{chain=osmosis}: Subscribing to NewBlock events...
2023-05-26T10:17:29.254485Z  INFO collect{chain=osmosis}: Waiting for new blocks...

...

Prometheus 度量

内置的 HTTP 服务器在 /metrics 上导出以下 Prometheus 度量

# HELP ibc_effected_packets The number of IBC packets that are effected
# TYPE ibc_effected_packets counter
ibc_effected_packets{chain_id, src_channel, src_port, dst_channel, dst_port, signer, memo}
# HELP ibc_uneffected_packets The number of IBC packets that are not effected
# TYPE ibc_uneffected_packets counter
ibc_uneffected_packets{chain_id, src_channel, src_port, dst_channel, dst_port, signer, memo}
# HELP ibc_frontrun_counter The number of times a signer gets frontrun by the original signer
# TYPE ibc_frontrun_counter counter
ibc_frontrun_counter{chain_id, src_channel, src_port, dst_channel, dst_port, signer, frontrunned_by, memo, effected_memo}

# HELP ibc_stuck_packets The number of packets stuck on an IBC channel
# TYPE ibc_stuck_packets gauge
ibc_stuck_packets{dst_chain,src_chain,src_channel} 1

内部度量

以下内部度量也可用,用于监控 Chain Pulse 本身

# HELP chainpulse_chains The number of chains being monitored
# TYPE chainpulse_chains gauge
chainpulse_chains 2
# HELP chainpulse_packets The number of packets processed
# TYPE chainpulse_packets counter
chainpulse_packets{chain_id}
# HELP chainpulse_reconnects The number of times we had to reconnect to the WebSocket
# TYPE chainpulse_reconnects counter
chainpulse_reconnects{chain_id}
# HELP chainpulse_txs The number of txs processed
# TYPE chainpulse_txs counter
chainpulse_txs{chain_id}

归属

本项目受到 @clemensgg 的 relayer-metrics-exporter 的极大启发和部分移植。

许可

版权 © 2023 Informal Systems Inc. 和 Hermes 作者。

根据 Apache License,版本 2.0(“许可”)许可;除非适用法律要求或书面同意,否则不得使用本存储库中的文件,除非遵守本许可。您可以在以下位置获得许可副本:

https://www.apache.org/licenses/LICENSE-2.0

除非适用法律要求或书面同意,否则在许可下分发的软件按“原样”基础分发,不提供任何明示或暗示的保证或条件。有关许可的具体语言,请参阅许可。

依赖项

~82MB
~1.5M SLoC