From 769d0bf21cc3c9c44bf26ef91eeda33663bf031e Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Tue, 28 Nov 2023 15:32:41 +0100 Subject: [PATCH] feat: prometheus & grafana minimal setup --- .run/Server.db_ Compose Deployment.run.xml | 18 ----- .../Server.server_ Compose Deployment.run.xml | 17 ----- ...r-compose.yml_ Compose Deployment.run.xml} | 4 +- Continuity.sln.DotSettings | 3 - Server/Program.cs | 7 +- Server/Server.csproj | 1 + .../docker-compose.yml => docker-compose.yml | 72 +++++++++++++++---- otlp/datasource.yml | 8 +++ otlp/otel-config.yaml | 39 ++++++++++ otlp/prometheus.yml | 8 +++ 10 files changed, 122 insertions(+), 55 deletions(-) delete mode 100644 .run/Server.db_ Compose Deployment.run.xml delete mode 100644 .run/Server.server_ Compose Deployment.run.xml rename .run/{Server_ Compose Deployment.run.xml => docker-compose.yml_ Compose Deployment.run.xml} (80%) delete mode 100644 Continuity.sln.DotSettings rename Server/docker-compose.yml => docker-compose.yml (50%) create mode 100644 otlp/datasource.yml create mode 100644 otlp/otel-config.yaml create mode 100644 otlp/prometheus.yml diff --git a/.run/Server.db_ Compose Deployment.run.xml b/.run/Server.db_ Compose Deployment.run.xml deleted file mode 100644 index e9a1da3..0000000 --- a/.run/Server.db_ Compose Deployment.run.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.run/Server.server_ Compose Deployment.run.xml b/.run/Server.server_ Compose Deployment.run.xml deleted file mode 100644 index 5e00ed4..0000000 --- a/.run/Server.server_ Compose Deployment.run.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.run/Server_ Compose Deployment.run.xml b/.run/docker-compose.yml_ Compose Deployment.run.xml similarity index 80% rename from .run/Server_ Compose Deployment.run.xml rename to .run/docker-compose.yml_ Compose Deployment.run.xml index 6da7b0d..b09ae53 100644 --- a/.run/Server_ Compose Deployment.run.xml +++ b/.run/docker-compose.yml_ Compose Deployment.run.xml @@ -1,10 +1,10 @@  - + diff --git a/Continuity.sln.DotSettings b/Continuity.sln.DotSettings deleted file mode 100644 index 103c6e2..0000000 --- a/Continuity.sln.DotSettings +++ /dev/null @@ -1,3 +0,0 @@ - - True - True \ No newline at end of file diff --git a/Server/Program.cs b/Server/Program.cs index 212fc75..3327bb6 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -56,6 +56,7 @@ if (configuration.GetValue("Tracing:Enabled")) .WithMetrics(metrics => { metrics.AddRuntimeInstrumentation(); + metrics.AddProcessInstrumentation(); }); builder.Logging.AddOpenTelemetry(logging => @@ -70,19 +71,19 @@ if (configuration.GetValue("Tracing:Enabled")) { logging.AddOtlpExporter(options => { - options.Endpoint = new Uri(configuration["OTLP:Endpoint"] ?? string.Empty); + options.Endpoint = new Uri(configuration["OTLP:Logging:Endpoint"] ?? string.Empty); }); }); builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => { metrics.AddOtlpExporter(options => - options.Endpoint = new Uri(configuration["OTLP:Endpoint"] ?? string.Empty)); + options.Endpoint = new Uri(configuration["OTLP:Metrics:Endpoint"] ?? string.Empty)); }); builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => { tracing.AddZipkinExporter(options => options.Endpoint = new Uri(configuration["Zipkin:Endpoint"] ?? string.Empty)); - tracing.AddOtlpExporter(options => options.Endpoint = new Uri(configuration["OTLP:Endpoint"] ?? string.Empty)); + tracing.AddOtlpExporter(options => options.Endpoint = new Uri(configuration["OTLP:Tracing:Endpoint"] ?? string.Empty)); }); } diff --git a/Server/Server.csproj b/Server/Server.csproj index c6ea36c..37ca425 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -96,6 +96,7 @@ + diff --git a/Server/docker-compose.yml b/docker-compose.yml similarity index 50% rename from Server/docker-compose.yml rename to docker-compose.yml index bd51431..cbf029a 100644 --- a/Server/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,9 @@ services: - DB:Password=continuity - Game:Data:Path=/app/data/ - Tracing:Enabled=true - - OTLP:Endpoint=http://jaeger:4317 + - OTLP:Tracing:Endpoint=http://otel-collector:4317 + - OTLP:Logging:Endpoint=http://otel-collector:4317 + - OTLP:Metrics:Endpoint=http://otel-collector:4317 - Zipkin:Endpoint=http://zipkin:9411/api/v2/spans networks: - continuity @@ -22,17 +24,14 @@ services: - 10001:10001 volumes: - type: bind - source: ../wk-data + source: wk-data target: /app/data read_only: true - type: bind - source: ../wk-logs - target: /app/logs - read_only: false - - type: bind - source: ../config + source: config target: /app/config read_only: true + mem_limit: 100m db: container_name: continuity-db @@ -58,14 +57,12 @@ services: container_name: continuity-jaeger image: jaegertracing/all-in-one:1.51.0 restart: always + depends_on: + - server + - prometheus networks: - continuity expose: - - 6831 - - 6832 - - 5778 - - 4317 - - 4318 - 14250 - 14268 - 14269 @@ -73,6 +70,11 @@ services: - 16686:16686 environment: - COLLECTOR_OTLP_ENABLED=true + - METRICS_STORAGE_TYPE=prometheus + - PROMETHEUS_SERVER_URL=http://prometheus:9090 + - PROMETHEUS_QUERY_SUPPORT_SPANMETRICS_CONNECTOR=true + - PROMETHEUS_QUERY_NORMALIZE_CALLS=true + - PROMETHEUS_QUERY_NORMALIZE_DURATION=true zipkin: container_name: continuity-zipkin @@ -83,9 +85,55 @@ services: networks: - continuity + prometheus: + container_name: continuity-prometheus + image: prom/prometheus:latest + restart: always + depends_on: + - server + ports: + - 9090:9090 + volumes: + - prom-data:/prometheus + - ./otlp/prometheus.yml:/etc/prometheus/prometheus.yml + networks: + - continuity + + otel-collector: + container_name: continuity-otel-collector + image: otel/opentelemetry-collector-contrib:0.89.0 + restart: always + depends_on: + - prometheus + ports: + - 14278:14278 + - 4317:4317 + - 9091:9091 + volumes: + - ./otlp/otel-config.yaml:/etc/otel-config.yaml + command: [ "--config=/etc/otel-config.yaml" ] + networks: + - continuity + + grafana: + networks: + - continuity + image: grafana/grafana:latest + depends_on: + - prometheus + volumes: + - ./otlp/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yaml + environment: + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + - GF_AUTH_DISABLE_LOGIN_FORM=true + ports: + - 3000:3000 + networks: continuity: volumes: db-data: prom-data: + server-logs: diff --git a/otlp/datasource.yml b/otlp/datasource.yml new file mode 100644 index 0000000..9828310 --- /dev/null +++ b/otlp/datasource.yml @@ -0,0 +1,8 @@ +apiVersion: 1 +datasources: + - name: Prometheus + type: prometheus + url: http://prometheus:9090 + isDefault: true + access: proxy + editable: true diff --git a/otlp/otel-config.yaml b/otlp/otel-config.yaml new file mode 100644 index 0000000..0003a8a --- /dev/null +++ b/otlp/otel-config.yaml @@ -0,0 +1,39 @@ +receivers: + otlp: + protocols: + grpc: + http: + jaeger: + protocols: + thrift_http: + endpoint: otel-collector:14278 + + +exporters: + prometheus: + endpoint: otel-collector:9091 + zipkin: + endpoint: "http://zipkin:9411/api/v2/spans" + format: proto + otlp: + endpoint: jaeger:4317 + tls: + insecure: true + +processors: + batch: + +extensions: + health_check: + +service: + extensions: [ health_check ] + pipelines: + traces: + receivers: [ otlp, jaeger ] + processors: [ batch ] + exporters: [ otlp, zipkin ] + metrics: + receivers: [ otlp ] + processors: [ batch ] + exporters: [ prometheus ] diff --git a/otlp/prometheus.yml b/otlp/prometheus.yml new file mode 100644 index 0000000..be6cf35 --- /dev/null +++ b/otlp/prometheus.yml @@ -0,0 +1,8 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: 'otel-collector' + static_configs: + - targets: [ 'otel-collector:9091' ]