count
Return the number of points in the stream, optionally filtering on a specified field.
put|reduce count(field)
Parameter | Description | Required? |
---|---|---|
field |
The field on which to filter If field is specified, then count returns the number of points containing that field. If unspecified, it returns the total number of points received. |
No |
Example
This example uses batching. See the batch processor for details about batching.
// On historical data, you can apply reducer to get a single computation,
// or batch your historical data by time, then reduce per batch period.
sub historical_points() {
emit -from :0: -limit 10
| put cnt = count(), value = Math.random()
}
historical_points
| reduce cnt = count()
| view table -title "Historical total count"
;
historical_points
| batch 5
| reduce cnt = count(value)
| view table
-update "append"
-title "Historical 5-second count"
;
// On live streaming data, you must batch by time, then reduce per batch period.
sub live_points() {
emit -limit 10
| put cnt = count(), value = Math.random()
}
live_points
| batch 2
| reduce cnt=count()
| view table
-update 'append'
-title "Live 2-second count"