Skip to main content

Send syslog-ng logs to Zerobus Ingest

info

The opentelemetry() destination is part of syslog-ng. For the destination's other options, see syslog-ng's opentelemetry() destination options.

Maintained by: the syslog-ng open-source project, in the syslog-ng/syslog-ng repository.

This page shows how to send logs from syslog-ng into a Unity Catalog Delta table through Zerobus Ingest. syslog-ng reads log messages from its sources and maps the syslog fields to OpenTelemetry log fields in a rewrite. Its opentelemetry() destination then sends each message over OpenTelemetry Protocol (OTLP) gRPC to Zerobus Ingest, which writes it into the table. Because syslog-ng sends the logs straight to Zerobus Ingest, you don't need to run a message bus between syslog-ng and the lakehouse.

When to use syslog-ng​

  • You already run syslog-ng to collect syslog messages or application logs, and you want those messages in Delta tables.
  • You want each message as one row, with the message text in body and the syslog fields in attributes.
  • You want to reshape messages in syslog-ng before they're stored.

How it works​

  • Interface: The opentelemetry() destination sends OTLP over gRPC to the Zerobus Ingest OTLP endpoint. The x-databricks-zerobus-table-name header names the target table, and each request targets one table.
  • Table: Zerobus Ingest doesn't create tables. Create the OpenTelemetry logs table first, then point the destination at it.
  • Authentication: The cloud-auth(oauth2(...)) block gets an OAuth 2.0 token for a service principal. The authorization_details in that block ask for a token that covers the catalog, the schema, and the table.
  • Delivery: syslog-ng sends messages in batches. If the server rejects a batch with a permanent error, syslog-ng drops that batch. Messages held in memory are lost when syslog-ng stops, even on a graceful stop. This configuration has no disk buffer, so if the server stays unreachable long enough to fill the in-memory queue, messages that can't be queued are lost while syslog-ng keeps running. See Troubleshooting.
  • Severity: Syslog levels aren't OpenTelemetry severity numbers, so the configuration sets the OpenTelemetry number and text for each level. See Severity mapping.

Requirements​

  • syslog-ng 4.12.0 and above, with the otel and cloud_auth modules. Earlier versions aren't covered on this page.
  • syslog-ng installed on the host from the packages in Installation from binaries. Steps 3 and 4 assume a host installation, so the Docker image isn't covered on this page. Check the version with syslog-ng --version. The first line shows the version, and the Available-Modules line lists otel and cloud_auth.
  • A workspace in a region that supports Zerobus Ingest. See Availability.
  • A service principal with an OAuth secret. See Configure authentication. The service principal must have the Workspace access entitlement, which Zerobus Ingest requires. See Manage entitlements. Note the service principal's application ID and client secret.
  • A target table that meets the Zerobus Ingest table requirements.
  • Network access from the syslog-ng host to your Zerobus Ingest endpoint and your workspace URL on port 443.
  • Root access on the syslog-ng host, with sudo, to create /run/syslog-ng and start syslog-ng as root (Step 4).
  • Databricks Runtime 15.3 and above to query VARIANT columns. Databricks Runtime 17.3 and above turns on variant shredding when it creates a table with VARIANT columns, and shredded tables can be read only on Databricks Runtime 17.3 and above. To let readers on Databricks Runtime 15.3 to 17.2 query the table, create it on a runtime below 17.3 and omit the optional shredding properties.

Step 1: Create the logs table and grant access​

Zerobus Ingest writes into tables that already exist, so create the table before you start syslog-ng. If readers on Databricks Runtime 15.3 to 17.2 need to query the table, create it on a cluster instead, as the reader requirement in Requirements describes. Otherwise, run this statement in Databricks SQL. Replace the placeholders either way. The columns follow the OpenTelemetry logs table in Configure OTLP clients.

SQL
CREATE TABLE <catalog>.<schema>.<table> (
record_id STRING,
time TIMESTAMP,
date DATE,
service_name STRING,
event_name STRING,
trace_id STRING,
span_id STRING,
time_unix_nano LONG,
observed_time_unix_nano LONG,
severity_number STRING,
severity_text STRING,
body VARIANT,
attributes VARIANT,
dropped_attributes_count INT,
flags INT,
resource STRUCT<
attributes: VARIANT,
dropped_attributes_count: INT
>,
resource_schema_url STRING,
instrumentation_scope STRUCT<
name: STRING,
version: STRING,
attributes: VARIANT,
dropped_attributes_count: INT
>,
log_schema_url STRING
) USING DELTA
CLUSTER BY (time, service_name)
TBLPROPERTIES (
'otel.schemaVersion' = 'v2',
'delta.checkpointPolicy' = 'classic',
'delta.enableVariantShredding' = 'true', -- optional, DBR 17.3 and above
'delta.feature.variantShredding' = 'supported', -- optional, DBR 17.3 and above
'delta.feature.variantType' = 'supported'
);

Then grant the service principal access to the catalog, the schema, and the table:

SQL
GRANT USE CATALOG ON CATALOG <catalog> TO `<service-principal-uuid>`;
GRANT USE SCHEMA ON SCHEMA <catalog>.<schema> TO `<service-principal-uuid>`;
GRANT MODIFY, SELECT ON TABLE <catalog>.<schema>.<table> TO `<service-principal-uuid>`;

Granting ALL PRIVILEGES isn't sufficient for OTLP writes, so grant MODIFY and SELECT on the table explicitly. After these statements run, the service principal can write to the table.

Step 2: Get your endpoints​

The syslog-ng configuration must include the Zerobus Ingest endpoint host and the workspace URL. To find your workspace ID, region, and URL, see Get your workspace URL and Zerobus Ingest endpoint.

The endpoint host is <workspace-id>.zerobus.<region>.gcp.databricks.com, on port 443.

Step 3: Configure syslog-ng​

Save the following content as /etc/syslog-ng/zerobus.conf. The Step 4 commands use this absolute path, so they work from any directory. Replace the placeholders in the @define lines with your values from Steps 1 and 2. For workspace_url, enter the host only, without https://.

The client secret isn't stored in the file. syslog-ng imports the host's environment variables as global variables, so the destination reads DATABRICKS_CLIENT_SECRET from the environment when syslog-ng starts. You set and export this variable in Step 4.

To run syslog-ng as a service, store the secret in a file that only its owner can read, such as a systemd EnvironmentFile= with mode 0600, or load it from your secrets manager. Also restrict the configuration file: make /etc/syslog-ng/zerobus.conf owned by root or the syslog-ng user, and run chmod 600 /etc/syslog-ng/zerobus.conf.

The socket is in a private directory, /run/syslog-ng. Only the application's account can write to it. perm(0600) sets the socket's mode, and owner() and group() set who owns it. syslog-ng's defaults are mode 0666 and owner root, so any local user can send messages to the socket. Create the directory before you start syslog-ng, owned by root, with the producer's group and mode 0750, so the producer can enter it. Don't rely on create-dirs() to create it. The directory it makes can have mode 0700, which the producer can't enter. The dir-perm() and dir-group() global options apply to log directories of file destinations, so they don't change this directory.

Text
@version: current
@include "scl.conf"

# Variables: replace each placeholder with your value.
@define workspace_id "<workspace-id>"
@define zerobus_host "<zerobus-endpoint>" # the endpoint host from Step 2, without the port
@define workspace_url "<workspace-url>"
@define client_id "<service-principal-uuid>"
@define catalog "<catalog>"
@define schema "<schema>"
@define table "<table>"
@define producer_user "<producer-user>" # the account that runs the application
@define producer_group "<producer-group>" # the group of that account

options {
threaded(yes);
};

# Source: the Unix socket that the application writes to
source s_flask {
unix-dgram("/run/syslog-ng/flask-app.sock"
perm(0600)
owner("`producer_user`")
group("`producer_group`")
keep-hostname(yes)
);
};

# Rewrite: map syslog fields to OpenTelemetry log attributes
rewrite r_to_otlp {
# Signal type: tells syslog-ng this is a log record
set("log" value(".otel.type"));

# Timestamps (syslog seconds to nanoseconds)
set("$(* $S_UNIXTIME 1000000000)" value(".otel.log.time_unix_nano"));
set("$(* $R_UNIXTIME 1000000000)" value(".otel.log.observed_time_unix_nano"));

# Severity: syslog levels are not OTel severity numbers, so map them (set in the if-chain below)
set("$(+ 0 9)" value(".otel.log.severity_number"));
set("$(uppercase $LEVEL)" value(".otel.log.severity_text"));

# Log body
set("$MESSAGE" value(".otel.log.body"));

# Span and trace correlation (empty for syslog sources)
set("" value(".otel.log.trace_id"));
set("" value(".otel.log.span_id"));

# Resource attributes: service.name here populates the top-level service_name column
set("$PROGRAM" value(".otel.resource.attributes.service.name"));

# Log attributes
set("$HOST" value(".otel.log.attributes.host.name"));
set("$PID" value(".otel.log.attributes.process.pid"));

# Syslog-specific attributes
set("$FACILITY" value(".otel.log.attributes.syslog.facility"));
set("$FACILITY_NUM" value(".otel.log.attributes.syslog.facility.code"));
set("$PRI" value(".otel.log.attributes.syslog.priority"));

# Event name and instrumentation scope
set("syslog.$FACILITY.$PROGRAM" value(".otel.log.attributes.event.name"));
set("syslog-ng-otel-exporter" value(".otel.scope.name"));
};

# Severity mapping: syslog level to OTel severity number and text
rewrite r_sev_fatal { set("$(+ 0 21)" value(".otel.log.severity_number")); set("FATAL" value(".otel.log.severity_text")); };
rewrite r_sev_error { set("$(+ 0 17)" value(".otel.log.severity_number")); set("ERROR" value(".otel.log.severity_text")); };
rewrite r_sev_warn { set("$(+ 0 13)" value(".otel.log.severity_number")); set("WARNING" value(".otel.log.severity_text")); };
rewrite r_sev_info { set("$(+ 0 9)" value(".otel.log.severity_number")); set("INFO" value(".otel.log.severity_text")); };
rewrite r_sev_debug { set("$(+ 0 5)" value(".otel.log.severity_number")); set("DEBUG" value(".otel.log.severity_text")); };

# Destination: Zerobus Ingest via OTLP/gRPC
destination d_zerobus_logs {
opentelemetry(
url("`zerobus_host`:443")
persist-name("zerobus_logs")

# Target table
headers(
"x-databricks-zerobus-table-name" => "`catalog`.`schema`.`table`"
)

# OAuth 2.0 token request for the service principal
cloud-auth(
oauth2(
client_id("`client_id`")
client_secret("`DATABRICKS_CLIENT_SECRET`")
token_url("https://`workspace_url`/oidc/v1/token")
scope("all-apis")
resource("api://databricks/workspaces/`workspace_id`/zerobusDirectWriteApi")
authorization_details('[
{
"type": "unity_catalog_privileges",
"object_type": "CATALOG",
"object_full_path": "`catalog`",
"privileges": ["USE CATALOG"]
},
{
"type": "unity_catalog_privileges",
"object_type": "SCHEMA",
"object_full_path": "`catalog`.`schema`",
"privileges": ["USE SCHEMA"]
},
{
"type": "unity_catalog_privileges",
"object_type": "TABLE",
"object_full_path": "`catalog`.`schema`.`table`",
"privileges": ["SELECT", "MODIFY"]
}
]')
auth_method(basic)
)
)

# TLS, required for Zerobus endpoints
auth(tls())

# Batching and workers
workers(4)
batch-lines(50)
);
};

# Pipeline
log {
source(s_flask);
rewrite(r_to_otlp);
if (level(emerg..crit)) {
rewrite(r_sev_fatal);
} elif (level(err)) {
rewrite(r_sev_error);
} elif (level(warning)) {
rewrite(r_sev_warn);
} elif (level(notice..info)) {
rewrite(r_sev_info);
} else {
rewrite(r_sev_debug);
};
destination(d_zerobus_logs);
};

Severity mapping​

Each syslog level maps to one OpenTelemetry severity number and text. The if and elif block in the log path picks the rewrite for each level.

syslog level

severity_number

severity_text

emerg, alert, crit

21

FATAL

err

17

ERROR

warning

13

WARNING

notice, info

9

INFO

debug

5

DEBUG

syslog level

severity_number

severity_text

emerg, alert, crit

21

FATAL

err

17

ERROR

warning

13

WARNING

notice, info

9

INFO

debug

5

DEBUG

The rewrites write integers, so the table stores the name for each number, for example SEVERITY_NUMBER_ERROR for 17. Write the number with "$(+ 0 17)" as shown. A plain string such as "17" doesn't produce a number.

Step 4: Validate and start syslog-ng​

Create the socket directory first. The producer's group must be able to enter it, and the socket inside it stays 0600:

Bash
sudo install -d -o root -g <producer-group> -m 0750 /run/syslog-ng

syslog-ng runs as root. Only root can create the socket directory /run/syslog-ng, so start it from a root shell, not from your user shell. A variable set in your user shell doesn't reach a root process. Open a root shell with sudo -i, set the variable there, and check the syntax. The command exits with status 0 when the file is valid.

Bash
sudo -i
read -rsp 'Client secret: ' DATABRICKS_CLIENT_SECRET && export DATABRICKS_CLIENT_SECRET
syslog-ng --syntax-only -f /etc/syslog-ng/zerobus.conf

Start syslog-ng in the foreground, in the same root shell, after you run the export command. The -F flag keeps it in the foreground, -e echoes its messages to stderr, and -v and -d add verbose and debug output. The --persist-file, --control, and --pidfile options give this instance its own files, so it doesn't share them with a syslog-ng service that already runs on the host. Don't stop or restart that service while this instance runs. A systemd unit with RuntimeDirectory=syslog-ng removes /run/syslog-ng when that service stops, by default (RuntimeDirectoryPreserve defaults to no), which takes this instance's socket with it.

Bash
syslog-ng -Fevd -f /etc/syslog-ng/zerobus.conf --persist-file=/run/syslog-ng/zerobus.persist --control=/run/syslog-ng/zerobus.ctl --pidfile=/run/syslog-ng/zerobus.pid

Startup prints the modules and the version. Look for these lines:

Output
Module loaded and initialized successfully; module='otel'
Module loaded and initialized successfully; module='cloud_auth'
syslog-ng starting up; version='4.12.0'

Start syslog-ng before the application. syslog-ng creates the socket at /run/syslog-ng/flask-app.sock when it starts, in the directory from Step 4, and the application writes to that socket. A socket file left by an earlier run doesn't stop syslog-ng from starting.

Step 5: Send log messages​

The application writes to the socket with Python's SysLogHandler. Run it as the <producer-user> account from Step 3, the owner of the socket. The following snippet sets up the handler:

Python
import logging
import logging.handlers

logger = logging.getLogger("health-monitor")
logger.setLevel(logging.DEBUG)

syslog_handler = logging.handlers.SysLogHandler(address="/run/syslog-ng/flask-app.sock")
syslog_handler.setFormatter(
logging.Formatter("%(name)s[%(process)d]: %(levelname)s %(message)s")
)
logger.addHandler(syslog_handler)

logger.info("health_check status=ok latency_ms=45 memory_pct=62")
logger.error("simulated_failure latency_ms=1656 memory_pct=93")
logger.warning("memory_threshold_exceeded memory_pct=93 threshold=85")

Each message becomes one row in the table. Keep syslog-ng running while the application sends messages.

Step 6: Query the table​

Query the messages from the last hour. The body and attributes columns are VARIANT, so cast the fields you read.

SQL
SELECT time, severity_text, body::string AS message
FROM <catalog>.<schema>.<table>
WHERE severity_text IN ('ERROR', 'WARNING')
AND time > current_timestamp() - INTERVAL 1 HOUR
ORDER BY time DESC;
SQL
SELECT
time,
severity_text,
body::string AS message,
attributes:['host.name']::string AS host,
attributes:['syslog.facility']::string AS facility,
attributes:['process.pid']::string AS pid
FROM <catalog>.<schema>.<table>
WHERE time > current_timestamp() - INTERVAL 1 HOUR
ORDER BY time DESC;

The query returns one row for each message that syslog-ng sent. The attributes column holds the syslog host, facility, and process ID.

Troubleshooting​

Symptom

Cause

Fix

Messages sent while syslog-ng is down are missing

syslog-ng isn't running, so the socket refuses the messages

Start syslog-ng first (Step 4). While it is down, the socket refuses messages, so they don't reach Zerobus Ingest.

A message accepted just before a stop or restart is missing

syslog-ng holds queued messages in memory, and this configuration has no disk buffer

Add a disk-buffer() to the destination. The syslog-ng buffering documentation describes the options. Keep the disk buffer and the persist file on persistent storage. The Step 4 command puts --persist-file under /run, which is cleared at reboot, so use a directory on persistent storage, such as /var/lib/syslog-ng, for both in a production setup.

The server responds with error_code='13', and a batch is dropped

A message body isn't valid UTF-8, so the server rejects the batch with a permanent error

Make sure message text is valid UTF-8 before it reaches the destination. An invalid message can cause its batch to be dropped.

severity_number is NULL

The value was a plain string, not an integer

Write the number as an expression, such as "$(+ 0 9)", as in Step 3.

severity_number shows SEVERITY_NUMBER_DEBUG2 for an info message

The syslog level (0 to 7) was written as the OpenTelemetry number

Map each level to its OpenTelemetry number, as in Step 3.

A query for ERROR returns only WARNING rows

The error level was written as ERR

Set severity_text for each level, as in Step 3.

Writes fail with a permission error

The service principal lacks one of the required privileges

Grant USE CATALOG, USE SCHEMA, MODIFY, and SELECT, as in Step 1. ALL PRIVILEGES isn't sufficient for OTLP writes.

Writes fail with a table not found error

The table doesn't exist, or the name in the header doesn't match it

Create the table in Step 1 first, and check that the x-databricks-zerobus-table-name header uses the same <catalog>.<schema>.<table> name.

Querying body or attributes fails

The cluster runs Databricks Runtime 15.2 or below

Use Databricks Runtime 15.3 and above.

Symptom

Cause

Fix

Messages sent while syslog-ng is down are missing

syslog-ng isn't running, so the socket refuses the messages

Start syslog-ng first (Step 4). While it is down, the socket refuses messages, so they don't reach Zerobus Ingest.

A message accepted just before a stop or restart is missing

syslog-ng holds queued messages in memory, and this configuration has no disk buffer

Add a disk-buffer() to the destination. The syslog-ng buffering documentation describes the options. Keep the disk buffer and the persist file on persistent storage. The Step 4 command puts --persist-file under /run, which is cleared at reboot, so use a directory on persistent storage, such as /var/lib/syslog-ng, for both in a production setup.

The server responds with error_code='13', and a batch is dropped

A message body isn't valid UTF-8, so the server rejects the batch with a permanent error

Make sure message text is valid UTF-8 before it reaches the destination. An invalid message can cause its batch to be dropped.

severity_number is NULL

The value was a plain string, not an integer

Write the number as an expression, such as "$(+ 0 9)", as in Step 3.

severity_number shows SEVERITY_NUMBER_DEBUG2 for an info message

The syslog level (0 to 7) was written as the OpenTelemetry number

Map each level to its OpenTelemetry number, as in Step 3.

A query for ERROR returns only WARNING rows

The error level was written as ERR

Set severity_text for each level, as in Step 3.

Writes fail with a permission error

The service principal lacks one of the required privileges

Grant USE CATALOG, USE SCHEMA, MODIFY, and SELECT, as in Step 1. ALL PRIVILEGES isn't sufficient for OTLP writes.

Writes fail with a table not found error

The table doesn't exist, or the name in the header doesn't match it

Create the table in Step 1 first, and check that the x-databricks-zerobus-table-name header uses the same <catalog>.<schema>.<table> name.

Querying body or attributes fails

The cluster runs Databricks Runtime 15.2 or below

Use Databricks Runtime 15.3 and above.

Additional resources​