The Simplest Way to Make Google Pub/Sub and New Relic Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair google pub/sub and new relic to send cloud logs and queue stats into one dashboard. This setup lets engineers watch message backlogs, catch slow consumers, and read system logs in real time. Google Pub/Sub moves events between cloud services at high speed. New Relic reads those events and turns them into charts and alerts. When you link them well, your team spots queue delays before apps break. When you link them poorly, you get missing logs, high bills, and leaked keys. How data f

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams pair google pub/sub and new relic to send cloud logs and queue stats into one dashboard. This setup lets engineers watch message backlogs, catch slow consumers, and read system logs in real time.

Google Pub/Sub moves events between cloud services at high speed. New Relic reads those events and turns them into charts and alerts. When you link them well, your team spots queue delays before apps break. When you link them poorly, you get missing logs, high bills, and leaked keys.

How data flows between google pub/sub and new relic

Data moves between these two tools in two main ways. First, New Relic can poll Google Cloud for queue metrics like message count and age. Second, Google Pub/Sub can push log messages straight to New Relic over HTTPS.

For metric polling, you create a Google Cloud service account for New Relic. You give this account a read-only viewer role on your cloud project. New Relic uses that role to check topic size and subscription lag every few minutes.

For log streaming, Cloud Logging routes entries into a Pub/Sub topic. A push subscription or a small worker function reads each message from that topic. The worker sends the log payload to the New Relic ingest endpoint using an ingest key. This push model keeps log delay low and avoids constant polling.

Common failure modes and role scoping

Many teams take shortcuts when they set up this pipeline. The most common mistake is using a shared service account with broad owner roles. If an attacker steals that key, they can read every topic or delete cloud resources.

Broad New Relic ingest keys cause problems too. Teams often share one ingest key across twenty apps and several cloud projects. When a bad script floods New Relic with junk logs, you cannot shut off just one source. Rotating that single key breaks every app at once.

End-to-End Encryption + New Relic Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Another trap is unlogged edits to topics and subscriptions. Engineers often log in to the cloud console and change retry rules by hand. They might pull sample messages from a live queue to fix a bug. Those messages often hold sensitive data like emails, phone numbers, or card numbers. Without an audit trail, you do not know who read that queue data.

To fix this, scope every role down to the single resource it needs. Give the metric collector permission to read metrics only, not message bodies. Create a separate New Relic ingest key for each pipeline so you can revoke keys safely. Mask sensitive fields like national IDs or emails before logs enter the topic.

Keeping queue operations and alerts clean

Dead-letter queues need special attention in your monitoring setup. When a consumer fails to process a message, Pub/Sub moves it to a dead-letter topic. Your team should watch the message count on that dead-letter topic in New Relic. A single message there often points to a broken schema or a bad deploy.

You also need clear rules for how engineers inspect stuck messages. Pulling raw payloads on a developer laptop leaves copies of user data on local disks. Instead, route admin tasks through a controlled path that logs every read and write action. Data masking rewrites matched fields in results, such as card numbers or phone numbers, during live checks.

Keep network paths tight between your worker functions and your monitoring ingest endpoints. Use private cloud networking where possible and store ingest keys in a secret manager. Check your key usage logs each month and delete any unused service accounts.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Should I use push subscriptions or a worker function to send logs to New Relic?

Use a worker function when you need to batch, filter, or mask logs before sending them. Direct push subscriptions work well for simple payloads that already match the target format.

What permissions does New Relic need to read Google Pub/Sub metrics?

Give the service account only the monitoring viewer role in Google Cloud. It does not need permission to read or publish actual queue messages to track metric health.

How do we stop sensitive user data from reaching New Relic logs?

Scrub or mask fields like emails, phone numbers, and card numbers before publishing to the log topic. You can also run a filter step in your forwarding worker to rewrite matched patterns.

The query runs. The emails stay hidden.