Sending Azure and Google Cloud logs to Loki

Azure logs reach self-hosted Loki through the Event Hubs Kafka endpoint, which needs a non-Basic tier, and Google Cloud logs through Pub/Sub with Grafana Alloy. This page covers both paths, their prerequisites and where they fail.

On this page

How Azure and Google Cloud logs reach Loki with Grafana Alloy

Loki does not reach out to Azure or Google Cloud to collect anything, so a team that runs workloads in either cloud and wants platform logs in self-hosted Loki needs a shipper in between. In Grafana's tooling, that shipper is Grafana Alloy. The loki.source.azure_event_hubs component reads messages from Azure Event Hubs through the Event Hubs Apache Kafka endpoint, and the loki.source.gcplog component reads logs from Google Cloud Pub/Sub subscriptions, using either push or pull delivery. Both components run inside your own network, and both forward entries to a loki.write component that points at your Loki cluster. Your cloud accounts, your Alloy hosts and your Loki deployment remain the places where the data lives.

The Azure path has a licensing dependency that is easy to miss until late in a project. The Event Hubs Kafka endpoint is not available on the Basic pricing tier, so the namespace that receives your diagnostic or activity logs must run on a tier that exposes that endpoint. Confirm the tier of each namespace before you design the pipeline, and confirm with Microsoft what the current tier names and feature matrix include, because the pricing model is the vendor's to define. On the Google side, decide early whether each Pub/Sub subscription will be push or pull, which determines how Alloy must be reachable from Google Cloud and how it authenticates. Check the loki.source.gcplog reference for the current configuration keys before you write them into a runbook.

Before you build either path, write down three things for each source: which Alloy host or cluster will consume it, which Loki tenant will own the resulting streams, and which labels the team will set at the edge so that queries stay fast and cardinality stays bounded. Those decisions shape the Alloy configuration more than the cloud-side setup does. Then test with one low-volume source end to end, confirming that entries arrive in Grafana with the expected labels, before you connect production subscriptions. Ask your Azure and Google Cloud administrators to confirm the identities, network paths and roles Alloy will use, since those permissions are the usual reason a first deployment collects nothing.

What you need before connecting Azure or Google Cloud to Loki

The Azure and Google Cloud paths share one requirement: a running self-hosted Loki that Alloy can reach over the network. Beyond that, each cloud has its own resources to create and permissions to grant before Alloy can read a single message.

A reachable self-hosted Loki

Both paths end at a Loki push endpoint, so the Loki deployment must exist and be reachable from the Alloy host or pod before you start. Confirm the network path from wherever Alloy runs, including firewall rules and TLS, and decide whether auth_enabled is true so each request carries an X-Scope-OrgID tenant header. Loki has no built-in authentication, so the endpoint should sit behind an authenticating reverse proxy. Check the destination before you configure the source, because a silent write failure looks like missing logs.

Loki send data docs

Event Hubs namespace on a qualifying tier

The Kafka endpoint that loki.source.azure_event_hubs reads from is not available on the Basic pricing plan. Confirm that the namespace you plan to use is on a tier that includes the Kafka endpoint before building anything else, because changing tiers later can alter cost and configuration. Ask the Azure team who owns the namespace, which region it lives in, and whether network restrictions such as private endpoints or IP filters will block Alloy.

Alloy Event Hubs reference

Event Hub, consumer group and access policy

Create a dedicated event hub for the diagnostic or application logs you want, plus a consumer group reserved for Alloy so its read position does not collide with other readers. Attach a shared access policy with listen rights only, scoped to that hub. Confirm the exact authentication fields and any Azure SDK requirements against the current Alloy reference page, since these are set in the component configuration and may change between releases.

Pub/Sub topic and subscription

For Google Cloud, the source reads logs through a Pub/Sub subscription, so create the topic that receives the log export and a subscription for Alloy. Decide early between push and pull delivery, because the Alloy component supports both and the choice determines how the endpoint must be reachable. Name the subscription for its purpose so that acknowledgement and retry behavior can be traced to one consumer.

Alloy gcplog reference

Service account with least-privilege roles

Create a dedicated service account for Alloy and grant only the Pub/Sub roles needed to consume from the subscription. Confirm the exact role names against the current Alloy gcplog reference and Google Cloud IAM documentation rather than relying on memory. Keep the key file or workload identity mechanism out of shared configuration, and record who owns the account so that rotation is not forgotten.

Source log export configured

Neither cloud sends logs on its own. On Azure, the diagnostic settings or producers must write to the hub you created. On Google Cloud, a log sink must route the chosen resource logs, such as GCS, load balancer or GKE logs, into the Pub/Sub topic. Decide which log categories to export, since this drives volume, label design and the amount Loki must store.

Configuring the Azure Event Hubs and GCP Pub/Sub pipelines

This sequence takes you from cloud resources to a verified LogQL result in self-hosted Loki, with Azure and Google Cloud handled as separate paths. Each step closes with a check so you know the pipeline works before you move on.

  1. Confirm the Event Hubs pricing tier

    For Azure, confirm that the Event Hubs namespace is on a pricing plan that exposes the Apache Kafka endpoint. Alloy's loki.source.azure_event_hubs reads through that endpoint, and the Basic plan does not offer it, so a Basic namespace has to be upgraded before anything else can work. Your Azure administrator owns this decision and its cost. Done means the namespace shows a tier that supports the Kafka endpoint and you have an event hub with a consumer group reserved for Alloy. Check it by confirming the namespace's Kafka endpoint address resolves and that a test producer can publish to the hub.

  2. Create the Pub/Sub topic and subscription

    For Google Cloud, create a Pub/Sub topic that receives the log sink output and a subscription that Alloy will read. Choose pull delivery if Alloy will reach out to the subscription from your network, or push delivery if Google must call an HTTPS endpoint that Alloy exposes, and confirm which one your network design supports before you pick. Create a log sink in Cloud Logging that routes the chosen resources, such as GCS bucket access logs, load balancer logs or GKE logs, to the topic. Done means the sink exists and the subscription shows that messages are queued when you generate a sample log entry.

  3. Grant Alloy read access to the sources

    Create a dedicated identity for Alloy in each cloud. In Azure, assign a role that lets it receive from the event hub and use the consumer group, and supply its connection details through a secret your platform team manages. In Google Cloud, create a service account and grant it subscriber access on the subscription only, not project-wide. Keep these credentials out of plain configuration files. Done means each identity can read: test with the Azure CLI or the Google Cloud CLI using that identity, and confirm it can receive a sample message without holding broader rights.

  4. Define the Azure Alloy component block

    On the host or cluster that runs Alloy, add a loki.source.azure_event_hubs block for Azure. Point it at the Event Hubs Kafka bootstrap address, the hub name, the consumer group and the authentication settings from the previous step. Set labels that stay low in cardinality, such as the cloud, service and resource type, and leave high-variance fields in the log body or structured metadata. Give the component a clear label so later blocks can reference its output. Done means Alloy starts without configuration errors and its component status reports the source as healthy.

  5. Define the GCP Alloy component block

    Add a loki.source.gcplog block for Google Cloud in the same Alloy configuration. Set the project ID, the subscription name and whether it uses pull or push, and point it at the service account from the previous step. If you chose push, configure the listener address and the HTTPS endpoint that Google calls, and place it behind your standard TLS and network controls. Apply the same low-cardinality label discipline used for Azure. Done means Alloy reports the component as running and, for pull mode, that it is connected to the subscription.

  6. Forward both sources to loki.write with the tenant header

    Route the outputs of both source components to a loki.write block that targets your self-hosted Loki push endpoint. If auth_enabled is true in Loki, set the X-Scope-OrgID header to the tenant that should own these logs, and use separate tenants for Azure and Google Cloud if your access model requires it. Keep the receiver and the reverse proxy in front of Loki in the path, because Loki has no built-in authentication layer. Done means Alloy reports successful writes to Loki and no 401 or 429 responses appear in its logs.

  7. Verify with a test message in LogQL

    Generate one known test event in each cloud, such as a tagged message sent to the Event Hub and a labeled entry produced by the sink. In Grafana, query Loki with a LogQL selector that matches your labels and the tenant, then filter for the test tag. Run this check separately for Azure and Google Cloud, because each path can fail for different reasons. Done means both test messages appear with the expected labels in the correct tenant, and you have recorded the query for your runbook.

How cloud log messages flow into Loki

The diagram starts in two cloud accounts: Azure Event Hubs exposes messages through its Kafka endpoint, and Google Cloud Pub/Sub delivers messages from a subscription. Grafana Alloy runs in the client's infrastructure, reads from both through its source components, and forwards entries with loki.write to Loki, which expects the X-Scope-OrgID tenant header. Grafana then queries Loki. The dashed boundaries mark where credentials and network paths cross from the cloud account into the client's environment, so confirm each one before go-live.

Cloud log messages move from provider sources through Alloy into tenant-scoped Loki.

How cloud log fields map to Loki labels and metadata

This table compares the source attributes from Event Hubs and Pub/Sub with where they land in Loki: stream labels, structured metadata, or the log line. Use it to decide which fields to promote to labels and which to keep out of the index. Confirm the exact label output in the Alloy version you deploy, because the component defaults can change between releases.

Source attributeTypical Loki destinationCardinality effectWhat to check
Event Hubs topic and consumer groupStream label for the source, kept lowLow, one value per configured sourceConfirm which label names the component sets by default in your version
Event Hubs partitionLabel only if you need per-partition filteringLow to moderate, bounded by partition countPartition count is fixed per hub, so a label of this kind stays bounded
Pub/Sub subscription nameStream label identifying the pipelineLow, one value per subscriptionUse one subscription per log category where possible
Pub/Sub resource labels such as project or clusterLabel for coarse grouping like project or environmentLow when limited to a handful of valuesAvoid labels for per-instance IDs that multiply across the project
Per-record IDs, trace IDs, request IDsStructured metadata or left in the log lineHigh if promoted to labelsKeep out of labels so streams do not multiply
Message body fields such as resource properties or payloadsParsed in the pipeline only when queried oftenVaries widely by fieldParse at query time in LogQL unless a field is a fixed, small set
Timestamps from the source recordLog entry timestamp, not a labelNoneConfirm which timestamp the component uses when records arrive late

Event Hubs pricing tier and GCP identity choices

The Azure source in Alloy reads messages through the Event Hubs Apache Kafka endpoint. That endpoint is not available on the Basic pricing plan, so an Event Hubs namespace on Basic cannot feed loki.source.azure_event_hubs no matter how the Alloy configuration is written. Check the tier on the namespace itself, because the plan is set per namespace and a namespace created for another purpose may already be on Basic. Azure changes its tier names and feature matrix over time, so confirm the current tiers and the Kafka endpoint availability for each tier in Azure's documentation before you choose.

  • Plan before you provision: Choose the tier when you create the namespace. Confirm the plan that includes the Kafka endpoint, since moving tiers later can change capacity and cost.
  • Check the existing namespace: If the team already runs Event Hubs for other workloads, verify its tier before assuming the Kafka endpoint works.
  • Separate log streams: Give diagnostic logs their own Event Hub so retention and throughput settings do not affect application streams.
  • Cost components: The Azure bill for Event Hubs (tier, throughput capacity, and retention) recurs monthly and sits with the cloud account owner, not with Loki.
  • Quote questions: Ask the partner which tier the design assumes and who approves the cost of that tier.

Before building, confirm the namespace tier and that the Kafka endpoint is enabled for the Event Hub you plan to read.

Securing the cloud credentials and the Loki endpoint

Two paths carry cloud logs into Loki: a pull from Azure Event Hubs and a Pub/Sub subscription from Google Cloud. Each one holds credentials that can read sensitive logs, and the Loki endpoint they write to has to be protected in its own right. The cards below cover the access, secret, transport, tenancy and rotation controls to settle before the pipeline goes live.

Scope the Event Hubs and Pub/Sub access

Give the Alloy identity only the rights it needs: receive from the specific Event Hub or Pub/Sub subscription, not the whole namespace or project. On Azure, the Kafka endpoint must be enabled on a plan that supports it, so confirm the namespace is not on the Basic plan before you create the credential. On Google Cloud, a dedicated service account with subscriber rights on one subscription keeps a leaked key from reading other topics. Review who else holds rights on the same namespace or project.

gcplog reference

Store connection strings and keys outside config

Keep the Event Hubs connection string and the Google Cloud service account key out of Alloy configuration files and version control. Load them from your secret manager or from environment variables injected at runtime, and restrict who can read the secret store. Confirm that Alloy logs and debug output do not echo the credential. A key stored as a file on a shared host is a weaker position than one held in a managed secret store with access logging.

Encrypt every hop to Loki

Loki has no built-in authentication, so the endpoint Alloy writes to must sit behind an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium. Terminate TLS at that proxy and have Alloy send to the HTTPS address with a credential the proxy checks. Use a certificate your Alloy hosts already trust, and confirm the proxy rejects unauthenticated writes, since an open push endpoint accepts logs from anyone who finds it.

Loki authentication docs

Set the tenant ID boundary

When auth_enabled is true, Loki reads the X-Scope-OrgID header on each request to decide which tenant owns the data. Assign a tenant ID per team or per cloud account in the Alloy write configuration, and have the reverse proxy set or validate that header so a client cannot choose another tenant. Cloud logs often include production and development accounts together, so decide early whether they share a tenant. Check that queries from one team cannot see another team's streams.

Multi-tenancy docs

Restrict push sources and rotate credentials

Where a Google Cloud push subscription is used, Pub/Sub delivers messages to an HTTPS endpoint you expose, so allow only known sources and require authentication on the push request. Limit network access to the Alloy listener to the cloud ranges or gateways you actually use. Rotate Event Hubs keys and service account keys on a fixed schedule, and rehearse the change so a rotation does not stop log collection. Record each rotation so you can show when a credential changed.

Why cloud logs fail to arrive in Loki

This table lists the failures that most often stop Azure and Google Cloud logs from reaching self-hosted Loki, with the cause and fix for each. Check the rows in order, since the Azure tier and the Loki tenant header are the first things to rule out before you look at Alloy configuration.

FailureLikely causeFix
Azure Kafka endpoint refuses connectionsEvent Hubs namespace is on the Basic pricing plan, which does not offer the Kafka endpoint used by loki.source.azure_event_hubsConfirm the namespace tier before building. Move to a tier that includes the Kafka endpoint, then retest the connection from the Alloy host
Azure consumer receives no messagesWrong consumer group, or the identity lacks read permission on the Event HubCreate a dedicated consumer group for Alloy and grant the consuming identity data receiver rights. Verify the group name matches the component configuration
Loki returns 401 or no data for Azure or GCP writesAuth is enabled in Loki but the Alloy writer does not send X-Scope-OrgID, or a proxy strips itSet the tenant ID in the Loki write configuration, and confirm the authenticating proxy forwards the header to Loki
Pub/Sub pull subscriber gets no logsService account lacks subscriber permission on the subscription, or the subscription name is wrongGrant the Pub/Sub subscriber role to the Alloy service account on that subscription and check the project and subscription IDs
Pub/Sub push delivery failsAlloy push endpoint is not reachable from Google Cloud, or TLS and authentication do not match the push configurationExpose the endpoint on a reachable address with a valid certificate, then check delivery errors in the subscription metrics
Streams rejected by LokiLabels from cloud resource fields create too many unique streams, or a label is missing its required formKeep labels to a small set such as project, resource type and region, and move detailed fields into structured metadata or the log body

Cost, effort and what your team must provide

What drives the cost of sending Azure and Google Cloud logs to Loki?

The cost depends mainly on how many event sources you connect, how your cloud network and access rules are set up, and whether Loki is run for one team or many. Each Azure Event Hub, Google Cloud Pub/Sub subscription and log source adds configuration, testing and documentation work. Network design, such as private endpoints or push delivery through an endpoint you expose, adds design and security review time. Multi-tenancy adds tenant mapping and access checks. Ask any provider to price these items separately so you can see which ones your scope includes.

Does the Azure Event Hubs Kafka endpoint require a specific pricing tier?

Yes. Alloy's loki.source.azure_event_hubs component reads Event Hubs messages through the Event Hubs Apache Kafka endpoint, and that endpoint is not available on the Basic pricing plan. Confirm the tier of each namespace before scoping the work, because a move to a higher tier is a platform change that your cloud owners must approve and that carries its own cost. Ask your Azure team to check the current tier and the Kafka endpoint availability in your region, since the pricing details are set by Microsoft and may change.

What does our team need to provide before the work starts?

Plan for access and decisions from several owners before work begins:

  • Azure subscriptions, resource groups and Event Hubs namespaces, with rights to create or read consumer groups and access policies
  • Google Cloud projects with rights to create Pub/Sub topics, subscriptions and service accounts, or a named owner who will do it
  • A reachable Loki endpoint, with the reverse proxy and authentication in front of it, and the tenant IDs to use
  • Approvals for network paths, secret storage for credentials, and where Alloy will run

Write these down in the scope so each dependency has an owner and a date agreed in advance.

Can an internal team set this up without a partner?

Often yes, if the team already runs Grafana Alloy, understands Azure Event Hubs or Google Cloud Pub/Sub, and has operated a self-hosted Loki before. The harder parts are usually cross-cloud identity, least-privilege permissions, network paths into a private Loki endpoint, and testing that every expected log type arrives with the right labels. Assess skills in each of these areas, and check whether the same people will run the pipeline after go-live, since operating it is ongoing work.

Is the cost of this work one-time or recurring?

Most of the initial work is one-time: designing the pipelines, creating cloud resources, configuring Alloy, testing and handover. Recurring costs include cloud usage charges for Event Hubs, Pub/Sub and the compute running Alloy, storage costs in Loki's object store, and staff time for upkeep, upgrades and new sources. Ask for each recurring item to be listed separately with the party who pays for it, because cloud consumption is billed by your cloud provider, not by the implementation partner.

What should a written quote for this work include?

A useful quote lists the scope in writing and states what is included and excluded. Ask for:

  • The list of Event Hubs namespaces, Pub/Sub subscriptions and log types in scope
  • The Loki deployment and tenant model assumed, and whether authentication is included
  • Who creates cloud resources, and which credentials and permissions are needed
  • Testing, documentation and handover deliverables, with acceptance criteria
  • Post-go-live support, retainer terms and any assumptions that would change the price

DeployOpen agrees scope, deliverables and timelines in writing before work starts, so a quote should follow from that written scope.

What are the main risks that change effort during the project?

The most common surprises are a Basic-tier Event Hub that must be upgraded, a Pub/Sub service account given broader permissions than intended, and a Loki endpoint that is not reachable from where Alloy runs. Multi-tenant setups add risk when tenant IDs are not agreed early. Each risk adds investigation time, so name an owner for each one in the scope and confirm the tier, network path and permissions in the first design step.

What a DeployOpen cloud log integration includes

A DeployOpen cloud log integration covers the sources you agree on in writing before work starts, usually the Azure Event Hubs namespaces and the Google Cloud Pub/Sub subscriptions that carry your logs. For each source, the work includes the Grafana Alloy configuration (loki.source.azure_event_hubs for Azure, loki.source.gcplog for Google Cloud), the credentials and network paths Alloy needs, the push or pull delivery choice for Pub/Sub, and the write path into your self-hosted Loki. Scope, deliverables and timelines are fixed in a written statement of work, so the boundaries of each source are settled before any configuration is written. Confirm with us whether your Event Hubs tier and your Google Cloud project layout match the assumptions in that document.

The design work matters more than the configuration. DeployOpen proposes the tenant mapping that decides which X-Scope-OrgID value each Azure or Google Cloud source writes to, the label set on each stream, and which fields stay in the log line or move to structured metadata. Label choices made at the edge are hard to undo later, so they are reviewed with your platform and security teams before rollout. Verification follows: DeployOpen supplies LogQL queries that confirm each source is arriving, that tenants see only their own streams, and that labels stay within the cardinality you agreed.

The handover is a runbook and a working integration, not a slide deck. The runbook records each source, its owner, the Alloy component settings, the credential rotation steps, and the queries your operators will use when a stream goes quiet. Ask for the handover contents, the named responsibilities after go-live, and any ongoing support or retesting you want, since those are priced separately and should appear in the quote.

How DeployOpen works on this

DeployOpen plans and builds the cloud log path into your self-hosted Loki, inside your own cloud accounts and networks. Each engagement starts with a written scope covering the Azure or Google Cloud sources, the Alloy pipeline, tenant routing and the Grafana access model. Work is delivered as fixed-scope engagements, with documentation and a handover your team can run.

How we scope

  • Inventory which Azure Event Hubs namespaces or Google Cloud Pub/Sub topics carry logs you need in Loki
  • Confirm the Event Hubs pricing tier supports the Kafka endpoint before any build work starts
  • Agree tenant IDs, label choices and retention periods for each cloud log source in writing

How we build

  • Configure loki.source.azure_event_hubs or loki.source.gcplog in Alloy, with credentials handled through your secrets process
  • Choose push or pull delivery for Pub/Sub subscriptions based on your network and firewall rules
  • Test ingestion end to end, including label cardinality, dropped messages and reconnect behavior

How we hand over

  • Deliver Alloy configuration, subscription and namespace setup notes, and an operations runbook
  • Document the identities, roles and permissions the pipeline uses, and the reason for each
  • Walk your platform and security teams through the verification steps and the fixes for known failures

How we support

  • Offer ongoing support, upgrades and continuous testing for the pipeline as a retainer
  • Review Alloy and Loki version changes against the pipeline before you upgrade
  • Retest the log path after changes to cloud networking, identities or Loki configuration

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.