# sum

The sum operator calculates the sum of the metrics values that match a metric query.

Calculates the sum of the metrics values that match the query. If grouping is specified, it calculates the sum for each group.

### sum syntax

`sum [by FIELD [, FIELD, ...]]`

### sum examples

#### Sum the value of a metric

This query calculates the total of the `cpu_system`

metric values across all time series whose `dep`

tag equals “prod”.

`dep=prod metric=cpu_system | sum`

#### Sum the value of a metric by one field

This query calculates the total of the `cpu_system`

metric values across all time series whose `dep`

tag equals “prod” by node.

`cluster=search metric=cpu_idle | sum by node`