Skip to content

Commit

Permalink
Add grafana stack with otel collector.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduard-melnytskyi committed Jan 15, 2025
1 parent 28058dc commit 3470cd1
Show file tree
Hide file tree
Showing 10 changed files with 2,466 additions and 0 deletions.
1,135 changes: 1,135 additions & 0 deletions context/otel-stack/dashboards/dashboard-apm.json

Large diffs are not rendered by default.

1,139 changes: 1,139 additions & 0 deletions context/otel-stack/dashboards/dashboard-top.json

Large diffs are not rendered by default.

Empty file.
30 changes: 30 additions & 0 deletions context/otel-stack/grafana-datasources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
uid: prometheus
access: proxy
orgId: 1
url: http://prometheus:9090
basicAuth: false
isDefault: false
version: 1
editable: false
jsonData:
httpMethod: GET
- name: Tempo
type: tempo
access: proxy
orgId: 1
url: http://tempo:3200
basicAuth: false
isDefault: true
version: 1
editable: false
apiVersion: 1
uid: tempo
jsonData:
httpMethod: GET
serviceMap:
datasourceUid: prometheus
16 changes: 16 additions & 0 deletions context/otel-stack/otel-collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
receivers:
otlp:
protocols:
grpc:
http:

exporters:
otlp:
endpoint: tempo:4317
tls:
insecure: true
service:
pipelines:
traces:
receivers: [otlp]
exporters: [otlp]
11 changes: 11 additions & 0 deletions context/otel-stack/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
global:
scrape_interval: 15s
evaluation_interval: 15s

scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'tempo'
static_configs:
- targets: ['tempo:3200']
65 changes: 65 additions & 0 deletions context/otel-stack/tempo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
stream_over_http_enabled: true
server:
http_listen_port: 3200
log_level: info

query_frontend:
search:
duration_slo: 5s
throughput_bytes_slo: 1.073741824e+09
trace_by_id:
duration_slo: 5s

distributor:
receivers: # this configuration will listen on all ports and protocols that tempo is capable of.
jaeger: # the receives all come from the OpenTelemetry collector. more configuration information can
protocols: # be found there: https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver
thrift_http: #
grpc: # for a production deployment you should only enable the receivers you need!
thrift_binary:
thrift_compact:
zipkin:
otlp:
protocols:
http:
grpc:
opencensus:

ingester:
max_block_duration: 5m # cut the headblock when this much time passes. this is being set for demo purposes and should probably be left alone normally

compactor:
compaction:
block_retention: 1h # overall Tempo trace retention. set for demo purposes

metrics_generator:
registry:
external_labels:
source: tempo
cluster: docker-compose
storage:
path: /var/tempo/generator/wal
remote_write:
- url: http://prometheus:9090/api/v1/write
send_exemplars: true
traces_storage:
path: /var/tempo/generator/traces

storage:
trace:
backend: local # backend configuration to use
wal:
path: /var/tempo/wal # where to store the wal locally
local:
path: /var/tempo/blocks

overrides:
defaults:
global:
max_bytes_per_trace: 100000000
ingestion:
max_traces_per_user: 10000
read:
max_bytes_per_tag_values_query: 100000000
metrics_generator:
processors: [service-graphs, span-metrics, local-blocks] # enables metrics generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% extends "nginx/http/gateway/server.conf.twig" %}
{% block upstream %}{{ upstream }}:8080{% endblock upstream %}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% include "service/#{engine}/latest/#{engine}.yml.twig" with _context only %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

# Tempo runs as user 10001, and docker compose creates the volume as root.
# As such, we need to chown the volume in order for Tempo to start correctly.
tempo-init:
image: &tempoImage grafana/tempo:main-1a21818
user: root
entrypoint:
- "chown"
- "10001:10001"
- "/var/tempo"
volumes:
- {{ serviceName }}-{{ serviceData['engine'] }}-data:/var/tempo:rw

tempo:
image: *tempoImage
command: [ "-config.file=/etc/tempo.yaml" ]
volumes:
- ./${DEPLOYMENT_PATH}/context/otel-stack/tempo.yaml:/etc/tempo.yaml
- {{ serviceName }}-{{ serviceData['engine'] }}-data:/var/tempo:rw
networks:
- private
expose:
- "14268" # jaeger ingest
- "3200" # tempo
- "4317" # otlp grpc
- "4318" # otlp http
- "9411" # zipkin
depends_on:
- tempo-init

collector:
image: otel/opentelemetry-collector:0.86.0
command: [ "--config=/etc/otel-collector.yaml" ]
volumes:
- ./${DEPLOYMENT_PATH}/context/otel-stack/otel-collector.yaml:/etc/otel-collector.yaml
networks:
- private

prometheus:
image: prom/prometheus:latest
command:
- --config.file=/etc/prometheus.yaml
- --web.enable-remote-write-receiver
- --enable-feature=exemplar-storage
networks:
- private
volumes:
- ./${DEPLOYMENT_PATH}/context/otel-stack/prometheus.yaml:/etc/prometheus.yaml
expose:
- "9090"

grafana:
image: grafana/grafana:11.0.0
volumes:
- ./${DEPLOYMENT_PATH}/context/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
networks:
- public
- private
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_DISABLE_LOGIN_FORM=true
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor

expose:
- "3000"

0 comments on commit 3470cd1

Please sign in to comment.