Skip to content

Commit

Permalink
Base OTEL docker-compose
Browse files Browse the repository at this point in the history
Creates basic docker-compose that could be used for the local
running/testing opentelemetry output.

It contains Grafana, Grafana Alloy (which has OTEL receivers) and
Prometheus as metric backend.
  • Loading branch information
olegbespalov committed May 15, 2024
1 parent ad0196d commit e91030c
Show file tree
Hide file tree
Showing 6 changed files with 4,201 additions and 0 deletions.
50 changes: 50 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: '3.8'

networks:
k6:

services:
prometheus:
image: prom/prometheus:v2.52.0
command:
- --web.enable-remote-write-receiver
- --enable-feature=native-histograms
- --config.file=/etc/prometheus/prometheus.yml
networks:
- k6
ports:
- "9090:9090"

alloy:
image: grafana/alloy:v1.0.0
networks:
- k6
volumes:
- ./grafana/alloy:/etc/alloy
environment:
REMOTE_WRITE_HOST: prometheus:9090
depends_on:
- prometheus
command:
- run
- /etc/alloy/config.alloy
- --storage.path=/var/lib/alloy/data
- --server.http.listen-addr=0.0.0.0:12345
- --stability.level=experimental # Enable all functionality
ports:
- "12345:12345" # Alloy UI
- "4317:4317" # gRPC receiver
- "4318:4318" # HTTP receiver

grafana:
image: grafana/grafana:10.1.2
networks:
- k6
ports:
- "3000:3000"
environment:
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_BASIC_ENABLED=false
volumes:
- ./grafana:/etc/grafana/provisioning/
44 changes: 44 additions & 0 deletions grafana/alloy/config.alloy
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// expose OTEL receivers
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.receiver.otlp/
otelcol.receiver.otlp "default" {
// configures the default gRPC receiver endpoint "0.0.0.0:4317"
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.receiver.otlp/#grpc-block
grpc {}

// configures the default HTTP receiver endpoint "0.0.0.0:4318"
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.receiver.otlp/#http-block
http {}

output {
metrics = [otelcol.processor.batch.default.input]
}
}

otelcol.processor.batch "default" {
// https://grafana.com/docs/alloy/latest/reference/components/otelcol.processor.batch/
output {
metrics = [otelcol.exporter.prometheus.default.input]
}
}

otelcol.exporter.prometheus "default" {
add_metric_suffixes = false
forward_to = [prometheus.remote_write.default.receiver]
}

// Collect metrics from the local running Alloy instance and forward to
// Prometheus.
prometheus.exporter.self "alloy" {}
prometheus.scrape "alloy" {
targets = prometheus.exporter.self.alloy.targets
forward_to = [prometheus.remote_write.default.receiver]
}

prometheus.remote_write "default" {
endpoint {
url = format(
"http://%s/api/v1/write",
coalesce(env("REMOTE_WRITE_HOST"), "localhost:9090"),
)
}
}
14 changes: 14 additions & 0 deletions grafana/dashboards/dashboards.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# For configuration options, see
# https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards

apiVersion: 1

providers:
# We're defining a directory from which to load file-based dashboards
- name: 'prometheus'
type: file
disableDeletion: false
updateIntervalSeconds: 10
editable: true
options:
path: /etc/grafana/provisioning/dashboards
Loading

0 comments on commit e91030c

Please sign in to comment.