The collector does not connect to the Cosmos DB data endpoint and does not need a Cosmos DB account key. It consumes diagnostic records from Event Hubs and exports derived metrics to QueryComment.
Before you start
Make sure you have:- An Azure Cosmos DB account.
- A QueryComment ingest token from your dashboard.
- Permission to create an Event Hubs namespace, event hub, diagnostic setting, managed identity, and role assignment.
- Permission to attach a user-assigned managed identity to the collector host.
- A Linux collector host with Docker and the Azure CLI installed.
- Outbound access from the collector host to the Event Hubs namespace and
ingest.querycomment.com:443.
Configure Azure
1
Set the resource names
Sign in with the Azure CLI, then set values for your environment:
2
Create the diagnostic Event Hub
Create a Standard Event Hubs namespace and a dedicated event hub:Create the namespace authorization rule Azure Monitor uses to deliver diagnostic records:Azure Monitor requires this diagnostic-setting rule to have
Manage, Send, and Listen. The collector does not use this rule.If you restrict Event Hubs networking, allow trusted Microsoft services to bypass the namespace firewall so Azure Monitor can deliver diagnostic records.
3
Route Cosmos DB diagnostics
Enable exactly Leave the Cosmos DB diagnostics full-text query feature disabled.
DataPlaneRequests and QueryRuntimeStatistics on the Cosmos DB account:QueryRuntimeStatistics keeps query text and parameters obfuscated by default, and the collector never exports the raw or correlated diagnostic records as logs.4
Create the collector identity
Create a user-assigned managed identity and grant it receiver access to only the dedicated Event Hub:The collector needs no role on the Cosmos DB account. Azure role assignments can take several minutes to propagate.
5
Attach the identity to the collector host
Attach the identity to an existing Azure VM:For another Azure compute service, attach the same user-assigned identity through that service’s identity configuration.
Run the collector
Use the QueryComment Cosmos DB collector. The collector is available as theghcr.io/querycomment/collector-cosmos:0.1.0 Docker image.
Set these environment variables on the collector host:
Example
.env file:
$Default consumer group. One collector instance can consume multiple Event Hubs through named receivers.
Consume multiple Event Hubs
The bundled managed identity configuration accepts one Event Hub throughAZURE_EVENT_HUB_NAME and AZURE_EVENT_HUB_NAMESPACE. To consume multiple Event Hubs, start with cosmosdb-managed-identity.yaml and define a named receiver for each hub:
Keep the remaining extensions, processors, connector, exporter, and metrics pipeline from the bundled configuration. Changing the service.name action from upsert to insert preserves the Cosmos account name emitted by the connector while still labeling host metrics.
Grant the collector identity Azure Event Hubs Data Receiver on every Event Hub it consumes. Correlation and series limits are shared across all configured receivers, so increase the optional capacity controls when the combined workload requires it. Separate collector instances remain useful when you need per-account failure or capacity isolation.
Verify the integration
From the Azure provisioning shell, confirm the diagnostic setting and Event Hubs traffic:Collection behavior
Cosmos DB writes query text toQueryRuntimeStatistics and request charge, duration, bytes, and status to DataPlaneRequests. The collector accepts either arrival order and correlates query records exactly by Azure resource ID and ActivityId.
Successful Document creates with HTTP 201 are emitted immediately as INSERT statements. Query and insert records are aggregated in memory and emitted every 20 seconds as monotonic delta sums.
Average RU and duration are calculated downstream by dividing their sums by calls.
Unmatched query records are held in memory for up to two minutes. Pending records and active statement series are each bounded to 100,000 by default. Event Hub replay or an ambiguous downstream retry can produce duplicate data.
Optional collector controls: