mstats command: Examples
Examples for using the SPL2 mstats command.
Calculating a single metric grouped by time
The following example shows how to calculate a single metric grouped by time. This example returns the average value of the aws.ec2.CPUUtilization metric in the mymetricdata metric index. Use the bin command to bucket the results into 30 second time spans.
| mstats aggregates=[avg('aws.ec2.CPUUtilization')] predicate=(index=mymetricdata) | bin span=30s
Combining metrics with different metric names
The following example combines metrics with different metric names. This example returns the average value of both the aws.ec2.CPUUtilization and os.cpu.utilization metrics. Group the results by host. Use the bin command to bucket the results into 1 minute time spans. Both metrics are combined and considered a single metric series.
| mstats aggregates=[avg('aws.ec2.CPUUtilization'), avg('os.cpu.utilization')] predicate=(index=mymetricdata) byfields=[host] | bin span=1m
Filtering results on a dimension value and split results by the values of another dimension
The following example filters the results on a dimension value and splits by the values of another dimension. This example returns the average value of the aws.ec2.CPUUtilization metric for all measurements with host=www2. The results are grouped by the values of the app dimension.
| mstats aggregates=[avg('aws.ec2.CPUUtilization')] predicate=(host=www2) byfields=[app]
Specifying multiple aggregations of various metrics arranged by metric_name and put the results into 1 minute bins
The following example specifies multiple aggregations of multiple metrics. This example returns the average and maximum of the resident set size and virtual memory size. The results are grouped by the metric_name. The bin command is used to bucket the results into 1 minute spans.
| mstats aggregates=[avg('os.mem.rss') AS "AverageRSS", max('os.mem.rss') AS "MaxRSS", avg('os.mem.vsz') AS "AverageVMS", max('os.mem.vsz') AS "MaxVMS"] predicates=(index=mymetricdata) byfields=[metric_name] | bin span=1m
Calculating the rate of an accumulating counter metric and group the results by time series
The following example calculates the rate of an accumulating counter metric and groups the results by time series. See Perform statistical calculations on metric time series in Metrics for more information.
| mstats aggregates=[rate('spl.intr.resource_usage.PerProcess.data.elapsed') as 'data.elapsed'] predicate=(index=_metrics) byfields=[_timeseries] | rename _timeseries AS timeseries
Count of all of the measurements for a specific metric in an index
The following example returns a count of all of the measurements for the aws.ec2.CPUUtilization metric in the mymetricdata index.
| mstats aggregates=[count(_value)] predicate=(index=mymetricdata AND metric_name="aws.ec2.CPUUtilization")
See also
mstats command