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_vector or scalar)
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
		
Note

Differences from Prometheus

Native histogram operands, such as h * 2, and some pairs of instant vectors, listed in Prometheus compatibility, aren't supported yet.

Divides the left operand by the right operand element-wise. For vector–vector operations, the metric name is dropped.

Operands

lhs, rhs (instant_vector or scalar)
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
		
Note

Differences from Prometheus

Native histogram operands, such as h * 2, and some pairs of instant vectors, listed in Prometheus compatibility, aren't supported yet.

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_vector or scalar)
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
		
Note

Differences from Prometheus

Native histogram operands, such as h * 2, and some pairs of instant vectors, listed in Prometheus compatibility, aren't supported yet.

Multiplies the two operands element-wise. For vector–vector operations, the metric name is dropped.

Operands

lhs, rhs (instant_vector or scalar)
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])
		
Note

Differences from Prometheus

Native histogram operands, such as h * 2, and some pairs of instant vectors, listed in Prometheus compatibility, aren't supported yet.

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_vector or scalar)
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
		
Note

Differences from Prometheus

Native histogram operands, such as h * 2, and some pairs of instant vectors, listed in Prometheus compatibility, aren't supported yet.

Subtracts the right operand from the left operand element-wise. For vector–vector operations, the metric name is dropped.

Operands

lhs, rhs (instant_vector or scalar)
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
		
Note

Differences from Prometheus

Native histogram operands, such as h * 2, and some pairs of instant vectors, listed in Prometheus compatibility, aren't supported yet.