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
1sum:pubnub.http_status{customer:CUSTOMER} by {region}.as_count()
Total requests by API
1sum:pubnub.http_status{customer:CUSTOMER} by {api}.as_count()
Requests per second
1sum:pubnub.http_status{customer:CUSTOMER} by {region}.as_rate()
Max requests per second per API
1top(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.
1sum: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
1sum:pubnub.http_status{customer:CUSTOMER,status_class:4xx,!status:499}.as_count()
Percentage
1sum: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
1sum:pubnub.http_status{customer:CUSTOMER,status_class:4xx,!status:499,!status:403} by {api,status}.as_count()
Client unauthorized errors (403)
1sum: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
1sum:pubnub.http_status{customer:CUSTOMER,api:publish,status_class:2xx}.as_count()
Healthy subscribes
1sum:pubnub.http_status{customer:CUSTOMER,api:subscribe,status_class:2xx}.as_count()
Healthy history
1sum:pubnub.http_status{customer:CUSTOMER,api:history,status_class:2xx}.as_count()
Healthy signal publishes
1sum:pubnub.http_status{customer:CUSTOMER,api:signal,status_class:2xx}.as_count()
Healthy Message Reactions
1sum:pubnub.http_status{customer:CUSTOMER,api:message-actions,status_class:2xx}.as_count()
Healthy file sharing publish
1sum: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
1sum:pubnub.http_status{customer:CUSTOMER,api:presence,status_class:2xx}.as_count()
Healthy Access Manager grants
1sum:pubnub.http_status{customer:CUSTOMER,api:auth-grant,status_class:2xx}.as_count()
Healthy channel registrations
1sum: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)
1sum: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
1SELECT sum(`pubnub.http_status.value`) FROM Metric FACET region
Total requests by API
1SELECT sum(`pubnub.http_status.value`) FROM Metric FACET api
Client closed connections (499)
1SELECT 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
1SELECT sum(`pubnub.http_status.value`) FROM Metric where status_class = '4xx' and status NOT IN ('403', '499')
Percentage
1SELECT filter(count(*), WHERE status_class = '4xx' and status NOT IN ('403', '499')) / count(*) FROM Metric TIMESERIES
Client errors (4xx) non 403/499
1SELECT 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)
1SELECT 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
1SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'publish' and status_class = '2xx' TIMESERIES
Healthy subscribes
1SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'subscribe' and status_class = '2xx' TIMESERIES
Healthy history
1SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'history' and status_class = '2xx' TIMESERIES
Healthy signal publishes
1SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'signal' and status_class = '2xx' TIMESERIES
Healthy Message Reactions
1SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'message-actions' and status_class = '2xx' TIMESERIES
Healthy file sharing publish
1SELECT 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
1SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'presence' and status_class = '2xx' TIMESERIES
Healthy Access Manager grants
1SELECT sum(`pubnub.http_status.value`) FROM Metric where api = 'auth-grant' and status_class = '2xx' TIMESERIES
Healthy channel registrations
1SELECT 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)
1SELECT sum(`pubnub.http_status.value`) FROM Metric where status_class = '5xx' FACET api, status TIMESERIES