How can I get the number of records in a SOW topic?

There several ways to get the number of records in a SOW topic without pulling every record into the client. Here are the best ways in order of preference:

  1. You can request a stats acknowledgement with a TopN value of 0 in a sow query. This will execute a SOW query against the topic, but not return any records to your client. After the query is complete, AMPS will return a stats acknowledgement to your client containing the total number of messages evaluated for the query. If you're using just a single topic (not a regex pattern covering multiple topics) then this number is the number of records within the SOW topic. This approach has the advantage that you can run the exact query that you need information on, including content filtering and regex topics.

  2. You can subscribe to the /AMPS/SOWStats topic (or query it if you're capturing it to its own SOW topic). AMPS publishes statistics information to this topic. You can find more details on this approach in the AMPS User Guide. With this approach, you only get information about whole topics, and you need to monitor, and store messages from the subscription (or the results of the query) to be able to use the information.

  3. You can issue a HTTP GET request to the Administrative interface programmatically and get the number of "valid_keys" for the SOW topic. More information on that approach is available in the AMPS Monitoring Reference. This may be the best way to get the information if you need the number of records for an application (like a dashboard) that is already using the Administrative interface, and that doesn't otherwise use the AMPS client libraries.

The bottom line here is that there are several ways to get the information.

keywords: SOW size, SOW records

Last updated