Skip to content

Commit

Permalink
Add initial telemetry Docker example
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicmilos committed May 9, 2024
1 parent db2f825 commit 828c888
Show file tree
Hide file tree
Showing 9 changed files with 655 additions and 10 deletions.
23 changes: 16 additions & 7 deletions tm2/pkg/telemetry/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# Telemetry

The purpose of this package is to provide a way to easily integrate OpenTelemetry Protocol (OTLP) metrics collection into a Tendermint 2 node.
The purpose of this package is to provide a way to easily integrate OpenTelemetry Protocol (OTLP) metrics collection
into a Tendermint 2 node.

## Configure Telemetry

Telemetry can be regularly configured within the TM2 node through the
`[telemetry]` section. It is disabled by default.

## OTEL configuration
There are many ways configure the OTEL pipeline for exporting metrics. Here is an example of how a local OTEL collector can be configured to send metrics to Grafana Cloud. This is an optional step and can be highly customized.

There are many ways configure the OTEL pipeline for exporting metrics. Here is an example of how a local OTEL collector
can be configured to send metrics to Grafana Cloud. This is an optional step and can be highly customized.

### OTEL collector
The latest collector releases can be found [here](https://github.com/open-telemetry/opentelemetry-collector-releases/releases). This is an example of the config that can be used to receive metrics from gno.land and publish them to Grafana Cloud.

The latest collector releases can be
found [here](https://github.com/open-telemetry/opentelemetry-collector-releases/releases). This is an example of the
config that can be used to receive metrics from gno.land and publish them to Grafana Cloud.

```yaml
receivers:
otlp:
Expand All @@ -29,13 +36,15 @@ exporters:
service:
pipelines:
metrics:
receivers: [otlp]
processors: [batch]
exporters: [otlphttp]
receivers: [ otlp ]
processors: [ batch ]
exporters: [ otlphttp ]
```
Collector exporter environment variables, including those for authentication, can be found [here](https://opentelemetry.io/docs/specs/otel/protocol/exporter/).
Collector exporter environment variables, including those for authentication, can be
found [here](https://opentelemetry.io/docs/specs/otel/protocol/exporter/).
## Resources
- https://opentelemetry.io/docs/collector/
- https://grafana.com/docs/grafana-cloud/monitor-applications/application-observability/setup/collector/
11 changes: 11 additions & 0 deletions tm2/pkg/telemetry/docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: up
up:
docker compose up -d

.PHONY: down
down:
docker compose down

.PHONY: clean
clean:
docker compose down -v
22 changes: 22 additions & 0 deletions tm2/pkg/telemetry/docker/collector/collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317

processors:
batch:

exporters:
prometheus:
endpoint: collector:8090

service:
telemetry:
logs:
level: "debug"
pipelines:
metrics:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ prometheus ]
34 changes: 34 additions & 0 deletions tm2/pkg/telemetry/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
collector:
image: otel/opentelemetry-collector-contrib:latest
ports:
- "4317:4317"
- "4318:4318"
- "8090"
volumes:
- ./collector/collector.yaml:/etc/otelcol-contrib/config.yaml
prometheus:
image: prom/prometheus:latest
command:
- "--enable-feature=remote-write-receiver"
- "--config.file=/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
volumes:
- prometheus:/prometheus
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
grafana:
image: grafana/grafana-enterprise
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
- ./grafana/dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yaml
- ./grafana/gno-dashboards.json:/var/lib/grafana/dashboards/gno-dashboards.json
ports:
- "3000:3000"

volumes:
prometheus:
driver: local
grafana_data:
driver: local
8 changes: 8 additions & 0 deletions tm2/pkg/telemetry/docker/grafana/dashboards.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: 1

providers:
- name: Gno Node Metrics
folder: Gno
type: file
options:
path: /var/lib/grafana/dashboards
13 changes: 13 additions & 0 deletions tm2/pkg/telemetry/docker/grafana/datasources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
access: proxy
orgId: 1
url: http://prometheus:9090
basicAuth: false
isDefault: false
version: 1
editable: true
uid: prometheus
Loading

0 comments on commit 828c888

Please sign in to comment.