journald: rework logic to respect ignored error (#78679)
gitea/publik-infra/pipeline/head This commit looks good
Details
gitea/publik-infra/pipeline/head This commit looks good
Details
This commit is contained in:
parent
6e39c3bce9
commit
cf566de881
|
@ -27,6 +27,9 @@ JOURNALD_IGNORED_ERRORS = {
|
|||
],
|
||||
'ssh.service': [
|
||||
'maximum authentication attempts exceeded for ',
|
||||
'error: kex_exchange_identification: read: Connection reset by peer',
|
||||
'error: kex_exchange_identification: Connection closed by remote host',
|
||||
'fatal: Timeout before authentication for ',
|
||||
],
|
||||
'': [ # match all services (useful for ovpn*)
|
||||
'Connection reset, restarting [0]',
|
||||
|
@ -109,30 +112,27 @@ def harakiri(ctn):
|
|||
if 'HARAKIRI ON WORKER' in e['MESSAGE']:
|
||||
eo_harakiri.labels(ctn, 'errors', e['_SYSTEMD_UNIT']).inc()
|
||||
|
||||
|
||||
def journald(ctn):
|
||||
j = journal.Reader()
|
||||
fifteen = time.time() - 15 * 60
|
||||
j.seek_realtime(fifteen)
|
||||
j.add_match(PRIORITY=2)
|
||||
eo_journal.labels(ctn, 'critical').set(len(list(j)))
|
||||
j.seek_realtime(fifteen)
|
||||
j.add_match(PRIORITY=3)
|
||||
j.add_match(PRIORITY=2)
|
||||
eo_journal.labels(ctn, "critical").set(0)
|
||||
eo_journal.labels(ctn, "error").set(0)
|
||||
priority_to_tag = {2: "critical", 3: "error"}
|
||||
for e in j:
|
||||
msg = e['MESSAGE']
|
||||
ignored_message = False
|
||||
msg = e["MESSAGE"]
|
||||
ignored_strings = (
|
||||
JOURNALD_IGNORED_ERRORS.get(e.get('_SYSTEMD_UNIT'), []) + JOURNALD_IGNORED_ERRORS['']
|
||||
)
|
||||
for ignored_string in ignored_strings:
|
||||
if ignored_string in msg:
|
||||
ignored_message = True
|
||||
break
|
||||
if ignored_message:
|
||||
continue
|
||||
eo_journal.labels(ctn, 'error').inc()
|
||||
if 'Connected -> NetworkFailure' in msg or 'task nfsd' in msg:
|
||||
eo_journal.labels(ctn, 'network_failure').inc()
|
||||
else:
|
||||
eo_journal.labels(ctn, priority_to_tag[e["PRIORITY"]]).inc()
|
||||
if "Connected -> NetworkFailure" in msg or "task nfsd" in msg:
|
||||
eo_journal.labels(ctn, "network_failure").inc()
|
||||
|
||||
|
||||
def local_changes(ctn):
|
||||
|
|
Loading…
Reference in New Issue