Compare commits

...

5 Commits

Author SHA1 Message Date
Bnyro c30177ddd4
Merge 443fcc7233 into 4b57bc3db1 2024-11-15 13:23:27 +01:00
dependabot[bot] 4b57bc3db1 [upd] pypi: Bump flask from 3.0.3 to 3.1.0
Bumps [flask](https://github.com/pallets/flask) from 3.0.3 to 3.1.0.
- [Release notes](https://github.com/pallets/flask/releases)
- [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/flask/compare/3.0.3...3.1.0)

---
updated-dependencies:
- dependency-name: flask
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-15 13:23:24 +01:00
searxng-bot a345cbbe51 [l10n] update translations from Weblate
0216898a3 - 2024-11-14 - KhietVo <KhietVo@users.noreply.translate.codeberg.org>
3293db4c8 - 2024-11-14 - return42 <return42@users.noreply.translate.codeberg.org>
574e0d683 - 2024-11-13 - lrnz2 <lrnz2@users.noreply.translate.codeberg.org>
a32d9d158 - 2024-11-08 - Aadniz <Aadniz@users.noreply.translate.codeberg.org>
2024-11-15 13:20:52 +01:00
Nicolas Dato abd9b271bc [fix] engine: duckduckgo - only uses first word of the search terms
during the revision in PR #3955 the query string was accidentally converted into
a list of words, further the query must be quoted before POSTed in the ``data``
field, see ``urllib.parse.quote_plus`` [1]

[1] https://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote_plus

Closed: #4009
Co-Authored-by: @return42
2024-11-14 09:33:54 +01:00
Bnyro 443fcc7233 [feat] metrics: support for open metrics 2024-10-15 11:34:17 +02:00
15 changed files with 198 additions and 82 deletions

View File

@ -1,7 +1,7 @@
certifi==2024.8.30
babel==2.16.0
flask-babel==4.0.0
flask==3.0.3
flask==3.1.0
jinja2==3.1.4
lxml==5.3.0
pygments==2.18.0

View File

@ -6,7 +6,7 @@ DuckDuckGo Lite
from typing import TYPE_CHECKING
import re
from urllib.parse import urlencode
from urllib.parse import urlencode, quote_plus
import json
import babel
import lxml.html
@ -245,10 +245,12 @@ def request(query, params):
# Advanced search syntax ends in CAPTCHA
# https://duckduckgo.com/duckduckgo-help-pages/results/syntax/
query = [
query = " ".join(
[
x.removeprefix("site:").removeprefix("intitle:").removeprefix("inurl:").removeprefix("filetype:")
for x in query.split()
]
)
eng_region = traits.get_region(params['searxng_locale'], traits.all_locale)
if eng_region == "wt-wt":
# https://html.duckduckgo.com/html sets an empty value for "all".
@ -261,7 +263,7 @@ def request(query, params):
params['url'] = url
params['method'] = 'POST'
params['data']['q'] = query
params['data']['q'] = quote_plus(query)
# The API is not documented, so we do some reverse engineering and emulate
# what https://html.duckduckgo.com/html does when you press "next Page" link

View File

@ -8,6 +8,7 @@ from timeit import default_timer
from operator import itemgetter
from searx.engines import engines
from searx.openmetrics import OpenMetricsFamily
from .models import HistogramStorage, CounterStorage, VoidHistogram, VoidCounterStorage
from .error_recorder import count_error, count_exception, errors_per_engines
@ -149,7 +150,9 @@ def get_reliabilities(engline_name_list, checker_results):
checker_result = checker_results.get(engine_name, {})
checker_success = checker_result.get('success', True)
errors = engine_errors.get(engine_name) or []
if counter('engine', engine_name, 'search', 'count', 'sent') == 0:
sent_count = counter('engine', engine_name, 'search', 'count', 'sent')
if sent_count == 0:
# no request
reliability = None
elif checker_success and not errors:
@ -164,8 +167,9 @@ def get_reliabilities(engline_name_list, checker_results):
reliabilities[engine_name] = {
'reliability': reliability,
'sent_count': sent_count,
'errors': errors,
'checker': checker_results.get(engine_name, {}).get('errors', {}),
'checker': checker_result.get('errors', {}),
}
return reliabilities
@ -245,3 +249,53 @@ def get_engines_stats(engine_name_list):
'max_time': math.ceil(max_time_total or 0),
'max_result_count': math.ceil(max_result_count or 0),
}
def openmetrics(engine_stats, engine_reliabilities):
metrics = [
OpenMetricsFamily(
key="searxng_engines_response_time_total_seconds",
type_hint="gauge",
help_hint="The average total response time of the engine",
data_info=[{'engine_name': engine['name']} for engine in engine_stats['time']],
data=[engine['total'] for engine in engine_stats['time']],
),
OpenMetricsFamily(
key="searxng_engines_response_time_processing_seconds",
type_hint="gauge",
help_hint="The average processing response time of the engine",
data_info=[{'engine_name': engine['name']} for engine in engine_stats['time']],
data=[engine['processing'] for engine in engine_stats['time']],
),
OpenMetricsFamily(
key="searxng_engines_response_time_http_seconds",
type_hint="gauge",
help_hint="The average HTTP response time of the engine",
data_info=[{'engine_name': engine['name']} for engine in engine_stats['time']],
data=[engine['http'] for engine in engine_stats['time']],
),
OpenMetricsFamily(
key="searxng_engines_result_count_total",
type_hint="counter",
help_hint="The total amount of results returned by the engine",
data_info=[{'engine_name': engine['name']} for engine in engine_stats['time']],
data=[engine['result_count'] for engine in engine_stats['time']],
),
OpenMetricsFamily(
key="searxng_engines_request_count_total",
type_hint="counter",
help_hint="The total amount of user requests made to this engine",
data_info=[{'engine_name': engine['name']} for engine in engine_stats['time']],
data=[engine_reliabilities.get(engine['name'], {}).get('sent_count', 0) for engine in engine_stats['time']],
),
OpenMetricsFamily(
key="searxng_engines_reliability_total",
type_hint="counter",
help_hint="The overall reliability of the engine",
data_info=[{'engine_name': engine['name']} for engine in engine_stats['time']],
data=[
engine_reliabilities.get(engine['name'], {}).get('reliability', 0) for engine in engine_stats['time']
],
),
]
return "".join([str(metric) for metric in metrics])

35
searx/openmetrics.py Normal file
View File

@ -0,0 +1,35 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Module providing support for displaying data in OpenMetrics format"""
class OpenMetricsFamily: # pylint: disable=too-few-public-methods
"""A family of metrics.
The key parameter is the metric name that should be used (snake case).
The type_hint parameter must be one of 'counter', 'gauge', 'histogram', 'summary'.
The help_hint parameter is a short string explaining the metric.
The data_info parameter is a dictionary of descriptionary parameters for the data point (e.g. request method/path).
The data parameter is a flat list of the actual data in shape of a primive type.
See https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md for more information.
"""
def __init__(self, key: str, type_hint: str, help_hint: str, data_info: list, data: list):
self.key = key
self.type_hint = type_hint
self.help_hint = help_hint
self.data_info = data_info
self.data = data
def __str__(self):
text_representation = f"""# HELP {self.key} {self.help_hint}
# TYPE {self.key} {self.type_hint}
"""
for i in range(0, len(self.data_info)):
if not self.data[i] and self.data[i] != 0:
continue
info_representation = ','.join([f"{key}=\"{value}\"" for (key, value) in self.data_info[i].items()])
text_representation += f"{self.key}{{{info_representation}}} {self.data[i]}\n"
return text_representation

View File

@ -12,6 +12,10 @@ general:
contact_url: false
# record stats
enable_metrics: true
# expose stats in open metrics format at /metrics
# leave empty to disable (no password set)
# open_metrics: <password>
open_metrics: ''
brand:
new_issue_url: https://github.com/searxng/searxng/issues/new

View File

@ -143,6 +143,7 @@ SCHEMA = {
'contact_url': SettingsValue((None, False, str), None),
'donation_url': SettingsValue((bool, str), "https://docs.searxng.org/donate.html"),
'enable_metrics': SettingsValue(bool, True),
'open_metrics': SettingsValue(str, ''),
},
'brand': {
'issue_url': SettingsValue(str, 'https://github.com/searxng/searxng/issues'),

View File

@ -39,7 +39,7 @@ msgstr ""
"Project-Id-Version: searx\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-11-03 09:08+0000\n"
"PO-Revision-Date: 2024-11-14 14:07+0000\n"
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
"Language-Team: Spanish <https://translate.codeberg.org/projects/searxng/"
"searxng/es/>\n"
@ -1249,7 +1249,7 @@ msgstr "Buscador de favicon"
#: searx/templates/simple/preferences/favicon.html:15
msgid "Display favicons near search results"
msgstr ""
msgstr "Mostrar los favicons al lado de los resultados de búsqueda"
#: searx/templates/simple/preferences/footer.html:2
msgid ""

View File

@ -28,13 +28,14 @@
# unoyoa <unoyoa@users.noreply.translate.codeberg.org>, 2024.
# tiziodcaio <tiziodcaio@users.noreply.translate.codeberg.org>, 2024.
# Fabio_Perri <Fabio_Perri@users.noreply.translate.codeberg.org>, 2024.
# lrnz2 <lrnz2@users.noreply.translate.codeberg.org>, 2024.
msgid ""
msgstr ""
"Project-Id-Version: searx\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-10-08 13:41+0000\n"
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
"PO-Revision-Date: 2024-11-14 02:16+0000\n"
"Last-Translator: lrnz2 <lrnz2@users.noreply.translate.codeberg.org>\n"
"Language-Team: Italian <https://translate.codeberg.org/projects/searxng/"
"searxng/it/>\n"
"Language: it\n"
@ -42,13 +43,13 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.7.2\n"
"X-Generator: Weblate 5.8.1\n"
"Generated-By: Babel 2.16.0\n"
#. CONSTANT_NAMES['NO_SUBGROUPING']
#: searx/searxng.msg
msgid "without further subgrouping"
msgstr "senza altri sottogruppi"
msgstr "senza altri sottogruppamenti"
#. CONSTANT_NAMES['DEFAULT_CATEGORY']
#: searx/searxng.msg
@ -73,7 +74,7 @@ msgstr "musica"
#. CATEGORY_NAMES['SOCIAL_MEDIA']
#: searx/searxng.msg
msgid "social media"
msgstr "social"
msgstr "social media"
#. CATEGORY_NAMES['IMAGES']
#: searx/searxng.msg
@ -113,7 +114,7 @@ msgstr "mappa"
#. CATEGORY_NAMES['ONIONS']
#: searx/searxng.msg
msgid "onions"
msgstr "onion"
msgstr "cipolle"
#. CATEGORY_NAMES['SCIENCE']
#: searx/searxng.msg
@ -133,7 +134,7 @@ msgstr "dizionari"
#. CATEGORY_GROUPS['LYRICS']
#: searx/searxng.msg
msgid "lyrics"
msgstr "testi musicali"
msgstr "testo musicale"
#. CATEGORY_GROUPS['PACKAGES']
#: searx/searxng.msg
@ -148,12 +149,12 @@ msgstr "d&r"
#. CATEGORY_GROUPS['REPOS']
#: searx/searxng.msg
msgid "repos"
msgstr "ripostigli"
msgstr "repos"
#. CATEGORY_GROUPS['SOFTWARE_WIKIS']
#: searx/searxng.msg
msgid "software wikis"
msgstr "wiki software"
msgstr "wiki del software"
#. CATEGORY_GROUPS['WEB']
#: searx/searxng.msg
@ -193,7 +194,7 @@ msgstr "Tempo di attività"
#. BRAND_CUSTOM_LINKS['ABOUT']
#: searx/searxng.msg searx/templates/simple/base.html:50
msgid "About"
msgstr "A proposito"
msgstr "Al riguardo"
#. WEATHER_TERMS['AVERAGE TEMP.']
#: searx/engines/wttr.py:32 searx/searxng.msg

View File

@ -11,13 +11,14 @@
# omfj <omfj@users.noreply.translate.codeberg.org>, 2024.
# combwizard <combwizard@users.noreply.translate.codeberg.org>, 2024.
# laaknor <laaknor@users.noreply.translate.codeberg.org>, 2024.
# Aadniz <Aadniz@users.noreply.translate.codeberg.org>, 2024.
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-11-03 09:08+0000\n"
"Last-Translator: laaknor <laaknor@users.noreply.translate.codeberg.org>\n"
"PO-Revision-Date: 2024-11-09 12:07+0000\n"
"Last-Translator: Aadniz <Aadniz@users.noreply.translate.codeberg.org>\n"
"Language-Team: Norwegian Bokmål <https://translate.codeberg.org/projects/"
"searxng/searxng/nb_NO/>\n"
"Language: nb_NO\n"
@ -192,13 +193,13 @@ msgstr "Skydekke"
#: searx/engines/duckduckgo_weather.py:45 searx/engines/wttr.py:51
#: searx/searxng.msg
msgid "Condition"
msgstr ""
msgstr "Betingelse"
#. WEATHER_TERMS['CURRENT CONDITION']
#: searx/engines/duckduckgo_weather.py:118 searx/engines/wttr.py:104
#: searx/searxng.msg
msgid "Current condition"
msgstr ""
msgstr "Nåværende betingelse"
#. WEATHER_TERMS['EVENING']
#: searx/engines/wttr.py:100 searx/searxng.msg
@ -221,13 +222,13 @@ msgstr "Luftfuktighet"
#: searx/engines/duckduckgo_weather.py:77 searx/engines/wttr.py:34
#: searx/searxng.msg
msgid "Max temp."
msgstr ""
msgstr "Maks temp."
#. WEATHER_TERMS['MIN TEMP.']
#: searx/engines/duckduckgo_weather.py:73 searx/engines/wttr.py:33
#: searx/searxng.msg
msgid "Min temp."
msgstr ""
msgstr "Min temp."
#. WEATHER_TERMS['MORNING']
#: searx/engines/wttr.py:100 searx/searxng.msg
@ -334,17 +335,17 @@ msgstr "opphavsmann"
#. SOCIAL_MEDIA_TERMS['THREAD OPEN']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "open"
msgstr ""
msgstr "åpen"
#. SOCIAL_MEDIA_TERMS['THREAD CLOSED']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "closed"
msgstr ""
msgstr "lukket"
#. SOCIAL_MEDIA_TERMS['THREAD ANSWERED']
#: searx/engines/discourse.py:160 searx/searxng.msg
msgid "answered"
msgstr ""
msgstr "svart på"
#: searx/webapp.py:332
msgid "No item found"
@ -421,7 +422,7 @@ msgstr "tilgang nektet"
#: searx/webutils.py:60
msgid "server API error"
msgstr "Tjener-API-feil"
msgstr "server API feil"
#: searx/webutils.py:79
msgid "Suspended"
@ -453,7 +454,7 @@ msgstr "Regn ut {functions} av parameterne"
#: searx/engines/mozhi.py:57
msgid "Synonyms"
msgstr ""
msgstr "Synonymer"
#: searx/engines/openstreetmap.py:159
msgid "Get directions"
@ -528,7 +529,7 @@ msgstr "Filkvalitet"
#: searx/plugins/calculator.py:14
msgid "Calculate mathematical expressions via the search bar"
msgstr ""
msgstr "Kalkuler matematiske uttrykk via søkebaren"
#: searx/plugins/hash_plugin.py:10
msgid "Converts strings to different hash digests."
@ -572,7 +573,7 @@ msgstr ""
#: searx/plugins/self_info.py:28
msgid "Your IP is: "
msgstr ""
msgstr "Din IP er "
#: searx/plugins/self_info.py:31
msgid "Your user-agent is: "
@ -580,16 +581,16 @@ msgstr ""
#: searx/plugins/tor_check.py:24
msgid "Tor check plugin"
msgstr "Tor sjekk pluggin"
msgstr "Tor sjekking plugin"
#: searx/plugins/tor_check.py:27
msgid ""
"This plugin checks if the address of the request is a Tor exit-node, and "
"informs the user if it is; like check.torproject.org, but from SearXNG."
msgstr ""
"Denne plugin sjekker om adressen til forespørselen er en Tor utgangsnode,"
" og informerer brukeren om den er det; som check.torproject.org, men fra "
"SearXNG."
"Denne plugin-en sjekker om adressen til forespørselen er en Tor utgangsnode, "
"og informerer brukeren om den er det; slik som check.torproject.org gjør, "
"men fra SearXNG."
#: searx/plugins/tor_check.py:61
msgid ""
@ -621,7 +622,7 @@ msgstr "Fjern sporer-argumenter fra returnert nettadresse"
#: searx/plugins/unit_converter.py:29
msgid "Convert between units"
msgstr ""
msgstr "Konverter mellom forskjellige enheter"
#: searx/templates/simple/404.html:4
msgid "Page not found"
@ -688,7 +689,7 @@ msgstr "Lengde"
#: searx/templates/simple/macros.html:41
msgid "Views"
msgstr ""
msgstr "Visninger"
#: searx/templates/simple/macros.html:42
#: searx/templates/simple/result_templates/files.html:34
@ -946,7 +947,7 @@ msgstr "Meldinger fra søkemotorene"
#: searx/templates/simple/elements/engines_msg.html:7
msgid "seconds"
msgstr ""
msgstr "sekunder"
#: searx/templates/simple/elements/search_url.html:3
msgid "Search URL"
@ -1068,7 +1069,7 @@ msgstr "Bytt til en annen instans:"
#: searx/templates/simple/messages/no_results.html:24
msgid "Search for another query or select another category."
msgstr ""
msgstr "Oppgi et annet søkeord eller velg en annen kategori."
#: searx/templates/simple/messages/no_results.html:25
msgid "Go back to the previous page using the previous page button."
@ -1194,11 +1195,11 @@ msgstr ""
#: searx/templates/simple/preferences/engines.html:15
msgid "Enable all"
msgstr ""
msgstr "Aktiver alle"
#: searx/templates/simple/preferences/engines.html:16
msgid "Disable all"
msgstr ""
msgstr "Deaktiver alle"
#: searx/templates/simple/preferences/engines.html:25
msgid "!bang"

View File

@ -10,13 +10,14 @@
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
# vducong <vducong@users.noreply.translate.codeberg.org>, 2024.
# tvminh19 <tvminh19@users.noreply.translate.codeberg.org>, 2024.
# KhietVo <KhietVo@users.noreply.translate.codeberg.org>, 2024.
msgid ""
msgstr ""
"Project-Id-Version: searx\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-10-26 21:13+0000\n"
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
"PO-Revision-Date: 2024-11-14 14:07+0000\n"
"Last-Translator: KhietVo <KhietVo@users.noreply.translate.codeberg.org>\n"
"Language-Team: Vietnamese <https://translate.codeberg.org/projects/searxng/"
"searxng/vi/>\n"
"Language: vi\n"
@ -166,7 +167,7 @@ msgstr "Tối"
#. STYLE_NAMES['BLACK']
#: searx/searxng.msg
msgid "black"
msgstr ""
msgstr "màu đen"
#. BRAND_CUSTOM_LINKS['UPTIME']
#: searx/searxng.msg
@ -198,7 +199,7 @@ msgstr "Điều kiện"
#: searx/engines/duckduckgo_weather.py:118 searx/engines/wttr.py:104
#: searx/searxng.msg
msgid "Current condition"
msgstr ""
msgstr "tình hình hiện tại"
#. WEATHER_TERMS['EVENING']
#: searx/engines/wttr.py:100 searx/searxng.msg
@ -209,25 +210,25 @@ msgstr "Buổi chiều"
#: searx/engines/duckduckgo_weather.py:53 searx/engines/open_meteo.py:81
#: searx/engines/wttr.py:59 searx/searxng.msg
msgid "Feels like"
msgstr ""
msgstr "Cảm thấy"
#. WEATHER_TERMS['HUMIDITY']
#: searx/engines/duckduckgo_weather.py:64 searx/engines/open_meteo.py:93
#: searx/engines/wttr.py:68 searx/searxng.msg
msgid "Humidity"
msgstr ""
msgstr "Độ ẩm"
#. WEATHER_TERMS['MAX TEMP.']
#: searx/engines/duckduckgo_weather.py:77 searx/engines/wttr.py:34
#: searx/searxng.msg
msgid "Max temp."
msgstr ""
msgstr "Nhiệt độ tối đa"
#. WEATHER_TERMS['MIN TEMP.']
#: searx/engines/duckduckgo_weather.py:73 searx/engines/wttr.py:33
#: searx/searxng.msg
msgid "Min temp."
msgstr ""
msgstr "Nhiệt độ thấp nhất"
#. WEATHER_TERMS['MORNING']
#: searx/engines/wttr.py:100 searx/searxng.msg
@ -247,37 +248,37 @@ msgstr "Buổi trưa"
#. WEATHER_TERMS['PRESSURE']
#: searx/engines/open_meteo.py:95 searx/searxng.msg
msgid "Pressure"
msgstr ""
msgstr "Áp suất"
#. WEATHER_TERMS['SUNRISE']
#: searx/engines/duckduckgo_weather.py:81 searx/engines/wttr.py:36
#: searx/searxng.msg
msgid "Sunrise"
msgstr ""
msgstr "Mặt trời mọc"
#. WEATHER_TERMS['SUNSET']
#: searx/engines/duckduckgo_weather.py:82 searx/engines/wttr.py:37
#: searx/searxng.msg
msgid "Sunset"
msgstr ""
msgstr "mặt trời lặn"
#. WEATHER_TERMS['TEMPERATURE']
#: searx/engines/duckduckgo_weather.py:48 searx/engines/open_meteo.py:76
#: searx/engines/wttr.py:55 searx/searxng.msg
msgid "Temperature"
msgstr ""
msgstr "Nhiệt độ"
#. WEATHER_TERMS['UV INDEX']
#: searx/engines/duckduckgo_weather.py:80 searx/engines/wttr.py:35
#: searx/searxng.msg
msgid "UV index"
msgstr ""
msgstr "Chỉ số UV"
#. WEATHER_TERMS['VISIBILITY']
#: searx/engines/duckduckgo_weather.py:62 searx/engines/wttr.py:66
#: searx/searxng.msg
msgid "Visibility"
msgstr ""
msgstr "Tầm nhìn"
#. WEATHER_TERMS['WIND']
#: searx/engines/duckduckgo_weather.py:58 searx/engines/open_meteo.py:86
@ -288,12 +289,12 @@ msgstr "Gió"
#. SOCIAL_MEDIA_TERMS['SUBSCRIBERS']
#: searx/engines/lemmy.py:85 searx/searxng.msg
msgid "subscribers"
msgstr ""
msgstr "người đăng ký"
#. SOCIAL_MEDIA_TERMS['POSTS']
#: searx/engines/lemmy.py:86 searx/searxng.msg
msgid "posts"
msgstr ""
msgstr "những bài đăng"
#. SOCIAL_MEDIA_TERMS['ACTIVE USERS']
#: searx/engines/lemmy.py:87 searx/searxng.msg
@ -309,42 +310,42 @@ msgstr ""
#. SOCIAL_MEDIA_TERMS['USER']
#: searx/engines/lemmy.py:129 searx/engines/lemmy.py:164 searx/searxng.msg
msgid "user"
msgstr ""
msgstr "người dùng"
#. SOCIAL_MEDIA_TERMS['COMMUNITY']
#: searx/engines/lemmy.py:131 searx/engines/lemmy.py:165 searx/searxng.msg
msgid "community"
msgstr ""
msgstr "cộng đồng"
#. SOCIAL_MEDIA_TERMS['POINTS']
#: searx/engines/hackernews.py:78 searx/searxng.msg
msgid "points"
msgstr ""
msgstr "điểm"
#. SOCIAL_MEDIA_TERMS['TITLE']
#: searx/searxng.msg
msgid "title"
msgstr ""
msgstr "tiêu đề"
#. SOCIAL_MEDIA_TERMS['AUTHOR']
#: searx/engines/hackernews.py:81 searx/searxng.msg
msgid "author"
msgstr ""
msgstr "tác giả"
#. SOCIAL_MEDIA_TERMS['THREAD OPEN']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "open"
msgstr ""
msgstr "mở"
#. SOCIAL_MEDIA_TERMS['THREAD CLOSED']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "closed"
msgstr ""
msgstr "đóng"
#. SOCIAL_MEDIA_TERMS['THREAD ANSWERED']
#: searx/engines/discourse.py:160 searx/searxng.msg
msgid "answered"
msgstr ""
msgstr "đã trả lời"
#: searx/webapp.py:332
msgid "No item found"
@ -529,7 +530,7 @@ msgstr "Chất lượng tệp"
#: searx/plugins/calculator.py:14
msgid "Calculate mathematical expressions via the search bar"
msgstr ""
msgstr "Tính toán bằng thanh tìm kiếm"
#: searx/plugins/hash_plugin.py:10
msgid "Converts strings to different hash digests."
@ -540,12 +541,14 @@ msgid "hash digest"
msgstr "hash băm"
#: searx/plugins/hostnames.py:103
#, fuzzy
msgid "Hostnames plugin"
msgstr ""
msgstr "Mấy chủ bổ trợ"
#: searx/plugins/hostnames.py:104
msgid "Rewrite hostnames, remove results or prioritize them based on the hostname"
msgstr ""
"Viết lại máy chủ, xoá các kểt quả tìm kiếm hoặc sắp xếp dựa trên máy chủ"
#: searx/plugins/oa_doi_rewrite.py:12
msgid "Open Access DOI rewrite"
@ -571,7 +574,7 @@ msgstr "Hiện IP của bạn khi gõ \"ip\" và hiện user agent khi gõ \"use
#: searx/plugins/self_info.py:28
msgid "Your IP is: "
msgstr ""
msgstr "Địa chỉ IP của bạn: "
#: searx/plugins/self_info.py:31
msgid "Your user-agent is: "

View File

@ -87,10 +87,7 @@ from searx.webadapter import (
get_selected_categories,
parse_lang,
)
from searx.utils import (
gen_useragent,
dict_subset,
)
from searx.utils import gen_useragent, dict_subset
from searx.version import VERSION_STRING, GIT_URL, GIT_BRANCH
from searx.query import RawTextQuery
from searx.plugins import Plugin, plugins, initialize as plugin_initialize
@ -104,13 +101,7 @@ from searx.answerers import (
answerers,
ask,
)
from searx.metrics import (
get_engines_stats,
get_engine_errors,
get_reliabilities,
histogram,
counter,
)
from searx.metrics import get_engines_stats, get_engine_errors, get_reliabilities, histogram, counter, openmetrics
from searx.flaskfix import patch_application
from searx.locales import (
@ -1218,6 +1209,30 @@ def stats_checker():
return jsonify(result)
@app.route('/metrics')
def stats_open_metrics():
password = settings['general'].get("open_metrics")
if not (settings['general'].get("enable_metrics") and password):
return Response('open metrics is disabled', status=404, mimetype='text/plain')
if not request.authorization or request.authorization.password != password:
return Response('access forbidden', status=401, mimetype='text/plain')
filtered_engines = dict(filter(lambda kv: request.preferences.validate_token(kv[1]), engines.items()))
checker_results = checker_get_result()
checker_results = (
checker_results['engines'] if checker_results['status'] == 'ok' and 'engines' in checker_results else {}
)
engine_stats = get_engines_stats(filtered_engines)
engine_reliabilities = get_reliabilities(filtered_engines, checker_results)
metrics_text = openmetrics(engine_stats, engine_reliabilities)
return Response(metrics_text, mimetype='text/plain')
@app.route('/robots.txt', methods=['GET'])
def robots():
return Response(