You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: apps/price_pusher/README.md
+114
Original file line number
Diff line number
Diff line change
@@ -259,3 +259,117 @@ pushed twice and you won't pay additional costs most of the time.** However, the
259
259
conditions in the RPCs because they are often behind a load balancer which can sometimes cause rejected
260
260
transactions to land on-chain. You can reduce the chances of additional cost overhead by reducing the
261
261
pushing frequency.
262
+
263
+
## Prometheus Metrics
264
+
265
+
The price_pusher now supports Prometheus metrics to monitor the health and performance of the price update service. Metrics are exposed via an HTTP endpoint that can be scraped by Prometheus.
266
+
267
+
### Available Metrics
268
+
269
+
The following metrics are available:
270
+
271
+
- **pyth_price_last_published_time** (Gauge): The last published time of a price feed in unix timestamp, labeled by price_id and alias
272
+
- **pyth_price_update_attempts_total** (Counter): Total number of price update attempts with their trigger condition and status, labeled by price_id, alias, trigger, and status
273
+
- **pyth_price_feeds_total** (Gauge): Total number of price feeds being monitored
274
+
- **pyth_wallet_balance** (Gauge): Current wallet balance of the price pusher in native token units, labeled by wallet_address and network
275
+
276
+
### Configuration
277
+
278
+
Metrics are enabled by default and can be configured using the following command-line options:
279
+
280
+
- `--enable-metrics`: Enable or disable the Prometheus metrics server (default: true)
281
+
- `--metrics-port`: Port for the Prometheus metrics server (default: 9090)
282
+
283
+
Example:
284
+
285
+
```bash
286
+
pnpm run dev evm --config config.evm.mainnet.json --metrics-port 9091
287
+
```
288
+
289
+
### Running Locally with Docker
290
+
291
+
You can run the monitoring stack (Prometheus and Grafana) using the provided docker-compose configuration:
292
+
293
+
1. Use the sample docker-compose file for metrics:
294
+
295
+
```bash
296
+
docker-compose -f docker-compose.metrics.sample.yaml up
297
+
```
298
+
299
+
This will start:
300
+
- Prometheus server on port 9090 with the alerts configured in alerts.sample.yml
301
+
- Grafana server on port 3000 with default credentials (admin/admin)
302
+
303
+
The docker-compose.metrics.sample.yaml file includes a pre-configured Grafana dashboard (see the [Dashboard](#dashboard) section below) that displays all the metrics mentioned above. This dashboard provides monitoring of your price pusher operations with panels for configured feeds, active feeds, wallet balance, update statistics, and error tracking. The dashboard is automatically provisioned when you start the stack with docker-compose.
304
+
305
+
### Example Grafana Queries
306
+
307
+
Here are some example Grafana queries to monitor your price feeds:
sum by (condition) (increase(pyth_update_conditions_total[$__range]))
331
+
```
332
+
333
+
5. Monitor wallet balances:
334
+
335
+
```
336
+
pyth_wallet_balance
337
+
```
338
+
339
+
6. Detect low wallet balances (below 0.1 tokens):
340
+
341
+
```
342
+
pyth_wallet_balance < 0.1
343
+
```
344
+
345
+
### Dashboard
346
+
347
+
The docker-compose setup includes a pre-configured Grafana dashboard (`grafana-dashboard.sample.json`) that provides monitoring of your price pusher operations. The dashboard includes the following panels:
348
+
349
+
- **Configured Price Feeds**: Shows the number of price feeds configured in your price-config file.
350
+
- **Active Price Feeds**: Displays the number of price feeds currently being actively monitored.
351
+
- **Time Since Last Update**: Shows how long it's been since the last successful price update was published on-chain.
352
+
- **Price Feeds List**: A table listing all configured price feeds with their details.
353
+
- **Successful Updates (Current Range)**: Graph showing the number of successful price updates over the current range with timeline.
354
+
- **Update Conditions Distribution**: Pie chart showing the distribution of update conditions (YES/NO/EARLY) over the selected time range.
355
+
- **Wallet Balance**: Current balance of your wallet in native token units.
356
+
- **Wallet Balance Over Time**: Graph tracking your wallet balance over time to monitor consumption.
357
+
- **Failed Updates (Current Range)**: Graph showing the number of failed price updates over the current range with timeline.
358
+
359
+
When you first start the monitoring stack, the dashboard may show "No data" in the panels until the price pusher has been running for some time and has collected sufficient metrics.
360
+
361
+
This dashboard is automatically provisioned when you start the docker-compose stack and provides visibility into the health and performance of your price pusher deployment.
362
+
363
+
### Alerting
364
+
365
+
The price pusher includes pre-configured Prometheus alerting rules in the `alerts.sample.yml` file. These rules monitor various aspects of the price pusher's operation, including:
366
+
367
+
- Price feeds not being updated for an extended period (>1 hour)
368
+
- High error rates in price update attempts
369
+
- No successful price updates across all feeds in the last 30 minutes
When using the docker-compose setup, these alerts are automatically loaded into Prometheus and can be viewed in the Alerting section of Grafana after setting up the Prometheus data source.
0 commit comments