-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently the scrape path is still hard coded. This commit just flushes the local repository copy. * Dashboards and datasources are provisioned via files. * Example metric for snapshot of running games is given. * User arrival doesn't happen on path '^/metrics/'.
- Loading branch information
Showing
17 changed files
with
293 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
connect-four_metrics: | ||
path: /metrics/connect-four | ||
methods: | ||
- GET | ||
defaults: | ||
_controller: connect-four.metrics-controller::metricsAction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
|
||
connect-four.metrics-controller: | ||
class: Gaming\ConnectFour\Port\Adapter\Http\MetricsController | ||
arguments: | ||
- '@connect-four.query-bus' | ||
tags: | ||
- 'controller.service_arguments' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
WebInterface: | ||
resource: web-interface/routing.yml | ||
Gaming: | ||
resource: '*/routing.yml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM grafana/grafana-oss:8.5.2 | ||
|
||
COPY /docker/grafana/provisioning /etc/grafana/provisioning | ||
COPY /docker/grafana/dashboards /var/lib/grafana/dashboards |
136 changes: 136 additions & 0 deletions
136
docker/grafana/dashboards/connect-four/application-metrics.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{ | ||
"annotations": { | ||
"list": [ | ||
{ | ||
"builtIn": 1, | ||
"datasource": { | ||
"type": "grafana", | ||
"uid": "-- Grafana --" | ||
}, | ||
"enable": true, | ||
"hide": true, | ||
"iconColor": "rgba(0, 211, 255, 1)", | ||
"name": "Annotations & Alerts", | ||
"target": { | ||
"limit": 100, | ||
"matchAny": false, | ||
"tags": [], | ||
"type": "dashboard" | ||
}, | ||
"type": "dashboard" | ||
} | ||
] | ||
}, | ||
"editable": true, | ||
"fiscalYearStartMonth": 0, | ||
"graphTooltip": 0, | ||
"id": 3, | ||
"links": [], | ||
"liveNow": false, | ||
"panels": [ | ||
{ | ||
"datasource": { | ||
"type": "prometheus", | ||
"uid": "prometheus" | ||
}, | ||
"fieldConfig": { | ||
"defaults": { | ||
"color": { | ||
"mode": "palette-classic" | ||
}, | ||
"custom": { | ||
"axisLabel": "", | ||
"axisPlacement": "auto", | ||
"barAlignment": 0, | ||
"drawStyle": "line", | ||
"fillOpacity": 0, | ||
"gradientMode": "none", | ||
"hideFrom": { | ||
"legend": false, | ||
"tooltip": false, | ||
"viz": false | ||
}, | ||
"lineInterpolation": "linear", | ||
"lineWidth": 1, | ||
"pointSize": 5, | ||
"scaleDistribution": { | ||
"type": "linear" | ||
}, | ||
"showPoints": "auto", | ||
"spanNulls": false, | ||
"stacking": { | ||
"group": "A", | ||
"mode": "none" | ||
}, | ||
"thresholdsStyle": { | ||
"mode": "off" | ||
} | ||
}, | ||
"mappings": [], | ||
"thresholds": { | ||
"mode": "absolute", | ||
"steps": [ | ||
{ | ||
"color": "green", | ||
"value": null | ||
}, | ||
{ | ||
"color": "red", | ||
"value": 80 | ||
} | ||
] | ||
} | ||
}, | ||
"overrides": [] | ||
}, | ||
"gridPos": { | ||
"h": 9, | ||
"w": 12, | ||
"x": 0, | ||
"y": 0 | ||
}, | ||
"id": 2, | ||
"interval": "5s", | ||
"options": { | ||
"legend": { | ||
"calcs": [], | ||
"displayMode": "list", | ||
"placement": "bottom" | ||
}, | ||
"tooltip": { | ||
"mode": "single", | ||
"sort": "none" | ||
} | ||
}, | ||
"targets": [ | ||
{ | ||
"datasource": { | ||
"type": "prometheus", | ||
"uid": "prometheus" | ||
}, | ||
"expr": "running_games{domain=\"connect-four\"}", | ||
"refId": "A" | ||
} | ||
], | ||
"title": "Number of running games", | ||
"type": "timeseries" | ||
} | ||
], | ||
"refresh": "5s", | ||
"schemaVersion": 1, | ||
"style": "dark", | ||
"tags": [], | ||
"templating": { | ||
"list": [] | ||
}, | ||
"time": { | ||
"from": "now-15m", | ||
"to": "now" | ||
}, | ||
"timepicker": {}, | ||
"timezone": "", | ||
"title": "Application metrics", | ||
"uid": "BPTAtVX7z", | ||
"version": 1, | ||
"weekStart": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: 1 | ||
|
||
providers: | ||
- name: File | ||
type: file | ||
disableDeletion: true | ||
updateIntervalSeconds: 5 | ||
allowUiUpdates: false | ||
options: | ||
path: /var/lib/grafana/dashboards | ||
foldersFromFilesStructure: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: Prometheus | ||
type: prometheus | ||
isDefault: true | ||
access: proxy | ||
uid: prometheus | ||
url: http://prometheus:9090 | ||
version: 1 | ||
editable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM prom/prometheus:v2.35.0 | ||
|
||
COPY /docker/prometheus/prometheus.yml /etc/prometheus/prometheus.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
global: | ||
scrape_interval: 1m | ||
|
||
scrape_configs: | ||
- job_name: 'prometheus' | ||
scrape_interval: 5s | ||
static_configs: | ||
- targets: ['localhost:9090'] | ||
- job_name: 'connect-four' | ||
scrape_interval: 5s | ||
metrics_path: '/metrics/connect-four' | ||
static_configs: | ||
- targets: ['traefik'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Gaming\ConnectFour\Port\Adapter\Http; | ||
|
||
use Gaming\Common\Bus\Bus; | ||
use Gaming\ConnectFour\Application\Game\Query\Model\RunningGames\RunningGames; | ||
use Gaming\ConnectFour\Application\Game\Query\RunningGamesQuery; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
final class MetricsController | ||
{ | ||
public function __construct( | ||
private readonly Bus $queryBus | ||
) { | ||
} | ||
|
||
public function metricsAction(Request $request): Response | ||
{ | ||
$runningGames = $this->queryBus->handle(new RunningGamesQuery()); | ||
assert($runningGames instanceof RunningGames); | ||
|
||
$metrics = sprintf( | ||
'# HELP running_games Number of running games.' . PHP_EOL . | ||
'# TYPE running_games gauge' . PHP_EOL . | ||
'running_games{domain="connect-four"} %s ' . PHP_EOL, | ||
$runningGames->count() | ||
); | ||
|
||
return new Response( | ||
$metrics, | ||
200, | ||
['content-type' => 'text/plain'] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters