mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 12:10:11 +01:00
[mod] update /stats
This commit is contained in:
parent
461c6fb21e
commit
65c29081cc
@ -135,27 +135,13 @@ def to_percentage(stats, maxvalue):
|
||||
|
||||
|
||||
def get_engines_stats(engine_list):
|
||||
global counter_storage, histogram_storage
|
||||
|
||||
assert counter_storage is not None
|
||||
assert histogram_storage is not None
|
||||
|
||||
list_time = []
|
||||
list_time_http = []
|
||||
list_time_total = []
|
||||
list_result_count = []
|
||||
list_error_count = []
|
||||
list_scores = []
|
||||
list_scores_per_result = []
|
||||
|
||||
max_error_count = max_http_time = max_time_total = max_result_count = max_score = None # noqa
|
||||
max_time_total = max_result_count = None # noqa
|
||||
for engine_name in engine_list:
|
||||
error_count = counter('engine', engine_name, 'search', 'count', 'error')
|
||||
|
||||
if counter('engine', engine_name, 'search', 'count', 'sent') > 0:
|
||||
list_error_count.append({'avg': error_count, 'name': engine_name})
|
||||
max_error_count = max(error_count, max_error_count or 0)
|
||||
|
||||
successful_count = counter('engine', engine_name, 'search', 'count', 'successful')
|
||||
if successful_count == 0:
|
||||
continue
|
||||
@ -163,6 +149,10 @@ def get_engines_stats(engine_list):
|
||||
result_count_sum = histogram('engine', engine_name, 'result', 'count').sum
|
||||
time_total = histogram('engine', engine_name, 'time', 'total').percentage(50)
|
||||
time_http = histogram('engine', engine_name, 'time', 'http').percentage(50)
|
||||
time_total_p80 = histogram('engine', engine_name, 'time', 'total').percentage(80)
|
||||
time_http_p80 = histogram('engine', engine_name, 'time', 'http').percentage(80)
|
||||
time_total_p95 = histogram('engine', engine_name, 'time', 'total').percentage(95)
|
||||
time_http_p95 = histogram('engine', engine_name, 'time', 'http').percentage(95)
|
||||
result_count = result_count_sum / float(successful_count)
|
||||
|
||||
if result_count:
|
||||
@ -172,35 +162,25 @@ def get_engines_stats(engine_list):
|
||||
score = score_per_result = 0.0
|
||||
|
||||
max_time_total = max(time_total, max_time_total or 0)
|
||||
max_http_time = max(time_http, max_http_time or 0)
|
||||
max_result_count = max(result_count, max_result_count or 0)
|
||||
max_score = max(score, max_score or 0)
|
||||
|
||||
list_time.append({'total': round(time_total, 1),
|
||||
'total_p80': round(time_total_p80, 1),
|
||||
'total_p95': round(time_total_p95, 1),
|
||||
'http': round(time_http, 1),
|
||||
'http_p80': round(time_http_p80, 1),
|
||||
'http_p95': round(time_http_p95, 1),
|
||||
'name': engine_name,
|
||||
'processing': round(time_total - time_http, 1)})
|
||||
list_time_total.append({'avg': time_total, 'name': engine_name})
|
||||
list_time_http.append({'avg': time_http, 'name': engine_name})
|
||||
list_result_count.append({'avg': result_count, 'name': engine_name})
|
||||
list_scores.append({'avg': score, 'name': engine_name})
|
||||
list_scores_per_result.append({'avg': score_per_result, 'name': engine_name})
|
||||
|
||||
list_time = sorted(list_time, key=itemgetter('total'))
|
||||
list_time_total = sorted(to_percentage(list_time_total, max_time_total), key=itemgetter('avg'))
|
||||
list_time_http = sorted(to_percentage(list_time_http, max_http_time), key=itemgetter('avg'))
|
||||
list_result_count = sorted(to_percentage(list_result_count, max_result_count), key=itemgetter('avg'), reverse=True)
|
||||
list_scores = sorted(list_scores, key=itemgetter('avg'), reverse=True)
|
||||
list_scores_per_result = sorted(list_scores_per_result, key=itemgetter('avg'), reverse=True)
|
||||
list_error_count = sorted(to_percentage(list_error_count, max_error_count), key=itemgetter('avg'), reverse=True)
|
||||
'processing': round(time_total - time_http, 1),
|
||||
'processing_p80': round(time_total_p80 - time_http_p80, 1),
|
||||
'processing_p95': round(time_total_p95 - time_http_p95, 1),
|
||||
'score': score,
|
||||
'score_per_result': score_per_result,
|
||||
'result_count': result_count,
|
||||
})
|
||||
|
||||
return {
|
||||
'time': list_time,
|
||||
'max_time': math.ceil(max_time_total or 0),
|
||||
'time_total': list_time_total,
|
||||
'time_http': list_time_http,
|
||||
'result_count': list_result_count,
|
||||
'scores': list_scores,
|
||||
'scores_per_result': list_scores_per_result,
|
||||
'error_count': list_error_count,
|
||||
'max_result_count': math.ceil(max_result_count or 0),
|
||||
}
|
||||
|
@ -998,3 +998,21 @@ th:hover .engine-tooltip,
|
||||
padding: 0.4rem 0;
|
||||
width: 1px;
|
||||
}
|
||||
.stacked-bar-chart-serie1 {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
flex-basis: unset;
|
||||
background: #5bc0de;
|
||||
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
padding: 0.4rem 0;
|
||||
}
|
||||
.stacked-bar-chart-serie2 {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
flex-basis: unset;
|
||||
background: #deb15b;
|
||||
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
padding: 0.4rem 0;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -971,6 +971,24 @@ th:hover .engine-tooltip,
|
||||
padding: 0.4rem 0;
|
||||
width: 1px;
|
||||
}
|
||||
.stacked-bar-chart-serie1 {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
flex-basis: unset;
|
||||
background: #5bc0de;
|
||||
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
padding: 0.4rem 0;
|
||||
}
|
||||
.stacked-bar-chart-serie2 {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
flex-basis: unset;
|
||||
background: #deb15b;
|
||||
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
|
||||
padding: 0.4rem 0;
|
||||
}
|
||||
/*Global*/
|
||||
body {
|
||||
background: #1d1f21 none !important;
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
searx/static/themes/oscar/js/searx.min.js
vendored
2
searx/static/themes/oscar/js/searx.min.js
vendored
File diff suppressed because one or more lines are too long
@ -89,3 +89,17 @@ td:hover .engine-tooltip, th:hover .engine-tooltip, .engine-tooltip:hover {
|
||||
padding: 0.4rem 0;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.stacked-bar-chart-serie1 {
|
||||
.stacked-bar-chart-base();
|
||||
background: #5bc0de;
|
||||
box-shadow: inset 0 -1px 0 rgba(0,0,0,.15);
|
||||
padding: 0.4rem 0;
|
||||
}
|
||||
|
||||
.stacked-bar-chart-serie2 {
|
||||
.stacked-bar-chart-base();
|
||||
background: #deb15b;
|
||||
box-shadow: inset 0 -1px 0 rgba(0,0,0,.15);
|
||||
padding: 0.4rem 0;
|
||||
}
|
||||
|
@ -16,30 +16,76 @@
|
||||
<div class="container-fluid">
|
||||
<h1>{{ _('Engine stats') }}</h1>
|
||||
<div class="row">
|
||||
{% for stat_name,stat_category in stats %}
|
||||
<div class="col-xs-12 col-sm-12 col-md-6">
|
||||
<h3>{{ stat_name }}</h3>
|
||||
<div class="container-fluid">
|
||||
{% for engine in stat_category %}
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-md-4">{{ engine.name }}</div>
|
||||
<div class="col-sm-8 col-md-8">
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="{{ '%i'|format(engine.avg) }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ engine.percentage }}%;">
|
||||
{{ '%.02f'|format(engine.avg) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not stat_category %}
|
||||
<div class="col-xs-12 col-sm-12 col-md-12">
|
||||
<div class="table-responsive">
|
||||
{% if not engine_stats.get('time') %}
|
||||
<div class="col-sm-12 col-md-12">
|
||||
{% include 'oscar/messages/no_data_available.html' %}
|
||||
</div>
|
||||
{% else %}
|
||||
<table class="table table-hover table-condensed table-striped">
|
||||
<tr>
|
||||
<th scope="col" style="width:20rem;">{{ _("Engine name") }}</th>
|
||||
<th scope="col" style="width:7rem; text-align: right;">{{ _('Scores') }}</th>
|
||||
<th scope="col">{{ _('Number of results') }}</th>
|
||||
<th scope="col">{{ _('Response time') }}</th>
|
||||
</tr>
|
||||
{% for engine_stat in engine_stats.get('time', []) %}
|
||||
<tr>
|
||||
<td>{{ engine_stat.name }}</td>
|
||||
<td style="text-align: right;">
|
||||
<span aria-labelledby="{{engine_stat.name}}_score" >{{ engine_stat.score|round(1) }}</span>
|
||||
<div class="engine-tooltip text-left" role="tooltip" id="{{engine_name}}_score">{{- "" -}}
|
||||
<p>{{ _('Scores per result') }}: {{ engine_stat.score_per_result | round(3) }}</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="stacked-bar-chart-value">{{- engine_stat.result_count | int -}}</span>{{- "" -}}
|
||||
<span class="stacked-bar-chart" aria-labelledby="{{engine_stat.name}}_chart_result_count" aria-hidden="true">{{- "" -}}
|
||||
<span style="width: calc(max(2px, 100%*{{ (engine_stat.result_count / engine_stats.max_result_count )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}}
|
||||
</span>{{- "" -}}
|
||||
</td>
|
||||
<td>
|
||||
<span class="stacked-bar-chart-value">{{- engine_stat.total | round(1) -}}</span>{{- "" -}}
|
||||
<span class="stacked-bar-chart" aria-labelledby="{{engine_stat.name}}_chart" aria-hidden="true">{{- "" -}}
|
||||
<span style="width: calc(max(2px, 100%*{{ (engine_stat.http / engine_stats.max_time )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}}
|
||||
<span style="width: calc(100%*{{ engine_stat.processing / engine_stats.max_time |round(3) }})" class="stacked-bar-chart-serie2"></span>{{- "" -}}
|
||||
</span>{{- "" -}}
|
||||
<div class="engine-tooltip text-left" role="tooltip" id="{{engine_name}}_chart">{{- "" -}}
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th scope="col"></th>
|
||||
<th scope="col">{{ _('Total') }}</th>
|
||||
<th scope="col">{{ _('HTTP') }}</th>
|
||||
<th scope="col">{{ _('Processing') }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col">{{ _('Median') }}</th>
|
||||
<td>{{ engine_stat.total }}</td>
|
||||
<td>{{ engine_stat.http }}</td>
|
||||
<td>{{ engine_stat.processing }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col">{{ _('P80') }}</th>
|
||||
<td>{{ engine_stat.total_p80 }}</td>
|
||||
<td>{{ engine_stat.http_p80 }}</td>
|
||||
<td>{{ engine_stat.processing_p80 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col">{{ _('P95') }}</th>
|
||||
<td>{{ engine_stat.total_p95 }}</td>
|
||||
<td>{{ engine_stat.http_p95 }}</td>
|
||||
<td>{{ engine_stat.processing_p95 }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -1077,12 +1077,7 @@ def stats():
|
||||
engine_stats = get_engines_stats(filtered_engines)
|
||||
return render(
|
||||
'stats.html',
|
||||
stats=[(gettext('Engine time (sec)'), engine_stats['time_total']),
|
||||
(gettext('Page loads (sec)'), engine_stats['time_http']),
|
||||
(gettext('Number of results'), engine_stats['result_count']),
|
||||
(gettext('Scores'), engine_stats['scores']),
|
||||
(gettext('Scores per result'), engine_stats['scores_per_result']),
|
||||
(gettext('Errors'), engine_stats['error_count'])]
|
||||
engine_stats=engine_stats
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user