SigNoz/signoz · error · model.ApiError
cannot join the given group keys
Error message
cannot join the given group keys
What it means
For formula (expression) queries, the group-by keys of all referenced queries must be joinable — expression.CanJoin checks compatibility. If group keys don't align (e.g. different groupBy sets that can't be merged), the query is rejected.
Source
Thrown at pkg/query-service/app/parser.go:827
groupKeys[v] = append(groupKeys[v], key.Key)
}
} else {
return nil, &model.ApiError{Typ: model.ErrorBadData, Err: fmt.Errorf("unknown variable %s", v)}
}
}
params := make(map[string]interface{})
for k, v := range groupKeys {
params[k] = v
}
can, _, err := expression.CanJoin(params)
if err != nil {
return nil, &model.ApiError{Typ: model.ErrorBadData, Err: err}
}
if !can {
return nil, &model.ApiError{Typ: model.ErrorBadData, Err: fmt.Errorf("cannot join the given group keys")}
}
}
// If the step interval is less than the minimum allowed step interval, set it to the minimum allowed step interval
if minStep := common.MinAllowedStepInterval(queryRangeParams.Start, queryRangeParams.End); query.StepInterval < minStep {
query.StepInterval = minStep
}
if query.DataSource == v3.DataSourceMetrics {
// if the time range is greater than 1 day, and less than 1 week set the step interval to be multiple of 5 minutes
// if the time range is greater than 1 week, set the step interval to be multiple of 30 mins
start, end := queryRangeParams.Start, queryRangeParams.End
if end-start >= 24*time.Hour.Milliseconds() && end-start < 7*24*time.Hour.Milliseconds() {
query.StepInterval = int64(math.Round(float64(query.StepInterval)/300)) * 300
} else if end-start >= 7*24*time.Hour.Milliseconds() {
query.StepInterval = int64(math.Round(float64(query.StepInterval)/1800)) * 1800
}
}View on GitHub (pinned to 5069bf80b0)
Solutions
- Align group-by dimensions across all queries used in the expression (use the same groupBy set)
- Group at a common coarser dimension present in both queries
- Remove the formula or split it into separate panels if the join is semantically invalid
Example fix
// before A: groupBy [service_name]; B: groupBy [operation_name]; expr: A + B // after A: groupBy [service_name]; B: groupBy [service_name]; expr: A + B
Defensive patterns
Strategy: validation
Validate before calling
keys := map[string][]string{}
for _, v := range vars { keys[v] = groupKeysOf(v) }
if can, _, err := expression.CanJoin(toParams(keys)); err != nil || !can { return errors.New("group-bys are not joinable; align dimensions") } Prevention
- Use identical groupBy sets for queries combined in formulas
- When formulas are needed, prefer single-query formulas or shared dimensions
When it happens
Trigger: Formula 'A + B' where A groups by service_name and B groups by operation_name (disjoint group-bys), producing a non-joinable combination.
Common situations: Building a formula over queries with mismatched group-by dimensions in the dashboard UI; modifying groupBy of one query after creating the formula.
Related errors
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/e1c45eeb6a816a9c.
Report an issue: GitHub.