This plugin for the Handshake Daemon (hsd) exposes various metrics in a Prometheus-compatible format, allowing you to monitor your hsd node's performance and status using Prometheus and Grafana.
- Exposes hsd chain, peer, and mempool metrics.
- Lightweight, with no external dependencies.
- Configurable HTTP port for metrics exposure.
In your hsd project directory, install the plugin using npm:
npm install hsd-plugin-prometheusTo enable the plugin, add it to hsd list of plugins. You can do this via the command line, environment variables, or your hsd.conf file.
Run hsd with the --plugins flag pointing to the plugin directory:
hsd --plugins hsd-plugin-prometheusSet the HSD_PLUGINS environment variable:
export HSD_PLUGINS=hsd-plugin-prometheus
hsdAdd the plugins entry to your ~/.hsd/hsd.conf file:
plugins: hsd-plugin-prometheus
The plugin listens on port 9090 by default. You can change this port by adding the prometheus-port option to your hsd.conf file or as a command-line argument:
prometheus-port: 9091
prometheus-host: 127.0.0.1
prometheus-api-key: your-secret-key
hsd --plugins /path/to/hsd-plugin-prometheus --prometheus-port 9091 --prometheus-host 127.0.0.1 --prometheus-api-key your-secret-keyWhen the prometheus-api-key is set, the metrics endpoint will require Basic Authentication. The username must be x, and the password must be the configured API key.
Once the plugin is running, you can access the metrics by navigating to http://your-hsd-node-ip:9090/metrics (or your configured port) in your web browser or by configuring Prometheus to scrape this endpoint.
Here's a list of the metrics exposed by this plugin:
hsd_chain_height: Current block height of the blockchain.hsd_chain_difficulty: Current blockchain difficulty.hsd_chain_last_block_time_seconds: Unix timestamp of the last block's timestamp.
hsd_peer_count: Current number of connected peers.hsd_peer_inbound_count: Number of inbound peer connections.hsd_peer_outbound_count: Number of outbound peer connections.
hsd_mempool_tx_count: Current number of transactions in the mempool.hsd_mempool_size_bytes: Total size of transactions in the mempool in bytes.
hsd_uptime_seconds: Total uptime of the hsd node.hsd_cpu_usage_percent: CPU utilization of the hsd processhsd_memory_usage_bytes: Memory usage of the hsd process.
To scrape metrics from your hsd node, add the following job to your prometheus.yml configuration file:
scrape_configs:
- job_name: 'hsd'
static_configs:
- targets: ['your-hsd-node-ip:9090'] # Replace with your hsd node's IP and portReload your Prometheus configuration after making changes.
This project is licensed under the MIT License - see the LICENSE file for details. (Note: A LICENSE file should be created if not already present.)