Azure Event Hub¶
This guide shows how to bring the audit logs of Azure managed databases into QubeSight through Azure Event Hubs, and how to connect any other Kafka-compatible bus with the same integration.
Enterprise
How it works¶
flowchart LR
DB[Azure database, audit on] -- diagnostic setting --> EH[Event Hub, Kafka endpoint 9093]
EH -- QubeSight reads, consumer group --> W[QubeSight worker] --> E[Event table]
Azure writes the audit records to an Event Hub; QubeSight's worker reads them over the Kafka protocol with its own consumer group, parses them with the built-in Azure parser and stores them. The read position is committed only after the events are written, so a restart or an outage never loses events that are still in the hub.
Supported sources: Azure SQL Database, Azure SQL Managed Instance, Azure Database for PostgreSQL flexible server, Azure Database for MySQL flexible server, Cosmos DB for MongoDB (RU and vCore) and Cosmos DB for NoSQL.
Prerequisites¶
- An Event Hubs namespace in the Standard tier or higher. The Basic tier has no Kafka endpoint.
- The namespace in the same region as the database: a diagnostic setting can only write to an Event Hub in its own region. Use one namespace per region.
- QubeSight can resolve
*.servicebus.windows.netand reach it on TCP 9093 outbound. - An Enterprise licence (or the marketplace trial).
Step 1: prepare the Event Hub¶
- Create a hub, for example
db-auditwith 4 partitions. - Create a consumer group for QubeSight, for example
qubesight. - Set the retention longer than the longest outage QubeSight might have. Standard allows up to 7 days; in a longer outage the oldest records are lost at the source.
- Create two shared access policies:
- On the namespace, with Manage, Send and Listen, for the diagnostic settings to write.
- On the hub, with Listen only, for QubeSight. Use its connection string in QubeSight.
Step 2: configure each database¶
Turn on server auditing with the Event Hub as target:
az sql server audit-policy update -g <resource-group> -n <server> --state Enabled \
--event-hub-target-state Enabled \
--event-hub-authorization-rule-id <namespace-policy-id> --event-hub <hub>
The default action groups (BATCH_COMPLETED_GROUP, SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP) deliver every statement and every successful and failed login with user, client IP and SQL text.
- In the diagnostic setting, enable the
SQLSecurityAuditEventscategory. -
In
master, create the audit:
Drivers with connection pooling reset the session for every request, so a "LOGIN SUCCEEDED" record per statement is normal.
| Server parameter | Value |
|---|---|
azure.extensions |
add PGAUDIT |
shared_preload_libraries |
add pgaudit (the server restarts) |
pgaudit.log |
for example READ,WRITE,DDL,ROLE |
log_connections |
on |
log_line_prefix |
%t:%r:%u@%d:[%p]: (recommended) |
Then run CREATE EXTENSION pgaudit; in each database and enable the PostgreSQLLogs category in the diagnostic setting.
The prefix matters: the default prefix (%t-%c-) carries no user, database or client address, so those fields stay empty. With the recommended prefix QubeSight also receives connections, failed logins and failing statements (from the server's ERROR line, because pgaudit does not log failing statements).
- Set
audit_log_enabled = ONandaudit_log_events = CONNECTION,GENERAL(optionallyTABLE_ACCESS). - Enable the
MySqlAuditLogscategory in the diagnostic setting.
Azure writes several records per statement (the statement, an error record if it fails, and one table-access record per table). When they arrive in the same Event Hub message, QubeSight merges them into one event with the error code and table names; the secondary records are counted as merged in Pipeline → Flow.
- Cosmos DB for MongoDB (RU): enable
MongoRequests(optionallyControlPlaneRequests). For query text setdiagnosticLogSettings.enableFullTextQuery = Trueon the account (REST API). - Cosmos DB for MongoDB vCore: enable
vCoreMongoRequests. Command text is included by default; the real user name arrives after authentication, and a failed login arrives asSaslContinueerror 18. - Cosmos DB for NoSQL: enable
DataPlaneRequestsandQueryRuntimeStatistics(optionallyControlPlaneRequests), and full-text query logging for query text.
Requests are written in QubeSight's MongoDB form, <database>.<collection>.<command>({...}). With account keys, the user field holds the key type (for example PrimaryMasterKey); with Microsoft Entra ID the principal arrives.
Step 3: add the integration in QubeSight¶
- Open Data Sources → Stream Sources → Event Hub and press New integration.
-
Fill in:
Field Value Integration Name Free text. Events are tagged with the source eventhub:<name>.Bootstrap Address <namespace>.servicebus.windows.net:9093Topic (Event Hub Name) The hub name Consumer Group The group created for QubeSight (default $Default)Connection String (Azure Event Hubs) The Listen-only policy's connection string. Stored encrypted. SASL Mechanism PLAIN — Azure Event Hubs Use TLS On (must stay on for Azure Event Hubs) -
Press Save, then Test. The worker starts reading within about 15 seconds.

Other Kafka-compatible buses¶
The same integration reads Redpanda, Confluent or Amazon MSK topics. Leave the connection string empty and turn TLS off for a plain connection, or choose SCRAM-SHA-512 — Amazon MSK or SCRAM-SHA-256 — Amazon MSK with a SASL User (MSK). Accepted message formats: a single event JSON, a JSON array, or a {"records": [...]} envelope.
Verification¶
- The card status shows Connection Verified (or Connected (no topic metadata)), Events Received, Last Event, and Worker Status: Listening (~15s).
- Run a statement on the database. Azure delivers diagnostic records with a delay of its own: observed 30 seconds to 3 minutes for SQL and MySQL and up to 10 minutes for PostgreSQL; Cosmos DB for MongoDB (RU) varied from under a minute to more than 20 minutes.
- Platform → Pipeline → Flow shows the lines read by Azure Event Hub and stored.
Azure-managed activity you may want to ignore¶
Built-in rules under Platform → Pipeline → Storage rules → Built-in rules are off by default; turning them on is your decision:
| Rule | Ignores |
|---|---|
| Azure azuresu (Azure Database for PostgreSQL) | Successful activity of Azure's own monitoring user azuresu from 127.0.0.1 (about 100 lines per minute on an idle server). |
| Azure SQL MI connectivity probe | The managed instance's own connectivity checks from its private subnet, about 700 false "LOGIN FAILED" records per hour. Failed logins from public addresses are always stored. |
Without the probe rule, failed-login alerts fill with these probes.
Licence pause¶
The Event Hub reader runs only while Enterprise is active (licence, Azure Marketplace entitlement or the marketplace trial). When the licence or the trial ends, the Enterprise capability turns off and the reader pauses without loss: events already read are written, the position is committed, and no new events are read. The Event Hub tab is hidden while the licence is missing; the integrations are kept. A banner on every page reads Enterprise license required: {n} ingest sources paused. When a licence is applied, the tab returns and reading resumes from the stored position within about 15 seconds. Events wait in the hub only for its retention period (at most 7 days on Standard); older ones are lost at the source. See Licensing.
Throughput¶
Measured with 720-byte records on Event Hubs Standard: a backlog drained at about 4,500 events per second with the default batch size, and a steady 2,000 events per second was read without falling behind (p95 end-to-end latency 10 seconds), with no loss and no duplicates across worker restarts. Each throughput unit carries about 1 MB/s in and 2 MB/s out; size throughput units (or auto-inflate) for your event rate.
Troubleshooting¶
| Symptom | Cause and action |
|---|---|
| Connection Error | Wrong bootstrap address, Basic tier, TLS off, or the connection string lacks Listen. Check DNS resolution of *.servicebus.windows.net and outbound 9093. |
| Connected but no events | Diagnostic setting missing or in another region, audit not enabled, or Azure delivery delay. |
| PostgreSQL events without user or client IP | Default log_line_prefix; set the recommended prefix. |
| Cosmos DB queries without text | Full-text query logging not enabled on the account. |
Limitations¶
- Azure MySQL connection records carry no event time and no failure flag: the intake time is used, and failed logins cannot be told from successful ones in
connection_log. - Cosmos DB for NoSQL writes the request and its query text as two records, often in different Event Hub partitions. They are merged only when they arrive in the same read batch; otherwise the query-text record stays a separate row, linked by the same
activityIdin the session field. - Cosmos DB for MongoDB (RU) does not log failed authentication in this category.
- Azure occasionally loses diagnostic records on its side; a one-minute gap was observed once and could not be reproduced. The source silence alert detects long gaps only (with the default rule, at least 6 hours for a regular source; see Source Health).
- Statement duration is filled for Azure SQL, SQL Managed Instance and Cosmos DB; PostgreSQL and MySQL audit records have none (see Slow-operation logs).