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.96) (envelope-from ) id 1x4IOa-0073SJ-22 for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2026 13:31:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x4IOY-00F3qb-0d for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2026 13:31:22 +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.96) (envelope-from ) id 1x4IOX-00F3qQ-2W for pgsql-hackers@lists.postgresql.org; Wed, 09 Sep 2026 13:31:21 +0000 Received: from mail-qv1-xf2e.google.com ([2607:f8b0:4864:20::f2e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x4IOV-00000003lWI-0Qav for pgsql-hackers@postgresql.org; Wed, 09 Sep 2026 13:31:21 +0000 Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-90ce08834feso83343496d6.0 for ; Wed, 09 Sep 2026 06:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1788960676; cv=none; d=google.com; s=arc-20260327; b=BJv130rAXELVjq9VmuvFY4okPz88Z2/5vvz0rORXS8GkO6/jEH+7Z5kHbHf2VGNFxG 4g+ihCunCVg50ZJksHasONIxbRuKIMp7PjdR5a3gtDS3edcbJmwWncIHWqO3cW/1FjAT wZq3CF8+6RMkjWLXtJ4swgKog1A05MyMpxMA+rikv8w/c0A0iUjsDqkoW54H/i+OGwyX UbV7URwI+nVxy4ZnFEtyEcnuukupH1P4xXT81hduYdd8qLoHpR4djKcLG83p4Utxo7gq qgAYlbYGhJZ2aHTNs4kgWyhiQnqULM/ZT9NiGUgcTk8wO/4J+jUrQoZJ+Fs2lGwRzFFj sgDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=cp4WcbmJRlJFTcUGEouUk2mix8VD6NG5gbnykbR8lXs=; fh=euDRIqa0uWW6Baug/3f1vEPTMN4DnQlhRzA0mSKh+qM=; b=FKxzWnIgMoVvFc72obOcrnsjdc7nyslmZ5lbB+hSKko3P1UbCYIMiygzoLnN3uEIQc bvSUZmXC3xZoCWYlwQ2+Q/F+xV1KsYyKHYfaFNo+MEMWEbssaxsaeDxBf/+RboVRJn3w gyFw5ta4rfFTQ33kl2EzNDuU9uijBbAh5P+9iwChFgQGRyM7PipL1+XUVfzBo/tgzszR 9/hUZQ7T/bpKnbuLnwRzh51lWERReXMaNBeNlDESnDEj5sq6Eb09ncIlOLhvAumlAhbN xG5+Z4IrjifQLHecd1y990Ff0x6Kf20RV51LDClamcbPkU1q51P/MiQ9roftq6uX/Xkd itQg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postgres.ai; s=google; t=1788960676; x=1789565476; darn=postgresql.org; h=content-type:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cp4WcbmJRlJFTcUGEouUk2mix8VD6NG5gbnykbR8lXs=; b=VF5uG2xyHFSvN+6dfIgbZjGM7ru6gDg0BLb13xFRiHuKAqTX8Iw6XTInsOlLHloCxm 2jSv+8flBp6wuffx8ZBxUJ6p+CgKEOK7mJJQ9KKVtamYitM1x+19Qp1jPR2rCfLUz4GJ A2u3N6O5n7d8WXKn+YuuM1LElzosc2zxQlhEZBYoAoNxs0sVFmTFS6EHyy6oPkCMLgke SAAvVV3gYyRrk5UJaOQhI9IoNgXYmWPdF5q0dWR3ajNvawGom9EnF+1GIwfG/d1XNL+l +bpvcIoeNLdCybQYt3DjgJTRYtcgv1xd2hFApWXlmSHXCalVq5chbpw2Ja1P78eqJk9Q 0aRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788960676; x=1789565476; h=content-type:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=cp4WcbmJRlJFTcUGEouUk2mix8VD6NG5gbnykbR8lXs=; b=bZcNOTlGfgTDokIRZ+nOcic7eQvp7TcryeWs6WZqZN/Fg6uQQfc08Sl7fkgjS8+jnJ M6/gmPQEP4pWNQ+X8jFUYxXiPzRQ4y0jLI2IZw0sxQvuCTXvflnDls4E7qdOHSzJRLLa B8+5ETYyUCg9Rx0H695h/vXuiMspGf1dFlZZlpPBK2GrXf/Ja6YIVP2HQaFCcwnkfzjI u35bl/7XBfZS7BHufYRBRpfB1UKy53rxXVJt/3s3DnxhksA5tkLDRMmCEFK+D7k+b+bR XeWsCkUTDpc35eV8VHCsvPvwW9LGv7Y7ZtET5JvwNySRiwdPA0R9plmpAySCq76AzfYV NSGg== X-Forwarded-Encrypted: i=1; AKwUvBxZhAo68rp4eTAWsNe01+lmmUE5YNX0JBmZ8b/To2ib6X8+9JLOO02bivZayhYpv8Zq8LRaHlqowUF9i+wJ@postgresql.org X-Gm-Message-State: AFuF++nOBzdyfpc+8RKSPN+0tMn6bK5ERSru8wWI8YSaPu2vo0p6yKi9 qYul8sItHTPK5HadhbVucUK83fo09oWzpgMMesazQtkt8MmW041AdsyBYBTBNnesySxwQ2mGQCe 6tj9aevd0L65bqx97Yixz8a2r0ebxsEtB+ysSkzqXJA== X-Gm-Gg: AYBFou0LVoOlMdczQNLGpLMdI9Kt4/tp/jd5R34/6t1xP9RDOSaOC2TQP4EkZCR9LzV /nflEXBHsl2fB4YAc8ZAEAmbb7uCLlWS4QbtzPQZtdQTQH+NqHrGrOB9PImYI3Ljx2KzHbjSLV0 D1H7/CMrJf2WK1aBUMGwjPLmGOxk3YtXBBZjDbiB1AiiDfBIPKiABUiJs60tUGuS4aye6MP4bjw 9HjG3J6uhI9hXNZNXSpPXixCz09yWygBCIPWvCD1JYTX1vMxEtfbjAJmKN91ZDsEjyOu0GBHIJl Nz1UOCf4+g+JsN7JnDbks8oLJj0bUC0XPzGoq90uUy39x/OyPCyDJINiO5s70Cff6L6Q+0AiCwm XaxITGsw6zgNfaBdDK/Hvhn5x/XB8abDQj6K5IoFrA57ZW5dwHw== X-Received: by 2002:a05:6214:2386:b0:910:42f4:f92f with SMTP id 6a1803df08f44-91042f4fc5emr387021406d6.13.1788960673062; Wed, 09 Sep 2026 06:31:13 -0700 (PDT) MIME-Version: 1.0 References: <5D8BEEDE-8028-46C8-BC37-8E9F85ED384C@yesql.se> In-Reply-To: <5D8BEEDE-8028-46C8-BC37-8E9F85ED384C@yesql.se> From: Nikolay Samokhvalov Date: Wed, 9 Sep 2026 06:31:01 -0700 X-Gm-Features: AcwNN1VDOvhdLEBBBwKpRl6bbL3bdgfMvtJzrcEf_jbxneHhMgghRo2UsnqTefw Message-ID: Subject: Re: Add contrib module pg_stat_log: cumulative statistics about server log messages To: Daniel Gustafsson Cc: Fabrizio Mello , PostgreSQL Hackers , "mail@joeconway.com" Content-Type: multipart/alternative; boundary="0000000000006f81cb065b0cddc9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006f81cb065b0cddc9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Sep 3, 2026 at 00:58 Daniel Gustafsson wrote: > > On 18 Aug 2026, at 13:23, Fabrizio Mello > wrote: > > > * Is contrib the right home, or would people rather see this as a > > builtin stats kind with a core pg_stat_* view? Contrib felt right for > > a first step since it exercises the custom stats API and is entirely > > optional, but I'm happy to go either way. > > IMHO, contrib is not the right home for anything new. Either we think it= 's > important for production and place it in core or it should live as an > external > extension. > > Your email didn't motivate why this extension should be in core instead o= f > maintained as an external extension? I strongly support having this in core, exposed through a pg_stat_* view, rather than in contrib or an external extension. Reason is quite straightforward: error counters / error analysis is fundamental database monitoring. For example, I want to alert when Postgres reports an internal error (XX000), data corruption (XX001), or index corruption (XX002). Today, standard statistics don't provide general counters by SQLSTATE. We have rollbacks, deadlocks, recovery conflicts, and some other specific counters, but they don't tell us whether these errors occurred. Getting that information from logs is now the only way, but operationally much harder than collecting counters: - Logs mix diagnostic messages with statements and potentially sensitive data / PII, such as parameter values. Giving a monitoring system access to all of that is different from letting it read error counts. I personally feel this when working with users of managed Postgres platforms. It's usually not a problem to get pg_monitor access, and it's a completely different story to get access to logs. - Exporting pg_stat_* counters to Prometheus is straightforward and common. Processing logs requires a separate pipeline, with additional permissions, storage, resource usage, and failure modes. =E2=80=A2 In managed Postgres, users may have SQL monitoring access but lim= ited control over log collection or which extensions are available. - SQL path of analysis is also great for smaller clusters that cannot justify full fledged monitoring stacks -- having ability to just self-analyze and see if we had errors of some kinds is good enough for smaller cases. Counters would not replace logs. I want monitoring to tell me that Postgres reported a corruption error, then use logs to investigate it. Collecting the full diagnostic details should not be a prerequisite for detecting the event, in my opinion. An external extension is useful for developing and testing the implementation, but I don't see it as the right long-term home for this capability, especially considering how long it might take for it to propagate to managed Postgres platforms. Nik --0000000000006f81cb065b0cddc9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Sep 3, 2026 at 00:58 Daniel Gustafsson <<= a href=3D"mailto:daniel@yesql.se" target=3D"_blank">daniel@yesql.se>= wrote:
> On 18 Aug 2026, at = 13:23, Fabrizio Mello <fabrizio@planetscale.com> wrote:

> * Is contrib the right home, or would people rather see this as a
>=C2=A0 builtin stats kind with a core pg_stat_* view? Contrib felt righ= t for
>=C2=A0 a first step since it exercises the custom stats API and is enti= rely
>=C2=A0 optional, but I'm happy to go either way.

IMHO, contrib is not the right home for anything new.=C2=A0 Either we think= it's
important for production and place it in core or it should live as an exter= nal
extension.

Your email didn't motivate why this extension should be in core instead= of
maintained as an external extension?

I strongly support having this in core,= exposed through a pg_stat_* view, rather than in contrib or an external ex= tension.=C2=A0

Reason is quite straightforw= ard:=C2=A0error counters / error analysis is fundamental database monitorin= g.

For examp= le, I want to alert when Postgres reports an internal error (XX000), data c= orruption (XX001), or index corruption (XX002). Today, standard statistics = don't provide general counters by SQLSTATE. We have rollbacks, deadlock= s, recovery conflicts, and some other specific counters, but they don't= tell us whether these errors occurred.

Getting that information from logs is now the o= nly way, but operationally much harder than collecting counters:

- Logs mix diagnosti= c messages with statements and potentially sensitive data / PII, such as pa= rameter values. Giving a monitoring system access to all of that is differe= nt from letting it read error counts. I personally feel this when working w= ith users of managed Postgres platforms. It's usually not a problem to = get pg_monitor access, and it's a completely different story to get acc= ess to logs.
- Expor= ting pg_stat_* counters to Prometheus is straightforward and common. Proces= sing logs requires a separate pipeline, with additional permissions, storag= e, resource usage, and failure modes.
=E2=80= =A2 In managed Postgres, users may have SQL monitoring access but limited c= ontrol over log collection or which extensions are available.
- SQL path of analysis is also great = for smaller clusters that cannot justify full fledged monitoring stacks -- = having ability to just self-analyze and see if we had errors of some kinds = is good enough for smaller cases.

Counters would not replace logs. I want monitoring t= o tell me that Postgres reported a corruption error, then use logs to inves= tigate it. Collecting the full diagnostic details should not be a prerequis= ite for detecting the event, in my opinion.
=
An external extension is useful for develop= ing and testing the implementation, but I don't see it as the right lon= g-term home for this capability, especially considering how long it might t= ake for it to propagate to managed Postgres platforms.

Nik

--0000000000006f81cb065b0cddc9--