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
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_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
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_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
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_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])
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_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
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_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
Differences from Prometheus
Native histogram operands, such as h * 2, and some pairs of instant vectors, listed in Prometheus compatibility, aren't supported yet.