Skip to content
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
Prev Previous commit
Next Next commit
review changes
  • Loading branch information
shiqizng committed Feb 18, 2022
commit e4fe46a2445bd7a3fcbac068b01d18a1ce9c9d82
1 change: 0 additions & 1 deletion monitoring/.env

This file was deleted.

22 changes: 12 additions & 10 deletions monitoring/Dockerfile-indexer
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
FROM alpine:latest
ARG GO_VERSION=1.17.5
FROM golang:$GO_VERSION

RUN apk add --no-cache git make musl-dev go bash libtool autoconf automake build-base libsodium-dev boost-dev
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y apt-utils curl git git-core bsdmainutils python3

# Configure Go
ENV GOROOT /usr/lib/go
ENV GOPATH /go
ENV PATH /go/bin:$PATH

RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin

# Build and run indexer
# Build go-algorand
RUN mkdir /work
WORKDIR /work
ADD . ./
WORKDIR /work/third_party/go-algorand
RUN ./scripts/configure_dev.sh
RUN make

# Build indexer
WORKDIR /work
RUN make
WORKDIR /work/cmd/algorand-indexer
ENV CGO_ENABLED="1"
Expand All @@ -28,4 +30,4 @@ CMD ["/bin/sh", "-c", "\
-P \"${CONNECTION_STRING}\" \
--metrics-mode VERBOSE \
--algod-net \"${ALGOD_NET}\" \
--algod-token ${ALGOD_TOKEN}"]
--algod-token ${ALGOD_TOKEN}"]
31 changes: 16 additions & 15 deletions monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@
A monitoring dashboard displaying indexer performance metrics.

### To start a monitoring dashboard
Configurable env vars, `DB_CONNECTION`, `ALGOD_NET` and `ALGOD_TOKEN`. The defaults are set in `.env`. User must provide a valid `ALGOD_NET` and `ALGOD_TOKEN` pair.
### Prerequisite
- Algorand indexer is running with metrics-mode set to ON or VERBOSE

if indexer is not already running, start all services in `docker-compose.yml`
Data sources for Grafana are set in `grafana_prometheus_datasource.yml`. Check that configurations for
Prometheus source and PostgresSQL source are correct or Grafana will not have the metrics.

`docker-compose up -d`

if indexer is already running, start monitoring services only.

`docker-compose up -d prometheus grafana`

prometheus target should be updated to listen to a correct indexer address (host:port),
Also, Prometheus target should be updated to listen to a correct indexer address (host:port). The default target assumes
the indexer is running on prometheus container's host at port 8888. Check `<prometheus-url>/targets` to see whether Prometheus
connects to the target successfully.

```json
static_configs:
- targets: ['indexer:8888']
- targets: ['host.docker.internal:8888']
```

By default,
- indexer is running on http://localhost:8888
- grafana is running on http://localhost:3000; default login (admin/admin)
Run,

`docker-compose up -d prometheus grafana`

- Check metrics are written to <indexer-url>/metrics
- Grafana is running on http://localhost:3000; default login (admin/admin)



### View metrics on grafana

- In grafana configurations, add a PostgreSQL datasource. See example below.
- Go to Import and upload dashboard.json
- Run `create extension pg_stat_statements;` sql on db to enable query stats from Postgres

![](examples/postgresql_conn.png)
![](examples/widgets.png)


Expand Down
9 changes: 5 additions & 4 deletions monitoring/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version: '3'

services:
indexer:
container_name: "indexer"
Expand All @@ -8,9 +7,9 @@ services:
dockerfile: "./monitoring/Dockerfile-indexer"
environment:
PORT: 8888
CONNECTION_STRING: ${DB_CONNECTION}
ALGOD_NET: "${ALGOD_NET}"
ALGOD_TOKEN: "${ALGOD_TOKEN}"
CONNECTION_STRING: ${DB_CONNECTION:-"host=indexer-db port=5432 user=algorand password=algorand dbname=indexer_db sslmode=disable"}
ALGOD_NET: ${ALGOD_NET}
ALGOD_TOKEN: ${ALGOD_TOKEN}
ports:
- 8888:8888
depends_on:
Expand Down Expand Up @@ -38,6 +37,8 @@ services:
volumes:
# Install prometheus config
- ./prometheus.yml:/etc/prometheus/prometheus.yml
extra_hosts:
- "host.docker.internal:host-gateway"

grafana:
image: "grafana/grafana"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
image: "grafana/grafana"
image: "grafana/grafana:8.4.2"

Expand Down
Binary file removed monitoring/examples/postgresql_conn.png
Binary file not shown.
14 changes: 14 additions & 0 deletions monitoring/grafana_prometheus_datasource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ datasources:
# Access mode - proxy (server in the UI) or direct (browser in the UI).
access: proxy
httpMethod: POST
# The default connects to a local instance running in Docker. May be updated
# to connect to any live prometheus instance
url: http://prometheus:9090
version: 1
editable: false

- name: PostgresSQL
type: postgres
# The default connects to a local instance running in Docker. May be updated
# to connect to any live PostgresDB instance
url: indexer-db:5432
database: indexer_db
user: algorand
secureJsonData:
password: 'algorand'
jsonData:
sslmode: "disable"
2 changes: 1 addition & 1 deletion monitoring/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ scrape_configs:
# scheme defaults to 'http'.

static_configs:
- targets: ['indexer:8888']
- targets: ['host.docker.internal:8888']