Docs Menu
Docs Home
/
MongoDB Manual
/ / /

sp.processor.sample()

On this page

  • Definition
  • Syntax
  • Command Fields
  • Behavior
  • Access Control
  • Example
  • Learn More
sp.processor.sample()

New in version 7.0: Returns arrays of sampled results from a currently running Stream Processor on the current Stream Processing Instance.

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,
_stream_meta: {
window: {
start: ISODate('2024-03-19T22:09:10.000Z'),
end: ISODate('2024-03-19T22:09:20.000Z')
}
}
}
{
_id: {
device_id: 'device_0'
},
max_temp: 18,
max_watts: 210,
min_watts: 68,
avg_watts: 157,
median_watts: 193,
_stream_meta: {
window: {
start: ISODate('2024-03-19T22:09:10.000Z'),
end: ISODate('2024-03-19T22:09:20.000Z')
}
}
}
{
_id: {
device_id: 'device_10'
},
max_temp: 21,
max_watts: 128,
min_watts: 4,
avg_watts: 66,
median_watts: 4,
_stream_meta: {
window: {
start: ISODate('2024-03-19T22:09:10.000Z'),
end: ISODate('2024-03-19T22:09:20.000Z')
}
}
}
{
_id: {
device_id: 'device_9'
},
max_temp: 10,
max_watts: 227,
min_watts: 66,
avg_watts: 131.4,
median_watts: 108,
_stream_meta: {
window: {
start: ISODate('2024-03-19T22:09:10.000Z'),
end: ISODate('2024-03-19T22:09:20.000Z')
}
}
}
  • Manage Stream Processors

Back

sp.processor.drop