Queries for metrics visualizations

Once you receive your app’s raw metrics export and review the raw metrics glossary, you can build queries in Datadog or New Relic. These examples complement your Operational Dashboards. Use them to turn raw data into actionable insights quickly.

Replace CUSTOMER with your actual customer tag, for example customer:acme-prod. New Relic queries use WHERE filters instead of tags.

Performance and troubleshooting

Aggregation on large ranges may take up to 30–60 seconds. If a query returns no results, confirm the time window and filters (for example, customer) match your app configuration.

Datadog

Use these queries to power Datadog dashboards and alerts. Adapt filters (such as customer) to your environment.

Request data

Start here to understand overall traffic.

Total requests by region

sum:pubnub.http_status{customer:CUSTOMER} by {region}.as_count()

Total requests by API

sum:pubnub.http_status{customer:CUSTOMER} by {api}.as_count()

Requests per second

sum:pubnub.http_status{customer:CUSTOMER} by {region}.as_rate()

Max requests per second per API

top(sum:pubnub.http_status{customer:CUSTOMER} by {api}.as_rate(), 5, 'max', 'desc')

Connection optimization tracking (499 status monitoring)

Status 499 means the client closed the connection. Track this to spot timeout handling or network optimization effects.

sum:pubnub.http_status{customer:CUSTOMER,status:499} by {api}.as_count()

Client error data

Use these to track client‑side failures and their impact.

Count

sum:pubnub.http_status{customer:CUSTOMER,status_class:4xx,!status:499}.as_count()

Percentage

sum:pubnub.http_status{customer:CUSTOMER,status_class:4xx,!status:499}.as_count()/sum:pubnub.http_status{customer:CUSTOMER,!status_class:5xx}.as_count()*100

Client errors (4xx) non 403/499

sum:pubnub.http_status{customer:CUSTOMER,status_class:4xx,!status:499,!status:403} by {api,status}.as_count()

Client unauthorized errors (403)

sum:pubnub.http_status{customer:CUSTOMER,status:403} by {api}.as_count()

Messaging: publish | subscribe | history | signals | Message Actions | file sharing

Use these to confirm healthy traffic for key messaging features.

Healthy publishes

sum:pubnub.http_status{customer:CUSTOMER,api:publish,status_class:2xx}.as_count()

Healthy subscribes

sum:pubnub.http_status{customer:CUSTOMER,api:subscribe,status_class:2xx}.as_count()

Healthy history

sum:pubnub.http_status{customer:CUSTOMER,api:history,status_class:2xx}.as_count()

Healthy signal publishes

sum:pubnub.http_status{customer:CUSTOMER,api:signal,status_class:2xx}.as_count()

Healthy Message Reactions

sum:pubnub.http_status{customer:CUSTOMER,api:message-actions,status_class:2xx}.as_count()

Healthy file sharing publish

sum:pubnub.http_status{customer:CUSTOMER,api:files.publish-file,status_class:2xx}.as_count()

Presence | Access Manager | channel registrations

Use these to track Presence calls, Access Manager grants, and channel group activity.

Healthy presence total

sum:pubnub.http_status{customer:CUSTOMER,api:presence,status_class:2xx}.as_count()

Healthy Access Manager grants

sum:pubnub.http_status{customer:CUSTOMER,api:auth-grant,status_class:2xx}.as_count()

Healthy channel registrations

sum:pubnub.http_status{customer:CUSTOMER,api:channel-registration,status_class:2xx} by {status}.as_count()

Server errors

Use this to monitor server‑side failures.

Server errors (5xx)

sum:pubnub.http_status{customer:CUSTOMER,status_class:5xx} by {api,status}.as_count()

New Relic

Use these queries to build New Relic charts and alerts. Replace facets and filters to match your accounts and entities. Each query mirrors the Datadog examples above.

Request data

Start here to understand overall traffic.

Total requests by region

SELECT sum(`pubnub.http_status.value`) FROM Metric FACET region

Total requests by API

SELECT sum(`pubnub.http_status.value`) FROM Metric FACET api

Client closed connections (499)

SELECT sum(`pubnub.http_status.value`) FROM Metric where status = 499 FACET api TIMESERIES

Client error data

Use these to track client‑side failures and their impact.

Count

SELECT sum(`pubnub.http_status.value`) FROM Metric where status_class = '4xx' and status NOT IN ('403', '499')

Percentage

SELECT filter(count(*), WHERE status_class = '4xx' and status NOT IN ('403', '499')) / count(*) FROM Metric TIMESERIES

Client errors (4xx) non 403/499

SELECT sum(`pubnub.http_status.value`) FROM Metric where status_class = '4xx' and status NOT IN ('403', '499') FACET api, status TIMESERIES

Client unauthorized errors (403)

SELECT sum(`pubnub.http_status.value`) FROM Metric where status = '403' FACET api TIMESERIES

Messaging: publish | subscribe | history | signals | Message Actions | file sharing

Use these to confirm healthy traffic for key messaging features.

Healthy publishes

SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'publish' and status_class = '2xx' TIMESERIES

Healthy subscribes

SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'subscribe' and status_class = '2xx' TIMESERIES

Healthy history

SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'history' and status_class = '2xx' TIMESERIES

Healthy signal publishes

SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'signal' and status_class = '2xx' TIMESERIES

Healthy Message Reactions

SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'message-actions' and status_class = '2xx' TIMESERIES

Healthy file sharing publish

SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'files.publish-file' and status_class = '2xx' TIMESERIES

Presence | Access Manager | channel registrations

Use these to track Presence calls, Access Manager grants, and channel group activity.

Healthy presence total

SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'presence' and status_class = '2xx' TIMESERIES

Healthy Access Manager grants

SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'auth-grant' and status_class = '2xx' TIMESERIES

Healthy channel registrations

SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'channel-registration' and status_class = '2xx' TIMESERIES

Server errors

Use this to monitor server‑side failures.

Server errors (5xx)

SELECT sum(`pubnub.http_status.value`) FROM Metric where status_class = '5xx' FACET api, status TIMESERIES
Last updated on