Send Logs to Managed OpenSearch
Send the server log of a Managed PostgreSQL service to an Exoscale Managed OpenSearch service, and keep it searchable for as many days as you choose. exo dbaas logs only reads a short buffer and never shows pgaudit records; a logs integration keeps both.
This page covers an OpenSearch service of your own organization. For an OpenSearch or Elasticsearch cluster that you run elsewhere, use an external endpoint instead, as described in Use External Integrations.
Prerequisites
- The Exoscale CLI, configured with your API credentials.
- A running Managed PostgreSQL service.
- A running Managed OpenSearch service in the same organization.
The IP filter of the OpenSearch service does not need to list the PostgreSQL service: the integration delivers logs to an OpenSearch service whose filter allows only your own address.
Create the Integration
echo '{"integration-type":"logs","source-service":"SERVICE_NAME","dest-service":"OPENSEARCH_SERVICE","settings":{"elasticsearch_index_prefix":"INDEX_PREFIX","elasticsearch_index_days_max":DAYS}}' | \
exo api create-dbaas-integration -z ZONEParameters:
SERVICE_NAME: name of the Managed PostgreSQL service.OPENSEARCH_SERVICE: name of the Managed OpenSearch service that receives the logs.INDEX_PREFIX: prefix of the daily indices. Lowercase letters, digits,-,_and., starting with a letter or a digit. Defaults tologs.DAYS: number of daily indices to keep, from 1 to 10000. Defaults to3.ZONE: zone of the PostgreSQL service.
For example, to keep 14 days of logs of my-postgresql in my-opensearch:
echo '{"integration-type":"logs","source-service":"my-postgresql","dest-service":"my-opensearch","settings":{"elasticsearch_index_prefix":"my-postgresql","elasticsearch_index_days_max":14}}' | \
exo api create-dbaas-integration -z ch-gva-2The command returns the ID of the integration in reference.id. Keep it: you need it to delete the
integration. It is also listed in the integrations field of the service:
exo api get-dbaas-service-pg my-postgresql -z ch-gva-2 -q integrationsA third setting, selected_log_fields, limits the fields sent with each line. MESSAGE and
timestamp are always sent. Without the setting, the five other fields are sent too; with it, only
those you list among HOSTNAME, PRIORITY, REALTIME_TIMESTAMP, SYSTEMD_UNIT and
service_name. For example, "selected_log_fields":["HOSTNAME","SYSTEMD_UNIT"] inside settings.
Tip
Give each service its own index prefix, for example its name. With the default logs, every
service that sends logs to the same OpenSearch service writes into the same daily index.
Important
Choose the settings when you create the integration. exo api update-dbaas-integration answers
Integration does not exist. (HTTP 404), and a second logs integration between the same two
services is refused with Such integration already exists. To change a setting, delete the
integration and create it again. The new integration starts by sending every line the service
still holds, so its first index repeats lines that the previous one already sent.
Check That Logs Arrive
The status reported by exo api get-dbaas-integration INTEGRATION_ID -z ZONE stays at starting
while logs flow, so check OpenSearch itself. New lines are searchable within seconds.
List the indices of the service:
curl -s "OPENSEARCH_URI/_cat/indices/INDEX_PREFIX-*?v"Parameters:
OPENSEARCH_URI: the URI returned byexo dbaas show OPENSEARCH_SERVICE -z ZONE --uri. It contains theavnadmincredentials of the OpenSearch service.INDEX_PREFIX: the prefix set on the integration.
The integration writes one index per day, named INDEX_PREFIX-YYYY-MM-DD:
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open my-postgresql-2026-11-10 Lu2Jxm_UTnGxAbGSqjiifA 1 0 998 0 206kb 206kbWhat a Log Document Contains
Each line of the PostgreSQL server log becomes one document:
| Field | Content |
|---|---|
MESSAGE | The log line, starting with the log_line_prefix of the service. Always sent. |
timestamp | Time of the line in UTC, for example 2026-11-10T13:54:44.596031. Always sent. The only date field of the index. |
HOSTNAME | Node that wrote the line, for example my-postgresql-1. |
PRIORITY | Syslog priority: 6 for LOG lines, 4 for ERROR and DETAIL lines, 3 for FATAL lines. |
REALTIME_TIMESTAMP | The same instant in Unix seconds. |
SYSTEMD_UNIT | postgresql-18.service on PostgreSQL 18. |
service_name | Name of the PostgreSQL service. |
pgaudit
records arrive in the same indices with additional PG_* fields (user, database, client address,
application) and a MESSAGE that starts with AUDIT:.
Three properties of these indices shape how you query them:
- Only the PostgreSQL server log is sent. Every document comes from the
postgresql-18.serviceunit, also when a connection pool is in use: PgBouncer lines are not sent. - The fields are full text. You can search them, but not group by them: a terms aggregation on
SYSTEMD_UNITfails withText fields are not optimised for operations that require per-document field data like aggregations and sorting. - The platform’s own connections are logged.
log_connectionsandlog_disconnectionsare on, and the monitoring user_avnadmin_monitorconnects every few seconds, which accounts for a large share of the lines on a quiet service. Exclude them withNOT MESSAGE:"user=_avnadmin_monitor".
Search the Logs
Find the most recent errors, without the platform’s monitoring connections:
curl -s "OPENSEARCH_URI/INDEX_PREFIX-*/_search?pretty" \
-H 'Content-Type: application/json' \
-d '{
"size": 20,
"sort": [{"timestamp": "desc"}],
"_source": ["timestamp", "MESSAGE"],
"query": {"query_string": {"query": "MESSAGE:ERROR AND NOT MESSAGE:\"user=_avnadmin_monitor\""}}
}'The match is full text and ignores case, so MESSAGE:ERROR also returns lines that contain the word
anywhere, such as LOG: SSL error: unexpected eof while reading.
To chart and browse the same indices, add them to Grafana as shown in Visualize a service in Managed Grafana.
Where the Logs Are Stored
The logs are stored in the zone of the OpenSearch service. Keep both services in the same zone when the logs must stay in one country.
Delete the Integration
exo api delete-dbaas-integration INTEGRATION_ID -z ZONEParameters:
INTEGRATION_ID: the ID returned when the integration was created, also listed in theintegrationsfield of the service.ZONE: zone of the PostgreSQL service.
The indices already written stay in OpenSearch. Deleting the OpenSearch service also deletes the integration.