Arithmetic operators
These binary operators perform arithmetic between scalars and instant vectors. For vector–vector operations, the metric name is dropped from the result.
Adds the two operands element-wise. For vector–vector operations, the metric name is dropped.
Operands
lhs,rhs(instant_vectororscalar)- The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
Returns
An instant_vector, or a scalar when both operands are scalars.
Example
requests_total + requests_errors
Divides the left operand by the right operand element-wise. For vector–vector operations, the metric name is dropped.
Operands
lhs,rhs(instant_vectororscalar)- The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
Returns
An instant_vector, or a scalar when both operands are scalars.
Example
requests_errors / requests_total
Returns the remainder of dividing the left operand by the right operand element-wise. For vector–vector operations, the metric name is dropped.
Operands
lhs,rhs(instant_vectororscalar)- The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
Returns
An instant_vector, or a scalar when both operands are scalars.
Example
metric % 10
Multiplies the two operands element-wise. For vector–vector operations, the metric name is dropped.
Operands
lhs,rhs(instant_vectororscalar)- The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
Returns
An instant_vector, or a scalar when both operands are scalars.
Example
100 * rate(requests_total[5m])
Raises the left operand to the power of the right operand element-wise. For vector–vector operations, the metric name is dropped.
Operands
lhs,rhs(instant_vectororscalar)- The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
Returns
An instant_vector, or a scalar when both operands are scalars.
Example
metric ^ 2
Subtracts the right operand from the left operand element-wise. For vector–vector operations, the metric name is dropped.
Operands
lhs,rhs(instant_vectororscalar)- The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
Returns
An instant_vector, or a scalar when both operands are scalars.
Example
requests_total - requests_errors