From 0fe54b231f483fb1054c819a8956ab30fece2ab0 Mon Sep 17 00:00:00 2001 From: Ehsan Ansari Basir Date: Sat, 15 Jun 2024 12:47:23 +0200 Subject: [PATCH] add tempo, prometheus and grafana to docker-compose --- .gitignore | 1 + docker-compose.yaml | 50 +++++++++++++++++-- .../grafana-datasources.yaml | 31 ++++++++++++ observability-configs/prometheus.yaml | 13 +++++ observability-configs/tempo.yaml | 43 ++++++++++++++++ 5 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 observability-configs/grafana-datasources.yaml create mode 100644 observability-configs/prometheus.yaml create mode 100644 observability-configs/tempo.yaml diff --git a/.gitignore b/.gitignore index 22573552..afd8e42b 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,5 @@ cmd/docs/* # docker-compose gatewayd-files/ cmd/gatewayd-plugin-cache-linux-amd64-* +tempo-data diff --git a/docker-compose.yaml b/docker-compose.yaml index 96eda460..1d03ee79 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -38,7 +38,7 @@ services: retries: 5 gatewayd: image: gatewaydio/gatewayd:latest - command: ["run", "--config", "/gatewayd-files/gatewayd.yaml", "--plugin-config", "/gatewayd-files/gatewayd_plugins.yaml"] + command: ["run", "--config", "/gatewayd-files/gatewayd.yaml", "--plugin-config", "/gatewayd-files/gatewayd_plugins.yaml", "--tracing", "--collector-url", "tempo:4317"] environment: # For more information about the environment variables, see: # https://docs.gatewayd.io/using-gatewayd/configuration#environment-variables @@ -48,8 +48,8 @@ services: # GatewayD server for PostgreSQL clients to connect to - "15432:15432" # Prometheus metrics: - # http://localhost:9090/metrics - - "9090:9090" + # http://localhost:9090/metrics # Make sure the port is not used by prometheus before uncommenting the following line + # - "9090:9090" # GatewayD HTTP gateway: # http://localhost:18080/swagger-ui/ for the API documentation # http://localhost:18080/healthz for the health check @@ -74,3 +74,47 @@ services: condition: service_healthy install_plugins: condition: service_completed_successfully + + prometheus: + image: prom/prometheus:latest + volumes: + - ./observability-configs/prometheus.yaml:/etc/prometheus/prometheus.yml + ports: + - "9090:9090" + depends_on: + - gatewayd + + tempo_init: + image: &tempoImage grafana/tempo:latest + user: root + entrypoint: + - "chown" + - "10001:10001" + - "/var/tempo" + volumes: + - ./tempo-data:/var/tempo + + tempo: + image: *tempoImage + command: ["-config.file=/etc/tempo.yaml"] + volumes: + - ./observability-configs/tempo.yaml:/etc/tempo.yaml + - ./tempo-data:/var/tempo + ports: + - "4317:4317" # otlp grpc + depends_on: + - tempo_init + + grafana: + image: grafana/grafana:latest + volumes: + - ./observability-configs/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml + environment: + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_DISABLE_LOGIN_FORM=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + ports: + - "3000:3000" + depends_on: + - prometheus + - tempo diff --git a/observability-configs/grafana-datasources.yaml b/observability-configs/grafana-datasources.yaml new file mode 100644 index 00000000..e1606d1c --- /dev/null +++ b/observability-configs/grafana-datasources.yaml @@ -0,0 +1,31 @@ +apiVersion: 1 + +datasources: + - name: GatewayD 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: GatewayD 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 + diff --git a/observability-configs/prometheus.yaml b/observability-configs/prometheus.yaml new file mode 100644 index 00000000..f64370e6 --- /dev/null +++ b/observability-configs/prometheus.yaml @@ -0,0 +1,13 @@ +global: + scrape_interval: 5s + +scrape_configs: + - job_name: "gatewayd-aggregated-metrics" + scrape_interval: 5s + metrics_path: /metrics + static_configs: + - targets: ["gatewayd:9090"] + + - job_name: "tempo" + static_configs: + - targets: ["tempo:3200"] diff --git a/observability-configs/tempo.yaml b/observability-configs/tempo.yaml new file mode 100644 index 00000000..3a387bd0 --- /dev/null +++ b/observability-configs/tempo.yaml @@ -0,0 +1,43 @@ +stream_over_http_enabled: true +server: + http_listen_port: 3200 + log_level: info + +distributor: + receivers: # this configuration will listen on all ports and protocols that tempo is capable of. + otlp: + protocols: + grpc: + +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: + metrics_generator: + processors: [service-graphs, span-metrics, local-blocks] # enables metrics generator