Skip to content

Commit

Permalink
feat: change custom category to custom tag category
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaochaoren1 committed Mar 3, 2025
1 parent 6d7d59e commit 727d9f1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/querier/engine/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ func (e *CHEngine) TransSelect(tags sqlparser.SelectExprs) error {
if strings.HasPrefix(sqlparser.String(colName), "pod_ingress") || strings.HasPrefix(sqlparser.String(colName), "lb_listener") {
errStr := fmt.Sprintf("%s is not supported by select", sqlparser.String(colName))
return errors.New(errStr)
} else if sqlparser.String(colName) == "tags" || sqlparser.String(colName) == "metrics" || sqlparser.String(colName) == "attributes" || sqlparser.String(colName) == "packet_batch" {
} else if sqlparser.String(colName) == "tag" || sqlparser.String(colName) == "metrics" || sqlparser.String(colName) == "attribute" || sqlparser.String(colName) == "packet_batch" {
if as != "" {
errStr := fmt.Sprintf("%s does not support as", sqlparser.String(colName))
return errors.New(errStr)
Expand Down
7 changes: 4 additions & 3 deletions server/querier/engine/clickhouse/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ const TagClientEnPrefix = "Client"
const LanguageEN = "en"

const (
NATIVE_FIELD_TYPE_TAG = 1
NATIVE_FIELD_TYPE_METRIC = 2
NATIVE_FIELD_CATEGORY = "Custom"
NATIVE_FIELD_TYPE_TAG = 1
NATIVE_FIELD_TYPE_METRIC = 2
NATIVE_FIELD_CATEGORY_CUSTOM_TAG = "Custom Tag"
NATIVE_FIELD_CATEGORY_METRICS = "metrics"
)

var DB_TABLE_MAP = map[string][]string{
Expand Down
6 changes: 3 additions & 3 deletions server/querier/engine/clickhouse/metrics/ext_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ func GetExtMetrics(db, table, where, queryCacheTTL, orgID string, useQueryCache
metricName := fmt.Sprintf("metrics.%s", externalTag)
lm := NewMetrics(
i, dbField, metricName, metricName, metricName, "", "", "", METRICS_TYPE_COUNTER,
"metrics", []bool{true, true, true}, "", tableName, "", "", "", "", "",
common.NATIVE_FIELD_CATEGORY_METRICS, []bool{true, true, true}, "", tableName, "", "", "", "", "",
)
loadMetrics[fmt.Sprintf("%s-%s", metricName, tableName)] = lm
}
lm := NewMetrics(
len(loadMetrics), "metrics",
"metrics", "metrics", "metrics", "", "", "", METRICS_TYPE_ARRAY,
"metrics", []bool{true, true, true}, "", table, "", "", "", "", "",
common.NATIVE_FIELD_CATEGORY_METRICS, []bool{true, true, true}, "", table, "", "", "", "", "",
)
loadMetrics[fmt.Sprintf("%s-%s", "metrics", table)] = lm

Expand All @@ -97,7 +97,7 @@ func GetExtMetrics(db, table, where, queryCacheTTL, orgID string, useQueryCache
}
lm := NewMetrics(
len(loadMetrics), nativeMetric, displayName, displayName, displayName, "", "", "", METRICS_TYPE_COUNTER,
common.NATIVE_FIELD_CATEGORY, []bool{true, true, true}, "", table, "", "", "", "", "",
common.NATIVE_FIELD_CATEGORY_METRICS, []bool{true, true, true}, "", table, "", "", "", "", "",
)
loadMetrics[fmt.Sprintf("%s-%s", nativeMetric, table)] = lm
}
Expand Down
6 changes: 3 additions & 3 deletions server/querier/engine/clickhouse/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func GetMetrics(field, db, table, orgID string) (*Metrics, bool) {
metric := NewMetrics(
0, fmt.Sprintf("if(indexOf(%s, '%s')=0,null,%s[indexOf(%s, '%s')])", metrics_names_field, fieldName, metrics_values_field, metrics_names_field, fieldName),
field, field, field, "", "", "", METRICS_TYPE_COUNTER,
"metrics", []bool{true, true, true}, "", table, "", "", "", "", "",
ckcommon.NATIVE_FIELD_CATEGORY_METRICS, []bool{true, true, true}, "", table, "", "", "", "", "",
)
return metric, true
} else if fieldSplit[0] == "tag" {
Expand Down Expand Up @@ -280,14 +280,14 @@ func GetMetrics(field, db, table, orgID string) (*Metrics, bool) {
metric := NewMetrics(
0, field,
displayName, displayName, displayName, "", "", "", METRICS_TYPE_COUNTER,
ckcommon.NATIVE_FIELD_CATEGORY, []bool{true, true, true}, "", table, "", "", "", "", "",
ckcommon.NATIVE_FIELD_CATEGORY_METRICS, []bool{true, true, true}, "", table, "", "", "", "", "",
)
return metric, true
} else {
metric := NewMetrics(
0, field,
displayName, displayName, displayName, "", "", "", METRICS_TYPE_NAME_MAP["tag"],
ckcommon.NATIVE_FIELD_CATEGORY, []bool{true, true, true}, "", table, "", "", "", "", "",
ckcommon.NATIVE_FIELD_CATEGORY_CUSTOM_TAG, []bool{true, true, true}, "", table, "", "", "", "", "",
)
return metric, true
}
Expand Down
2 changes: 1 addition & 1 deletion server/querier/engine/clickhouse/tag/description.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ func GetDynamicTagDescriptions(db, table, rawSql, queryCacheTTL, orgID string, u
}
response.Values = append(response.Values, []interface{}{
externalTag, externalTag, externalTag, displayName, displayName, displayName, "string",
ckcommon.NATIVE_FIELD_CATEGORY, tagTypeToOperators["string"], []bool{true, true, true}, "", "", "", "", false, notSupportOperator, table,
ckcommon.NATIVE_FIELD_CATEGORY_CUSTOM_TAG, tagTypeToOperators["string"], []bool{true, true, true}, "", "", "", "", false, notSupportOperator, table,
})
}
}
Expand Down

0 comments on commit 727d9f1

Please sign in to comment.