Subject: Re: logfmt and application_context

From: Étienne BERSAC <[email-masked]>
Date: Tue, 26 Sep 2023 09:56:27 +0200

Hi Daniel,

Thanks for the feedback.

Le mardi 05 septembre 2023 à 11:35 +0200, Daniel Gustafsson a écrit :
> > On 30 Aug 2023, at 14:36, Étienne BERSAC <[email-masked]> wrote:
> 
> > ..what do you think of having logfmt output along json and CSV ?
> 
> Less ideal is
> that there is no official formal definition of what logfmt is [...]  If we add
> support for it, can we reasonably expect that what we emit is what consumers of
> it assume it will look like?

I didn't know logfmt had variation. Do you have a case of
incompatibility ?

Anyway, I think that logfmt will be better handled inside Postgres
rather than in an extension due to limitation in syslogger
extendability. I could send a patch if more people are interested in
this.

What do you think about application_context as a way to render e.g. a
web request UUID to all backend log messages ?

Regards,
Étienne

---

From: Daniel Gustafsson <[email-masked]>
Date: Wed, 27 Sep 2023 10:14:48 +0200

> On 26 Sep 2023, at 09:56, Étienne BERSAC <[email-masked]> wrote:

Like I said upthread, it might be reasonable to assume that the format is
fairly stable, but without a formal definition there is no way of being
certain.  Formats without specifications that become popular tend to diverge,
Markdown being the textbook example.

Being a common format in ingestion tools makes it interesting though, but I
wonder if those tools aren't alreday supporting CSV such that adding logfmt
won't move the compatibility markers much?

--
Daniel Gustafsson

---

From: Étienne BERSAC <[email-masked]>
Date: Wed, 27 Sep 2023 13:57:50 +0200

Hi,

> won't move the compatibility markers much?

Compared to CSV, logfmt has explicit named fields. This helps tools to
apply generic rules like : ok this is pid, this is timestamp, etc.
without any configuration. Loki and Grafana indexes a subset of known
fields. This is harder to achieve with a bunch a semi-colon separated
values.

Compared to JSON, logfmt is terser and easier for human eyes and
fingers.

This is why I think logfmt for PostgreSQL could be a good option.

Regards,
Étienne