feat: prometheus & grafana minimal setup

This commit is contained in:
Timothy Schenk 2023-11-28 15:32:41 +01:00
parent 5b8880f392
commit 769d0bf21c
10 changed files with 122 additions and 55 deletions

View file

@ -1,18 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Server.db: Compose Deployment" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
<deployment type="docker-compose.yml">
<settings>
<option name="envFilePath" value="" />
<option name="services">
<list>
<option value="db" />
</list>
</option>
<option name="sourceFilePath" value="Server/docker-compose.yml" />
<option name="upDetach" value="false" />
</settings>
</deployment>
<EXTENSION ID="com.jetbrains.rider.docker.debug" isFastModeEnabled="true" isSslEnabled="false" />
<method v="2" />
</configuration>
</component>

View file

@ -1,17 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Server.server: Compose Deployment" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
<deployment type="docker-compose.yml">
<settings>
<option name="envFilePath" value="" />
<option name="services">
<list>
<option value="server" />
</list>
</option>
<option name="sourceFilePath" value="Server/docker-compose.yml" />
</settings>
</deployment>
<EXTENSION ID="com.jetbrains.rider.docker.debug" isFastModeEnabled="true" isSslEnabled="false" />
<method v="2" />
</configuration>
</component>

View file

@ -1,10 +1,10 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Server: Compose Deployment" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker"> <configuration default="false" name="docker-compose.yml: Compose Deployment" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
<deployment type="docker-compose.yml"> <deployment type="docker-compose.yml">
<settings> <settings>
<option name="buildKitEnabledForCompose" value="true" /> <option name="buildKitEnabledForCompose" value="true" />
<option name="envFilePath" value="" /> <option name="envFilePath" value="" />
<option name="sourceFilePath" value="Server/docker-compose.yml" /> <option name="sourceFilePath" value="docker-compose.yml" />
<option name="upDetach" value="false" /> <option name="upDetach" value="false" />
<option name="upRemoveOrphans" value="true" /> <option name="upRemoveOrphans" value="true" />
</settings> </settings>

View file

@ -1,3 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=decryptor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Wonderking/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View file

@ -56,6 +56,7 @@ if (configuration.GetValue<bool>("Tracing:Enabled"))
.WithMetrics(metrics => .WithMetrics(metrics =>
{ {
metrics.AddRuntimeInstrumentation(); metrics.AddRuntimeInstrumentation();
metrics.AddProcessInstrumentation();
}); });
builder.Logging.AddOpenTelemetry(logging => builder.Logging.AddOpenTelemetry(logging =>
@ -70,19 +71,19 @@ if (configuration.GetValue<bool>("Tracing:Enabled"))
{ {
logging.AddOtlpExporter(options => 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 => builder.Services.ConfigureOpenTelemetryMeterProvider(metrics =>
{ {
metrics.AddOtlpExporter(options => 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 => builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
{ {
tracing.AddZipkinExporter(options => tracing.AddZipkinExporter(options =>
options.Endpoint = new Uri(configuration["Zipkin:Endpoint"] ?? string.Empty)); 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));
}); });
} }

View file

@ -96,6 +96,7 @@
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0-alpha.1"/> <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0-alpha.1"/>
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.8"/> <PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.8"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.6.0-beta.3"/> <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.6.0-beta.3"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Process" Version="1.0.0-alpha.6" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.1"/> <PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.1"/>
<PackageReference Include="OpenTelemetry.PersistentStorage.FileSystem" Version="1.0.0"/> <PackageReference Include="OpenTelemetry.PersistentStorage.FileSystem" Version="1.0.0"/>
<PackageReference Include="OpenTelemetry.ResourceDetectors.Container" Version="1.0.0-beta.4"/> <PackageReference Include="OpenTelemetry.ResourceDetectors.Container" Version="1.0.0-beta.4"/>

View file

@ -14,7 +14,9 @@ services:
- DB:Password=continuity - DB:Password=continuity
- Game:Data:Path=/app/data/ - Game:Data:Path=/app/data/
- Tracing:Enabled=true - 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 - Zipkin:Endpoint=http://zipkin:9411/api/v2/spans
networks: networks:
- continuity - continuity
@ -22,17 +24,14 @@ services:
- 10001:10001 - 10001:10001
volumes: volumes:
- type: bind - type: bind
source: ../wk-data source: wk-data
target: /app/data target: /app/data
read_only: true read_only: true
- type: bind - type: bind
source: ../wk-logs source: config
target: /app/logs
read_only: false
- type: bind
source: ../config
target: /app/config target: /app/config
read_only: true read_only: true
mem_limit: 100m
db: db:
container_name: continuity-db container_name: continuity-db
@ -58,14 +57,12 @@ services:
container_name: continuity-jaeger container_name: continuity-jaeger
image: jaegertracing/all-in-one:1.51.0 image: jaegertracing/all-in-one:1.51.0
restart: always restart: always
depends_on:
- server
- prometheus
networks: networks:
- continuity - continuity
expose: expose:
- 6831
- 6832
- 5778
- 4317
- 4318
- 14250 - 14250
- 14268 - 14268
- 14269 - 14269
@ -73,6 +70,11 @@ services:
- 16686:16686 - 16686:16686
environment: environment:
- COLLECTOR_OTLP_ENABLED=true - 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: zipkin:
container_name: continuity-zipkin container_name: continuity-zipkin
@ -83,9 +85,55 @@ services:
networks: networks:
- continuity - 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: networks:
continuity: continuity:
volumes: volumes:
db-data: db-data:
prom-data: prom-data:
server-logs:

8
otlp/datasource.yml Normal file
View file

@ -0,0 +1,8 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus:9090
isDefault: true
access: proxy
editable: true

39
otlp/otel-config.yaml Normal file
View file

@ -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 ]

8
otlp/prometheus.yml Normal file
View file

@ -0,0 +1,8 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'otel-collector'
static_configs:
- targets: [ 'otel-collector:9091' ]