Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tjhbp-00CdAG-9A for pgsql-general@arkaria.postgresql.org; Sun, 16 Feb 2025 16:35:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tjhbn-009Phf-Re for pgsql-general@arkaria.postgresql.org; Sun, 16 Feb 2025 16:35:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tjhbn-009PhW-GG for pgsql-general@lists.postgresql.org; Sun, 16 Feb 2025 16:35:07 +0000 Received: from mail1.dalibo.net ([51.159.93.128] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tjhbl-001BiQ-0D for pgsql-general@lists.postgresql.org; Sun, 16 Feb 2025 16:35:07 +0000 Received: from [192.168.1.131] (55.110.220.81.rev.sfr.net [81.220.110.55]) by mail.dalibo.com (Postfix) with ESMTPSA id DBD3827655 for ; Sun, 16 Feb 2025 17:35:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1739723702; bh=LA44SMH9k4UPLDeb7Wv+bu2EVl9LTPgkX3u5WdL1jcg=; h=Date:Subject:To:References:From:In-Reply-To:From; b=DbHcuva7rOA4H8hgL+LdeSkAvsUlv99z6UmcTGdiHAvvO3JHAgqWWID8A2fvXTmab d7Rk8db86ZlL4844u0srePmmrq3SzRn8ZPb+4OAsbgFIJj6Sz53llPve9LplyFv1WV aBFNNaFkb74m0oW2wtaq1e91pTU3d5ZxynGTq8nE= Message-ID: <54274170-49f7-4c88-8c23-431d50dd6a9f@dalibo.com> Date: Sun, 16 Feb 2025 17:35:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Question on Alerts To: pgsql-general@lists.postgresql.org References: Content-Language: fr From: Guillaume Lelarge Organization: Dalibo In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 16/02/2025 14:29, sud wrote: > Hi, > We are asked to have key monitoring or alerting added to our postgres > database. And I am thinking of metrics like blocked transactions, Max > used transaction Ids,  Max Active session threshold, Deadlock, Long > running query,  replica lag, buffer cache hit ratio, read/write IOPS or > latency etc. I have below questions > > 1)Below are some which i tried writing, can you please let me know if > these are accurate? > 2)How should we be writing the alerting query for deadlock, max used > transaction ids, read/write IOPS and latency? > 3)Are there any docs available which have these sample sql queries on > the pg_* table for these critical alerts which we can easily configure > through any tool? > 4)Any other alerts which we should be really having? > You should probably look at check_postgres and check_pgactivity. Their source code contain numerous SQL queries, that could help you write your own. Regards. -- Guillaume Lelarge Consultant https://dalibo.com