-
-
Notifications
You must be signed in to change notification settings - Fork 203
feat: Add Prometheus #2440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Add Prometheus #2440
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
331470e
Add prometheus endpoint
svenvg93 f52fd91
Merge branch 'alexjustesen:main' into feat/prometheus
svenvg93 d9c8dff
Merge branch 'alexjustesen:main' into feat/prometheus
svenvg93 39a737c
Switch to events
svenvg93 6778123
Add basic auth
svenvg93 2d61b98
Merge branch 'main' into feat/prometheus
svenvg93 4a45e3c
Text update
svenvg93 94df45d
Merge branch 'main' into feat/prometheus
svenvg93 83fc3f1
pint cause we lint
svenvg93 7048f99
update the ui to tabs
svenvg93 9a1758a
Merge branch 'main' into feat/prometheus
alexjustesen edcfabb
Merge branch 'main' into feat/prometheus
svenvg93 1a0170d
Merge branch 'main' into feat/prometheus
svenvg93 eaf506c
Merge branch 'alexjustesen:main' into feat/prometheus
svenvg93 ca38f89
Merge branch 'alexjustesen:main' into feat/prometheus
svenvg93 789cee8
Merge branch 'alexjustesen:main' into feat/prometheus
svenvg93 5edca89
restore helpertext
svenvg93 cec922d
Merge branch 'alexjustesen:main' into feat/prometheus
svenvg93 e93b170
add allowed ips instead of basic auth
svenvg93 92f13c5
update endpoint in the tests
svenvg93 a7d59d9
use import
svenvg93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,28 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Services\PrometheusMetricsService; | ||
| use App\Settings\DataIntegrationSettings; | ||
| use Illuminate\Http\Response; | ||
|
|
||
| class MetricsController extends Controller | ||
| { | ||
| public function __construct( | ||
| protected PrometheusMetricsService $metricsService, | ||
| protected DataIntegrationSettings $settings | ||
| ) {} | ||
|
|
||
| public function __invoke(): Response | ||
| { | ||
| if (! $this->settings->prometheus_enabled) { | ||
| abort(404); | ||
| } | ||
|
|
||
| $metrics = $this->metricsService->generateMetrics(); | ||
|
|
||
| return response($metrics, 200, [ | ||
| 'Content-Type' => 'text/plain; version=0.0.4; charset=utf-8', | ||
| ]); | ||
| } | ||
| } |
This file contains hidden or 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,43 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Middleware; | ||
|
|
||
| use App\Helpers\Network; | ||
| use App\Settings\DataIntegrationSettings; | ||
| use Closure; | ||
| use Illuminate\Http\Request; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| class PrometheusAllowedIpMiddleware | ||
| { | ||
| public function __construct( | ||
| protected DataIntegrationSettings $settings | ||
| ) {} | ||
|
|
||
| /** | ||
| * Handle an incoming request. | ||
| * | ||
| * @param Closure(Request):Response $next | ||
| */ | ||
| public function handle(Request $request, Closure $next): Response | ||
| { | ||
| if (blank($this->settings->prometheus_allowed_ips)) { | ||
| return $next($request); | ||
| } | ||
|
|
||
| $clientIp = $request->ip(); | ||
| $allowedIps = $this->settings->prometheus_allowed_ips; | ||
|
|
||
| foreach ($allowedIps as $allowedIp) { | ||
| if (str_contains($allowedIp, '/')) { | ||
| if (Network::ipInRange($clientIp, $allowedIp)) { | ||
| return $next($request); | ||
| } | ||
| } elseif ($clientIp === $allowedIp) { | ||
| return $next($request); | ||
| } | ||
| } | ||
|
|
||
| abort(403); | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.