Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add monitoring(grafana, prometheus, ethbalance) for localnet testing #1498

Merged
merged 20 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ localnet/ganache/storage
localnet/zetachain-monorepo
/standalone-network/authz/tx.json
/zetanode.log

# Blockscout Files
contrib/localnet/blockscout/services/blockscout-db-data/*
contrib/localnet/blockscout/services/logs/*
contrib/localnet/blockscout/services/redis-data/*
contrib/localnet/blockscout/services/stats-db-data/*
contrib/localnet/grafana/addresses.txt
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,26 @@ stateful-upgrade-source:
stop-stateful-upgrade:
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml down --remove-orphans

###############################################################################
### Monitoring and Blockscout ###
###############################################################################

start-blockscout:
@echo "Starting blockscout"
cd contrib/localnet/blockscout && $(DOCKER) compose -f docker-compose.yml up -d

stop-blockscout:
@echo "Stopping blockscout"
cd contrib/localnet/blockscout && $(DOCKER) compose -f docker-compose.yml down --remove-orphans

start-monitoring:
@echo "Starting monitoring services"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-monitoring.yml up -d

stop-monitoring:
@echo "Stopping monitoring services"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-monitoring.yml down

###############################################################################
### GoReleaser ###
###############################################################################
Expand Down
41 changes: 41 additions & 0 deletions contrib/localnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,47 @@ which does the following docker compose command:
# in zeta-node/contrib/localnet/orchestrator
$ docker compose down --remove-orphans
```
### Run monitoring setup
Before starting the monitoring setup, make sure you have added the eth addresses of interest to the grafana/addresses.txt file
morde08 marked this conversation as resolved.
Show resolved Hide resolved
```bash
# in zeta-node/
make start-monitoring
```
which does the following docker compose command:
```bash
# in zeta-node/contrib/localnet/
$ docker compose -f docker-compose-monitoring.yml up -d
```
To spin down the monitoring setup:
```bash
# in zeta-node/
make stop-monitoring
```
which does the following docker compose command:
```bash
# in zeta-node/contrib/localnet/
$ docker compose -f docker-compose-monitoring.yml down --remove-orphans
```
### Run blockscout for localnet
```bash
# in zeta-node/
make start-blockscout
```
which does the following docker compose command:
```bash
# in zeta-node/contrib/localnet/blockscout
$ docker compose -f compose -f docker-compose.yml up -d
```
To spin down the blockscout setup:
```bash
# in zeta-node/
make stop-blockscout
```
which does the following docker compose command:
```bash
# in zeta-node/contrib/localnet/blockscout
$ docker compose -f docker-compose.yml down --remove-orphans
```

## Useful data

Expand Down
91 changes: 91 additions & 0 deletions contrib/localnet/blockscout/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
version: '3.9'

services:
redis_db:
extends:
file: ./services/redis.yml
service: redis_db

db-init:
extends:
file: ./services/db.yml
service: db-init

db:
extends:
file: ./services/db.yml
service: db

backend:
depends_on:
- db
- redis_db
extends:
file: ./services/backend.yml
service: backend
build:
context: ..
dockerfile: ./docker/Dockerfile
args:
CACHE_EXCHANGE_RATES_PERIOD: ""
API_V1_READ_METHODS_DISABLED: "false"
DISABLE_WEBAPP: "false"
API_V1_WRITE_METHODS_DISABLED: "false"
CACHE_TOTAL_GAS_USAGE_COUNTER_ENABLED: ""
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL: ""
ADMIN_PANEL_ENABLED: ""
RELEASE_VERSION: 5.3.3
links:
- db:database
environment:
ETHEREUM_JSONRPC_HTTP_URL: http://host.docker.internal:9545/
ETHEREUM_JSONRPC_TRACE_URL: http://host.docker.internal:9545/
INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER: 'true'
INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER: 'true'
CHAIN_ID: '7001'


visualizer:
extends:
file: ./services/visualizer.yml
service: visualizer

sig-provider:
extends:
file: ./services/sig-provider.yml
service: sig-provider

frontend:
depends_on:
- backend
extends:
file: ./services/frontend.yml
service: frontend

stats-db-init:
extends:
file: ./services/stats.yml
service: stats-db-init

stats-db:
depends_on:
- backend
extends:
file: ./services/stats.yml
service: stats-db

stats:
depends_on:
- stats-db
extends:
file: ./services/stats.yml
service: stats

proxy:
depends_on:
- backend
- frontend
- stats
extends:
file: ./services/nginx.yml
service: proxy
83 changes: 83 additions & 0 deletions contrib/localnet/blockscout/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
FROM hexpm/elixir:1.14.5-erlang-24.2.2-alpine-3.18.2 AS builder

WORKDIR /app

ENV MIX_ENV="prod"

RUN apk --no-cache --update add alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3 file gcompat

RUN set -ex && \
apk --update add libstdc++ curl ca-certificates gcompat

ARG CACHE_EXCHANGE_RATES_PERIOD
ARG API_V1_READ_METHODS_DISABLED
ARG DISABLE_WEBAPP
ARG API_V1_WRITE_METHODS_DISABLED
ARG CACHE_TOTAL_GAS_USAGE_COUNTER_ENABLED
ARG ADMIN_PANEL_ENABLED
ARG CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL
ARG SESSION_COOKIE_DOMAIN
ARG MIXPANEL_TOKEN
ARG MIXPANEL_URL
ARG AMPLITUDE_API_KEY
ARG AMPLITUDE_URL
ARG CHAIN_TYPE
ENV CHAIN_TYPE=${CHAIN_TYPE}

# Cache elixir deps
ADD mix.exs mix.lock ./
ADD apps/block_scout_web/mix.exs ./apps/block_scout_web/
ADD apps/explorer/mix.exs ./apps/explorer/
ADD apps/ethereum_jsonrpc/mix.exs ./apps/ethereum_jsonrpc/
ADD apps/indexer/mix.exs ./apps/indexer/

ENV MIX_HOME=/opt/mix
RUN mix local.hex --force
RUN mix do deps.get, local.rebar --force, deps.compile

ADD apps ./apps
ADD config ./config
ADD rel ./rel
ADD *.exs ./

RUN apk add --update nodejs npm

# Run forderground build and phoenix digest
RUN mix compile && npm install npm@latest

# Add blockscout npm deps
RUN cd apps/block_scout_web/assets/ && \
npm install && \
npm run deploy && \
cd /app/apps/explorer/ && \
npm install && \
apk update && \
apk del --force-broken-world alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3


RUN apk add --update git make

RUN mix phx.digest

RUN mkdir -p /opt/release \
&& mix release blockscout \
&& mv _build/${MIX_ENV}/rel/blockscout /opt/release

##############################################################
FROM hexpm/elixir:1.14.5-erlang-24.2.2-alpine-3.18.2

ARG RELEASE_VERSION
ENV RELEASE_VERSION=${RELEASE_VERSION}
ARG CHAIN_TYPE
ENV CHAIN_TYPE=${CHAIN_TYPE}
ARG BLOCKSCOUT_VERSION
ENV BLOCKSCOUT_VERSION=${BLOCKSCOUT_VERSION}

RUN apk --no-cache --update add jq curl

WORKDIR /app

COPY --from=builder /opt/release/blockscout .
COPY --from=builder /app/apps/explorer/node_modules ./node_modules
COPY --from=builder /app/config/config_helper.exs ./config/config_helper.exs
COPY --from=builder /app/config/config_helper.exs /app/releases/${RELEASE_VERSION}/config_helper.exs
Loading
Loading