For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.

sp.processor.sample() (mongosh method)

sp.processor.sample()

New in version 7.0:

Returns arrays of sampled results from a currently running Stream Processor on the current Stream Processing Workspace.

This method is supported in Atlas Stream Processing Workspaces.

The sp.processor.sample() method has the following syntax:

sp.processor.sample()

sp.processor.sample() takes no fields.

sp.processor.sample() returns arrays of sampled results from the named, currently running stream processor to STDOUT. This command runs continuously until you cancel it using CTRL-C, or until the returned samples cumulatively reach 40 MB.

The user running sp.processor.sample() must have the atlasAdmin role.

The following example shows an expected response from calling sp.solarDemo.sample() to sample from a stream processor called solarDemo:

sp.solarDemo.sample()
{ _id: { device_id: 'device_5' }, max_temp: 8, max_watts: 66, min_watts: 66, avg_watts: 66, median_watts: 66}{ _id: { device_id: 'device_0' }, max_temp: 18, max_watts: 210, min_watts: 68, avg_watts: 157, median_watts: 193}{ _id: { device_id: 'device_10' }, max_temp: 21, max_watts: 128, min_watts: 4, avg_watts: 66, median_watts: 4}{ _id: { device_id: 'device_9' }, max_temp: 10, max_watts: 227, min_watts: 66, avg_watts: 131.4, median_watts: 108}