Skip to content

feat: integrate grafana and prometheus#60

Merged
Dejmenek merged 6 commits into
mainfrom
57-add-support-for-grafana-and-prometheus-integration
May 13, 2026
Merged

feat: integrate grafana and prometheus#60
Dejmenek merged 6 commits into
mainfrom
57-add-support-for-grafana-and-prometheus-integration

Conversation

@Dejmenek
Copy link
Copy Markdown
Owner

Summary

Implements OTLP metrics export to Prometheus and visualization with Grafana, refactors tournament metrics tracking, and provides local observability setup and documentation.

Changes

  • TelemetryExtensions.cs: Switched from console to OTLP exporter for metrics, targeting Prometheus.
  • TournamentMetrics.cs and TournamentMutations.cs: Refactored metrics logic to use UpDownCounter and explicit open/close tracking methods, removing DB dependency.
  • docker-compose.yml and prometheus.yml: Added configuration for local Prometheus (with OTLP receiver) and Grafana.
  • README.md: Added instructions for running the API with Prometheus and Grafana for metrics visualization.

Dejmenek added 6 commits May 12, 2026 21:38
Added OpenTelemetry.Exporter.OpenTelemetryProtocol (v1.15.3) to enable exporting telemetry data using the OpenTelemetry Protocol (OTLP). Updated Directory.Packages.props, TournamentAPI.csproj, and packages.lock.json to reflect this addition. This allows integration with observability backends such as Jaeger, Prometheus, or OpenTelemetry Collector.
Added Prometheus and Grafana services to docker-compose.yml for monitoring and visualization. Configured Prometheus with OTLP receiver and persistent storage. Exposed ports 5431 (Prometheus) and 3000 (Grafana). Defined named volumes for data persistence.
Refactor TournamentMetrics to use an UpDownCounter for tracking active tournaments instead of an observable gauge. Remove database polling and update the metric in real-time by calling TournamentOpened() and TournamentClosed() when tournaments are created, updated, or deleted. Inject TournamentMetrics into mutation methods to support this change. This improves accuracy and performance of the active tournaments metric.
Removed TournamentMetrics as a hosted service, keeping only its singleton registration. Replaced the console metrics exporter with an OTLP exporter configured for HTTP Protobuf, sending metrics to http://localhost:5431/api/v1/otlp/v1/metrics.
Added global scrape_interval of 15s in prometheus.yml. Configured a new 'prometheus' job with HTTP scheme, 10s scrape interval, 5s scrape timeout, and static target 'localhost:9090'.
Added a "Running the API" section to the README with detailed steps for starting Prometheus and Grafana via Docker Compose, running the .NET 9 API, and connecting Grafana to Prometheus for metrics visualization. Includes prerequisites and service URLs for easier setup.
@Dejmenek Dejmenek linked an issue May 13, 2026 that may be closed by this pull request
@Dejmenek Dejmenek merged commit 4dbcf3a into main May 13, 2026
2 checks passed
@Dejmenek Dejmenek deleted the 57-add-support-for-grafana-and-prometheus-integration branch May 13, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Grafana and Prometheus integration

1 participant