Commit 8458e5c7 authored by Dominik Hebeler's avatar Dominik Hebeler

Added metric to track returne results

parent 0a8c463d
......@@ -11,3 +11,7 @@ service:
commonName: ""
externalPort: 80
internalPort: 80
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "80"
......@@ -122,6 +122,10 @@ class MetaGerSearch extends Controller
dd($timings);
}
\Prometheus\CollectorRegistry::getDefault()
->getOrRegisterCounter('metager', 'result_counter', 'counts total number of returned results')
->incBy(sizeof($metager->getResults()));
return $resultpage;
}
......@@ -183,6 +187,7 @@ class MetaGerSearch extends Controller
];
$result["nextSearchLink"] = $metager->nextSearchLink();
$newResults = 0;
foreach ($metager->getResults() as $index => $resultTmp) {
if ($resultTmp->new) {
if ($metager->getFokus() !== "bilder") {
......@@ -196,9 +201,14 @@ class MetaGerSearch extends Controller
$result['newResults'][$index] = $html;
$result["imagesearch"] = true;
}
$newResults++;
}
}
\Prometheus\CollectorRegistry::getDefault()
->getOrRegisterCounter('metager', 'result_counter', 'counts total number of returned results')
->incBy($newResults)
$finished = true;
foreach ($engines as $engine) {
if (!$engine->loaded) {
......
......@@ -234,4 +234,14 @@ Route::group(
->header('Content-Type', 'text/plain');
});
});
Route::get('metrics', function() {
$registry = \Prometheus\CollectorRegistry::getDefault();
$renderer = new RenderTextFormat();
$result = $renderer->render($registry->getMetricFamilySamples());
return response($result, 200)
->header('Content-Type', RenderTextFormat::MIME_TYPE);
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment