CryptoPust

· Security

The architectural gap between a PostgreSQL alert script and a SIEM

The maintenance burden of custom log parsers, event correlation and security visibility.

Ekin Yegül


At a fintech company where I previously worked, there was no SIEM investment. We had to develop a custom JavaScript application to monitor PostgreSQL authorization errors, failed logins, audit records, data changes and application events.

It queried PostgreSQL periodically and generated alerts for records matching defined conditions. We worked with this arrangement for about a year. Changes to log formats or data structures during upgrades sometimes broke the parser, delayed or lost alerts, or caused rules to generate false positives. After each upgrade we also had to revalidate security monitoring.

I have no objection to JavaScript. Node.js can be used to build perfectly good collectors, normalizers and detection components. The problem was assuming that an application without defined maintenance and observability boundaries satisfied the need for central security monitoring.

Relationships between events

A single failed password attempt may not warrant an alert. Suppose failed attempts on an account are followed by a successful login, a privilege change and the initiation of a financial transaction. In this illustrative scenario, we need events from the identity system, API gateway, application audit trail and transaction system alongside database logs.

A central security monitoring system should normalize and correlate these events. I would start by considering event_id, schema_version, source, event_time, ingest_time, actor_id, session_id, correlation_id, action and outcome. Not every source will provide all these fields. Missing identities should not be guessed and presented as certain matches.

Recording event time separately from ingestion time makes delayed records visible. Correlation time windows must account for that difference.

What happens when the parser stops receiving data?

When writing a custom parser, I would first define its contract with the source. PostgreSQL’s CSV and JSON logging options can provide more stable input than regular expressions over free-form text. PostgreSQL’s documentation advises JSON log consumers to ignore unknown fields. That avoids rejecting every record when a new field appears. Missing required fields, however, should be visible as errors.

Illustrative data flow:

Source -> durable ingestion -> raw record -> normalization -> detection
                                  |-> replay / quarantine

Persisting the last processed position helps prevent record loss during restarts. Reprocessing an event should not repeat the alert’s operational effect. Checkpoints, unique event identities, replay and quarantine for unprocessable records need to be considered together.

For each source, monitor received, successfully parsed and rejected record counts alongside ingestion lag. Before celebrating a falling alert count, check whether the parser is still receiving data. I would use an independent ingestion health check.

Costs outside the licence invoice

Components such as pgAudit can provide more detailed audit data. Establish which records are needed, access permissions, masking and retention periods in advance. Logging every query can increase OLTP load and storage costs, and expose sensitive data in logs. Measure the selected configuration under representative workload.

A commercial SIEM is not mandatory. Open-source components can also support collection, correlation, retention, alert management and incident response. Someone must own their integration and lifecycle. In our arrangement, reducing licence expenditure left parser maintenance, version compatibility and security visibility with the development team.

Before accepting a security monitoring system, I would stop and restart the source, send old and new event schemas, deliver duplicate events and examine how delayed records are processed. Then I would inspect the evidence showing who received an alert and how it was handled. Seeing an alert in a demonstration is no substitute for those checks.

Originally published: 2026-07-30. Revised edition: 3 December 2026.

Sources


Related articles

All articles