Build multi-step, math-driven queries directly in Honeycomb—no calculated fields required.
This feature is in beta, and we would love your feedback!
To opt in, join our Pollinators Community Slack and ping us in the #discuss-metrics channel.
Pro and Enterprise users can also contact Honeycomb Support or email support@honeycomb.io.
Query Math adds support for multi-step queries in Honeycomb. You can now define multiple query steps, perform math between them, and visualize the final result—all inline in the Query Builder.
This feature helps you express richer queries without creating temporary calculated fields. Instead of building complex calculated field expressions, you can break down your analysis into logical steps and combine them using simple mathematical formulas.
Use Query Math to:
RATE() and INCREASE()Query Math lets you create multiple query steps, such as Step A and Step B—each with its own SELECT, WHERE, and GROUP BY clauses.
You can then define a formula that references these steps using variables like $A, $B, and so on.
When you run the query, Honeycomb:
Only the final formula result appears in your visualization.
To build a query with Query Math:
Metrics dataset.$A, $B, and so on, and combine them using mathematical operators.k8s.pod.name, then Step B must also group by k8s.pod.name.
Query Math supports standard mathematical operators in intuitive infix notation:
| Operator | Description | Example |
|---|---|---|
+ |
Addition | $A + $B |
- |
Subtraction | $A - $B |
* |
Multiplication | $A * $B |
/ |
Division | $A / $B |
() |
Parentheses for grouping | ($A + $B) / $C |
You can combine these operators to create complex formulas:
(($A / $B) * 100)
This is more intuitive than nested function notation (MULTIPLY(DIVIDE($A, $B), 100)) and easier to read at a glance.
These examples demonstrate common use cases for Query Math. Each shows how to structure your query stages and combine them with formulas.
Compute the percentage of all requests that resulted in 500 errors.
Step A:
SELECT COUNTWHERE status = 500Step B:
SELECT COUNTFormula C:
($A / $B) * 100
Calculate the percentage of successful requests (non-error status codes).
Step A:
SELECT COUNTWHERE status < 400Step B:
SELECT COUNTFormula C:
($A / $B) * 100
Calculate the percentage of available memory that is currently in use, which makes it easier to identify which pods are approaching capacity.
Step A:
SELECT MAX(k8s.pod.memory.usage)Step B:
SELECT MAX(k8s.pod.memory.available)Formula C:
($A / ($A / $B)) * 100
Compare the request rate between two services, which can help you identify load imbalances.
Step A:
SELECT AVG(request_rate) (create query-scoped calculated field request_rate with definition RATE($http.server.requests))WHERE service.name = "api"Step B:
SELECT AVG(request_rate)WHERE service.name = "frontend"Formula C:
$A - $B
Combine different temporal aggregation functions to analyze metric behavior. This query compares the current CPU utilization snapshot against the rate of change, helping you understand CPU usage patterns.
Step A:
SELECT AVG(last_cpu) (create query-scoped calculated field last_cpu with definition LAST($k8s.pod.cpu.utilization))Step B:
SELECT AVG(rate_cpu) (create query-scoped calculated field rate_cpu with definition RATE($k8s.pod.cpu.time))Formula C:
$A / $B
When using GROUP BY in Query Math, all query steps must group by the same dimensions. This ensures that Honeycomb can align the results correctly when evaluating the formula.
For example, if you want to calculate error rates per route:
Step A:
SELECT COUNTWHERE status >= 400GROUP BY http.routeStep B:
SELECT COUNTGROUP BY http.routeFormula C:
($A / $B) * 100
Honeycomb evaluates the formula for each unique value of http.route, producing a separate result for each route.
Query Math works seamlessly with temporal aggregation functions.
You can use RATE(), INCREASE(), SUMMARIZE(), and LAST() in your query steps, then perform math across the results.
For example, to calculate your error rate as a percentage of total throughput:
Step A:
SELECT SUM(error_rate) (create query-scoped calculated field error_rate with definition RATE($http.server.errors)
)Step B:
SELECT SUM(request_rate) (create query-scoped calculated field request_rate with definition RATE($http.server.requests))Formula C:
($A / $B) * 100
This query shows what percentage of your requests per second are errors, using temporal aggregation to normalize both metrics to per-second rates before calculating the ratio.
When you add a formula to your query, only the formula result appears in the visualization. This keeps your charts focused on the final calculated value.
If you want to see the individual step results alongside the formula:
This workflow is useful for debugging or validating intermediate results before combining them.
Use these strategies to build effective Query Math queries:
error_rate or memory_util make steps easier to understand.Keep the following constraints in mind when working with Query Math:
Query Math is actively evolving based on user feedback. Upcoming improvements include:
Query Math is in active beta, and your feedback shapes its development. We’d love to hear about:
Share your feedback in the Pollinators Community Slack in the #discuss-metrics channel, or reach out to Honeycomb Support.