Skip to content

Commit

Permalink
fix: Fix query error when database is prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchao authored and taloric committed Jul 18, 2024
1 parent e4eba34 commit 6eb9865
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions server/querier/engine/clickhouse/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func GetMetrics(field, db, table, orgID string) (*Metrics, bool) {
newAllMetrics[field] = metric
}
}
} else if db == ckcommon.DB_NAME_PROMETHEUS {
} else if db == ckcommon.DB_NAME_PROMETHEUS && field == "value" {
metric := NewMetrics(
0, field,
field, "", METRICS_TYPE_COUNTER,
Expand Down Expand Up @@ -258,21 +258,22 @@ func GetMetrics(field, db, table, orgID string) (*Metrics, bool) {
return metric, ok
} else {
// xx_id is not a metric
noIDField := strings.ReplaceAll(field, "_id", "")
_, ok = newAllMetrics[noIDField]
if ok {
return nil, false
} else {
// Dynamic tag metrics
dynamicTagDescriptions, err := tag.GetDynamicTagDescriptions(db, table, "", "", orgID, true, context.Background(), nil)
if err != nil {
log.Error("Failed to get tag type dynamic metrics")
if strings.Contains(field, "_id") {
noIDField := strings.ReplaceAll(field, "_id", "")
_, ok = newAllMetrics[noIDField]
if ok {
return nil, false
}
GetTagTypeMetrics(dynamicTagDescriptions, newAllMetrics, db, table, orgID)
metric, ok := newAllMetrics[field]
return metric, ok
}
// Dynamic tag metrics
dynamicTagDescriptions, err := tag.GetDynamicTagDescriptions(db, table, "", "", orgID, true, context.Background(), nil)
if err != nil {
log.Error("Failed to get tag type dynamic metrics")
return nil, false
}
GetTagTypeMetrics(dynamicTagDescriptions, newAllMetrics, db, table, orgID)
metric, ok := newAllMetrics[field]
return metric, ok
}
}

Expand Down

0 comments on commit 6eb9865

Please sign in to comment.