diff --git a/observability/config.river b/observability/config.river new file mode 100644 index 000000000..f6a26796a --- /dev/null +++ b/observability/config.river @@ -0,0 +1,51 @@ +//Basic authentication +otelcol.auth.basic "grafana_auth" { + username = env("GRAFANA_CLOUD_INSTANCE_ID") + password = env("GRAFANA_CLOUD_API_TOKEN") +} + + +// Define the 'Receiver' ingesting the data sent out from our app +otelcol.receiver.otlp "default" { + // configures the default grpc endpoint "0.0.0.0:4317" + grpc { } + // configures the default http/protobuf endpoint "0.0.0.0:4318" + http { } + + + output { + traces = [otelcol.processor.batch.default.input] + } +} + + +//The 'processor' optimizes the network throughput by batching the output +otelcol.processor.batch "default" { + output { + traces = [otelcol.exporter.otlp.digma.input,otelcol.exporter.otlphttp.grafana_cloud.input] + } +} + + +//Our two exporters will send the data both to Digma (to analytize our code observability, and to our Grafana cloud instance + + +otelcol.exporter.otlp "digma" { + // Send traces to Digma without TLS enabled. + client { + endpoint = env("DIGMA_OTLP_ENDPOINT") + + + tls { + insecure = true + } + } +} + + +otelcol.exporter.otlphttp "grafana_cloud" { + client { + endpoint = env("GRAFANA_CLOUD_OTLP_ENDPOINT") + auth = otelcol.auth.basic.grafana_auth.handler + } +} diff --git a/observability/docker-compose.yml b/observability/docker-compose.yml new file mode 100644 index 000000000..50e2ddb0e --- /dev/null +++ b/observability/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3.6" +services: + grafana-agent: + image: grafana/agent:latest + restart: always + command: + - run + - --server.http.listen-addr=0.0.0.0:12345 + - /etc/agent/config.river + volumes: + - ./config.river:/etc/agent/config.river + ports: + - "12345:12345" + - "4317:4317" + extra_hosts: + - "host.docker.internal:host-gateway" + environment: + - AGENT_MODE=flow + - DIGMA_OTLP_ENDPOINT=host.docker.internal:5050 + - GRAFANA_CLOUD_OTLP_ENDPOINT=--REPLACE_WITH_ENDPOINT-- + - GRAFANA_CLOUD_API_TOKEN=${GRAFANA_CLOUD_API_TOKEN} + - GRAFANA_CLOUD_INSTANCE_ID=--REPLACE_WITH_INSTANCE_ID--