Syslog-ng and postgresql connection logs
... / Syslog-ng and postgresql ...
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

Syslog-ng and postgresql connection logs

by
RaheelK1
Created on 2022-01-31 10:45:12 (edited on 2024-09-04 14:22:53) in AI and Machine Learning

I would like to send postgres connection logs to the OVH Logs Data Platform service with syslog-ng. How should syslog-ng be configured to send these logs?

Currently I have the following configuration in the ldp.conf file:

source s_postgres {
file("/var/log/postgresql/postgresql-${YEAR}-${MONTH}-${DAY}_000000.log" flags(no-parse));
}

template t_postgres {
template("<${LEVEL_NUM}>1 ${ISODATE} ${HOST} ${PROGRAM} ${PID} - [sdid X-OVH-TOKEN=\"\" pid=\"${PID}\" facility=\"${FACILITY}\" priority=\"${PRIORITY}\"]$
template_escape(no);
}

d_postgres {
tcp(".logs.ovh.com"
port(12201)
tls(ca_dir("/etc/ssl/certs"))
ts_format("rfc3339") template(t_postgres)
keep-alive(yes)
so_keepalive(yes)
log-fifo-size(30000)
);
}

log {
source(s_postgres);
destination(d_postgres);
}


1 Reply ( Latest reply on 2022-02-19 11:09:31 by
TamanaS
)

In order to log RFC 5424 syslogs to Logs Data Platform, you must use the appropriate port. The Port for RFC 5424 is 6514. You can find an example of the syslog-ng configuration at the following Official Documentation:
https://docs.ovh.com/fr/logs-data-platform/how-to-log-your-linux/

For your configuration, your are mostly interested in this part of the documentation (for syslog-ng 3.8+, note also the timestamp format).

destination ovhPaaSLogs {
network(".logs.ovh.com"
port(6514),
template(ovhTemplate),
ts_format("iso"),
transport("tls"),
tls(peer-verify("required-trusted") ca_dir("/etc/ssl/certs/")),
keep-alive(yes),
so_keepalive(yes),
);
};
The documentation provides also an example https://www.tommypetarabic.com/ Website of a working template, and other guides will give you alternatives.

Don't hesitate do reach directly the OVH team if you need further assistance at:

Replies are currently disabled for this question.