Skip to content

Commit

Permalink
Merge branch 'richard/quickstart' into 'master'
Browse files Browse the repository at this point in the history
add Docker Compose quickstart config

See merge request Blockdaemon/solana/pyth_exporter!6
  • Loading branch information
Richard Patel committed Mar 10, 2022
2 parents 0e10eef + 1cf1942 commit f041e72
Show file tree
Hide file tree
Showing 17 changed files with 2,908 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.png filter=lfs diff=lfs merge=lfs -text
112 changes: 78 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,40 +63,84 @@ Usage of pyth_exporter:
Solana WebSocket RPC URL
```

## Metrics
## Deployment

[./docker-compose.yml](./docker-compose.yml) defines a reference [Docker Compose](https://docs.docker.com/compose/) deployment on a single host.

The compose config includes the following services:
- pyth_exporter (this repo)
- Prometheus monitoring agent
- Grafana monitoring UI

### Requirements

The reference deployment requires Docker Compose: [Compose installation guide](https://docs.docker.com/compose/install/)

### Configuration

The env vars file contains deployment-specific config.
Copy the example config and adjust it.

```shell
cp docker.example.env docker.env
$EDITOR docker.env
```

- `*_IMAGE`: Docker image strings
- `SOLANA_RPC`: Solana RPC access
- `SOLANA_WS`: Solana WebSocket access
- `SOLANA_ENV`: Environment name (devnet, testnet, mainnet)

### Operations

Start all services

```shell
docker-compose --env-file docker.env up -d
```

Stop all services

```shell
docker-compose down
```
% curl http://localhost:8080/metrics
# HELP pyth_exporter_rpc_requests_total Number of outgoing RPC requests from pyth_exporter to RPC nodes
# TYPE pyth_exporter_rpc_requests_total counter
pyth_exporter_rpc_requests_total 24
# HELP pyth_exporter_ws_active_conns Number of active WebSockets between pyth_exporter and RPC nodes
# TYPE pyth_exporter_ws_active_conns gauge
pyth_exporter_ws_active_conns 1
# HELP pyth_exporter_ws_events_total Number of WebSocket events delivered from RPC nodes to pyth_exporter
# TYPE pyth_exporter_ws_events_total counter
pyth_exporter_ws_events_total 14408
# HELP pyth_oracle_aggregated_conf_amount Last aggregated conf of Pyth product
# TYPE pyth_oracle_aggregated_conf_amount gauge
pyth_oracle_aggregated_conf_amount{pyth_product="EWxGfxoPQSNA2744AYdAKmsQZ8F9o9M7oKkvL3VM1dko"} 2e-05
# HELP pyth_oracle_aggregated_price Last aggregated price of Pyth product
# TYPE pyth_oracle_aggregated_price gauge
pyth_oracle_aggregated_price{pyth_product="EWxGfxoPQSNA2744AYdAKmsQZ8F9o9M7oKkvL3VM1dko"} 1.1326100000000001
# HELP pyth_oracle_publisher_conf_amount Last published product confidence by Pyth publisher
# TYPE pyth_oracle_publisher_conf_amount gauge
pyth_oracle_publisher_conf_amount{pyth_product="EWxGfxoPQSNA2744AYdAKmsQZ8F9o9M7oKkvL3VM1dko",pyth_publisher="AKPWGLY5KpxbTx7DaVp4Pve8JweMjKbb1A19MyL2nrYT"} 0.00014000000000000001
# HELP pyth_oracle_publisher_price Last published product price by Pyth publisher
# TYPE pyth_oracle_publisher_price gauge
pyth_oracle_publisher_price{pyth_product="EWxGfxoPQSNA2744AYdAKmsQZ8F9o9M7oKkvL3VM1dko",pyth_publisher="AKPWGLY5KpxbTx7DaVp4Pve8JweMjKbb1A19MyL2nrYT"} 1.1326500000000002
# HELP pyth_oracle_publisher_slot Last observed slot for Pyth publisher
# TYPE pyth_oracle_publisher_slot gauge
pyth_oracle_publisher_slot{pyth_product="EWxGfxoPQSNA2744AYdAKmsQZ8F9o9M7oKkvL3VM1dko",pyth_publisher="AKPWGLY5KpxbTx7DaVp4Pve8JweMjKbb1A19MyL2nrYT"} 1.16427278e+08
# HELP pyth_solana_publish_account_balance SOL balance of Pyth publish account in lamports
# TYPE pyth_solana_publish_account_balance gauge
pyth_solana_publish_account_balance{pyth_publisher="AKPWGLY5KpxbTx7DaVp4Pve8JweMjKbb1A19MyL2nrYT"} 4.950539e+10
# HELP pyth_txs_total Approximate number of Pyth transactions sent
# TYPE pyth_txs_total counter
pyth_txs_total{pyth_publisher="AKPWGLY5KpxbTx7DaVp4Pve8JweMjKbb1A19MyL2nrYT",tx_status="failed"} 10
pyth_txs_total{pyth_publisher="AKPWGLY5KpxbTx7DaVp4Pve8JweMjKbb1A19MyL2nrYT",tx_status="success"} 67

Stop all services and delete all data (!)

```shell
docker-compose down -v --remove-orphans
```

View service status

```shell
docker-compose ps
```

View service logs

```shell
docker-compose logs
```

## Screenshots

**Overview**

![Overview](./docs/grafana-overview.png)

**Status Matrix**

![Status Matrix](./docs/grafana-status-matrix.png)

**Aggregated Price**

![Aggregated Price](./docs/grafana-price.png)

**Multiple Price Components**

![Multiple Price Components](./docs/grafana-price-components.png)

**Single Price Component**

![Single Price Component](./docs/grafana-price-published.png)
44 changes: 44 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Example docker-compose deployment.
version: '3'

volumes:
prometheus_storage: {}
grafana_storage: {}

services:
# Prometheus exporter
pyth_exporter:
# --- Release build
# image: "${PYTH_EXPORTER_IMAGE}"
# --- Development build
build:
dockerfile: ./Dockerfile
context: .
restart: unless-stopped
command:
- "--listen=:8080"
- "--log-level=info"
- "--env=${SOLANA_ENV}"
- "--rpc=${SOLANA_RPC}"
- "--ws=${SOLANA_WS}"

# Prometheus monitoring agent
prometheus:
image: "${PROMETHEUS_IMAGE}"
restart: unless-stopped
ports:
- '9090:9090'
volumes:
- 'prometheus_storage:/prometheus'
- './docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro'

# Grafana UI
grafana:
image: "${GRAFANA_IMAGE}"
restart: unless-stopped
ports:
- '3000:3000'
volumes:
- 'grafana_storage:/var/lib/grafana'
- './docker/grafana/grafana.ini:/etc/grafana/grafana.ini:ro'
- './docker/grafana/provisioning:/etc/grafana/provisioning:ro'
13 changes: 13 additions & 0 deletions docker.example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Pyth Prometheus Exporter
PYTH_EXPORTER_IMAGE=registry.gitlab.com/blockdaemon/solana/pyth_exporter:latest

# Prometheus
PROMETHEUS_IMAGE=prom/prometheus:latest

# Grafana
GRAFANA_IMAGE=grafana/grafana-oss:latest

# Solana node access
SOLANA_RPC=https://my-node.bdnodes.net?auth=xxx
SOLANA_WS=wss://my-node.bdnodes.net/websocket?auth=xxx
SOLANA_ENV=mainnet
20 changes: 20 additions & 0 deletions docker/grafana/grafana.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Example config file for Grafana.

[auth]
disable_login_form = true

[auth.basic]
enabled = false

[auth.anonymous]
enabled = true
org_name = Main Org.
org_role = Editor
hide_version = true

[security]
disable_initial_admin_creation = true

[users]
default_theme = light
home_page = /d/V0YM0T-7z/pyth-fix-overview?orgId=1&kiosk=tv&refresh=10s
11 changes: 11 additions & 0 deletions docker/grafana/provisioning/dashboards/local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: 1
providers:
- name: 'local'
orgId: 1
folder: ''
folderUid: ''
type: file
disableDeletion: true
allowUiUpdates: true
options:
path: /etc/grafana/provisioning/dashboards
Loading

0 comments on commit f041e72

Please sign in to comment.