PubNub
Analytics Plus can stream messages from PubNub channels. Analytics Plus subscribes to channels or channel groups with the Subscription Key and adds each message to a stream table as it arrives. One connection can supply several stream tables, with each table reading its own channels.
Before you begin
- Stream Analytics is available only in the Enterprise edition of Analytics Plus.
- You need the subscribe key for the PubNub keyset.
- If Access Manager is enabled, you need an auth key with read access to the required channels or channel groups.
- Messages must be JSON whose keys match the table column names exactly, including case.
Note: Use flat JSON. A nested object is stored in a single text column.
Connecting to PubNub
- Click Import Your Data at the top-right corner of the Home page.
- Select Streaming Data in the Category list, and click PubNub.
- If the Import Streaming Data into Analytics Plus pane appears, click Proceed.
- Enter a Workspace Name if you started from the Home page.
- Enter the Subscription Key.
- If Access Manager is enabled, enter the Access Manager Auth Key.
- Under How do you want to import?, select Channels or Channel Groups.
- Enter up to five names, pressing Enter after each name, and click Next.

Note: Enter the subscribe key, not the publish key.
Designing the table
| Option | Use it when | What happens |
| Design table manually | You know the keys and data types. | Add each column yourself. |
| Provide sample data | You have a sample message. | Analytics Plus fills the columns from the JSON. |
| Fetch data automatically from source | Messages are being published. | Analytics Plus reads live messages for up to 120 seconds and fills the columns. |

Design the table manually
- Select Design table manually and click Next.
- Add one column for each JSON key and specify its data type.
Provide sample data
- Select Provide sample data.
- Paste a JSON object or array in Provide sample JSON.
- Click Next and review the generated columns.

Fetch data automatically from the source
- Select Fetch data automatically from source.
- Click Fetch Table Metadata. Analytics Plus reads messages for up to 120 seconds.
- When a message arrives, Analytics Plus fills the columns.
Reviewing table details
- Enter a unique Table Name.
- Review each column's name, data type, mandatory setting, default value, and personal-data setting.
- Add columns if required, and click Next.

Note: Columns fetched from PubNub include a ChannelName column.
Validating and importing data
- Optionally set the retention period and turn on Enable Historical Data.
- Confirm that messages are being published.
- Click Validate & Import Streaming Data. Analytics Plus reads messages for 120 seconds.

After a matching message arrives, the status changes to Consuming Streaming Data. If validation fails, review the Failure Reason(s), correct the issue, and click Validate Again.
Managing the data source

Open Data Sources and select the PubNub source. You can:
- View each table's channels, Last Fetched Time, and Streaming Status.
- Validate, pause, or resume individual tables, or pause and resume all tables.
- Use Edit Setup to change keys.
- Use Add Table to create another table on the same connection.
- Edit a table's channels or retention and review failure details.
Note: A channel or channel group can be read by only one table in the same data source.
Retention and historical tables
- Rows remain in the stream table for one hour by default. Set a retention period from 30 minutes to 24 hours.
- Enable Historical Data creates
{Stream table name} - Historical_Tablefor each stream table. - Turning it off stops new rows but preserves the historical table and existing data.
Note: Historical table rows count toward the workspace row limit.
Streaming statuses
- Yet to be validated: Awaiting validation.
- Validating: Reading messages for 120 seconds.
- Consuming: Importing data.
- Paused: Import paused.
- Validation Failed: No matching message arrived.
- Failed: Repeated messages could not be processed.
Limits
- A stream table holds up to 1 million rows or one hour of data.
- Each table can read up to five channels or channel groups.
- A workspace cannot have two PubNub sources with the same keys.
- Stream tables cannot be copied.
- Reports refresh about every 30 seconds; dashboards require a manual refresh.
Frequently asked questions
When is the Access Manager Auth Key required?
It is required only when Access Manager is enabled. The key must have read access to the channels or channel groups.
Why does Analytics Plus report that the same credentials already exist?
A PubNub source with the same keys already exists in the workspace. Open it on the Data Sources page and click Add Table.
Does pausing a stream delete its data?
No. Existing rows remain until the retention period removes them.

