Extension to monitor errors in log - Mailing list pgsql-hackers

From Святослав Ермилин
Subject Extension to monitor errors in log
Date
Msg-id 43731587553233@mail.yandex-team.ru
Whole thread Raw
List 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
andfatals.
 
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
everypossible error code. 
 
In emit_log_hook messages are updating this info in hash table. Then bgworker every n seconds collects and prepares
thisinfo.
 
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



pgsql-hackers by date:

Previous
From: Ahsan Hadi
Date:
Subject: Re: create partition table caused server crashed withself-referencing foreign key
Next
From: Dipesh Pandit
Date:
Subject: Re: WIP/PoC for parallel backup