Extension to monitor errors in log

From: Святослав Ермилин <munakoiso(at)yandex-team(dot)ru>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Extension to monitor errors in log
Date: 2020-04-22 11:02:00
Message-ID: 43731587553233@mail.yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!
I wrote extension for postgresql that is collecting statistics about errors in logfile.

This extension counts the number of messages of each type and code.
It's designed to enable monitoring tools. I'm going to use it as a data source for plot of number of errors, warnings and fatals.
Source code is here: https://github.com/munakoiso/logerrors

Design considerations.
There is a hash table in shared memory that contains counters of each type (currently only fatal, error, warning) and every possible error code.
In emit_log_hook messages are updating this info in hash table. Then bgworker every n seconds collects and prepares this info.
pg_log_errors_stats() function is using this table in shared memory can show stats at last n*k seconds.

Here is an example of usage:
postgres=# select * from pg_log_errors_stats();
time_interval | type | message | count
---------------+---------+----------------------+-------
| WARNING | TOTAL | 0
| ERROR | TOTAL | 3
600 | ERROR | ERRCODE_SYNTAX_ERROR | 3
5 | ERROR | ERRCODE_SYNTAX_ERROR | 2
| FATAL | TOTAL | 0

It would be very cool if someone gave me some feedback.

--
Sviatoslav Ermilin
Yandex

Browse pgsql-hackers by date

  From Date Subject
Next Message Dipesh Pandit 2020-04-22 11:07:25 Re: WIP/PoC for parallel backup
Previous Message Ahsan Hadi 2020-04-22 10:44:07 Re: create partition table caused server crashed with self-referencing foreign key