Skip to content

Commit

Permalink
feat: querier delete live_view
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaochaoren1 committed Sep 27, 2024
1 parent 4409e4c commit 9e70909
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/querier/engine/clickhouse/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *Client) DoQuery(params *QueryParams) (result *common.Result, err error)
sqlstr, callbacks, query_uuid, columnSchemaMap, simpleSql := params.Sql, params.Callbacks, params.QueryUUID, params.ColumnSchemaMap, params.SimpleSql
queryCacheStr := ""
if params.UseQueryCache {
queryCacheStr = " SETTINGS use_query_cache = true, query_cache_store_results_of_queries_with_nondeterministic_functions = 1"
queryCacheStr = " SETTINGS use_query_cache = true, query_cache_nondeterministic_function_handling = 'save'"
if params.QueryCacheTTL != "" {
queryCacheStr += fmt.Sprintf(", query_cache_ttl = %s", params.QueryCacheTTL)
}
Expand Down
16 changes: 8 additions & 8 deletions server/querier/engine/clickhouse/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,19 +1178,19 @@ func GetPrometheusFilter(promTag, table, op, value string, e *CHEngine) (string,
return filter, nil
}
if strings.Contains(op, "match") {
filter = fmt.Sprintf("toUInt64(app_label_value_id_%d) GLOBAL IN (SELECT label_value_id FROM flow_tag.app_label_live_view WHERE label_name_id=%d and %s(label_value,%s))", appLabel.AppLabelColumnIndex, labelNameID, op, value)
filter = fmt.Sprintf("toUInt64(app_label_value_id_%d) GLOBAL IN (SELECT label_value_id FROM flow_tag.app_label_map WHERE label_name_id=%d and %s(label_value,%s))", appLabel.AppLabelColumnIndex, labelNameID, op, value)
} else {
filter = fmt.Sprintf("toUInt64(app_label_value_id_%d) GLOBAL IN (SELECT label_value_id FROM flow_tag.app_label_live_view WHERE label_name_id=%d and label_value %s %s)", appLabel.AppLabelColumnIndex, labelNameID, op, value)
filter = fmt.Sprintf("toUInt64(app_label_value_id_%d) GLOBAL IN (SELECT label_value_id FROM flow_tag.app_label_map WHERE label_name_id=%d and label_value %s %s)", appLabel.AppLabelColumnIndex, labelNameID, op, value)
}
break
}
}
}
if !isAppLabel {
if strings.Contains(op, "match") {
filter = fmt.Sprintf("toUInt64(target_id) GLOBAL IN (SELECT target_id FROM flow_tag.target_label_live_view WHERE metric_id=%d and label_name_id=%d and %s(label_value,%s))", metricID, labelNameID, op, value)
filter = fmt.Sprintf("toUInt64(target_id) GLOBAL IN (SELECT target_id FROM flow_tag.target_label_map WHERE metric_id=%d and label_name_id=%d and %s(label_value,%s))", metricID, labelNameID, op, value)
} else {
filter = fmt.Sprintf("toUInt64(target_id) GLOBAL IN (SELECT target_id FROM flow_tag.target_label_live_view WHERE metric_id=%d and label_name_id=%d and label_value %s %s)", metricID, labelNameID, op, value)
filter = fmt.Sprintf("toUInt64(target_id) GLOBAL IN (SELECT target_id FROM flow_tag.target_label_map WHERE metric_id=%d and label_name_id=%d and label_value %s %s)", metricID, labelNameID, op, value)
}
}
return filter, nil
Expand Down Expand Up @@ -1242,9 +1242,9 @@ func GetRemoteReadFilter(promTag, table, op, value, originFilter string, e *CHEn

// lru timeout
if strings.Contains(op, "match") {
sql = fmt.Sprintf("SELECT label_value_id FROM flow_tag.app_label_live_view WHERE label_name_id=%d and %s(label_value,%s) GROUP BY label_value_id", labelNameID, op, value)
sql = fmt.Sprintf("SELECT label_value_id FROM flow_tag.app_label_map WHERE label_name_id=%d and %s(label_value,%s) GROUP BY label_value_id", labelNameID, op, value)
} else {
sql = fmt.Sprintf("SELECT label_value_id FROM flow_tag.app_label_live_view WHERE label_name_id=%d and label_value %s %s GROUP BY label_value_id", labelNameID, op, value)
sql = fmt.Sprintf("SELECT label_value_id FROM flow_tag.app_label_map WHERE label_name_id=%d and label_value %s %s GROUP BY label_value_id", labelNameID, op, value)
}
chClient := client.Client{
Host: config.Cfg.Clickhouse.Host,
Expand Down Expand Up @@ -1279,9 +1279,9 @@ func GetRemoteReadFilter(promTag, table, op, value, originFilter string, e *CHEn
if !isAppLabel {
transFilter := ""
if strings.Contains(op, "match") {
transFilter = fmt.Sprintf("SELECT target_id FROM flow_tag.target_label_live_view WHERE metric_id=%d and label_name_id=%d and %s(label_value,%s) GROUP BY target_id", metricID, labelNameID, op, value)
transFilter = fmt.Sprintf("SELECT target_id FROM flow_tag.target_label_map WHERE metric_id=%d and label_name_id=%d and %s(label_value,%s) GROUP BY target_id", metricID, labelNameID, op, value)
} else {
transFilter = fmt.Sprintf("SELECT target_id FROM flow_tag.target_label_live_view WHERE metric_id=%d and label_name_id=%d and label_value %s %s GROUP BY target_id", metricID, labelNameID, op, value)
transFilter = fmt.Sprintf("SELECT target_id FROM flow_tag.target_label_map WHERE metric_id=%d and label_name_id=%d and label_value %s %s GROUP BY target_id", metricID, labelNameID, op, value)
}
targetLabelFilter := TargetLabelFilter{OriginFilter: originFilter, TransFilter: transFilter}
e.TargetLabelFilters = append(e.TargetLabelFilters, targetLabelFilter)
Expand Down
4 changes: 2 additions & 2 deletions server/querier/engine/clickhouse/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ func GetPrometheusNotNullFilter(name string, e *CHEngine) (view.Node, bool) {
for _, appLabel := range appLabels {
if appLabel.AppLabelName == nameNoPreffix {
isAppLabel = true
filter = fmt.Sprintf("toUInt64(app_label_value_id_%d) GLOBAL IN (SELECT label_value_id FROM flow_tag.app_label_live_view WHERE label_name_id=%d)", appLabel.AppLabelColumnIndex, labelNameID)
filter = fmt.Sprintf("toUInt64(app_label_value_id_%d) GLOBAL IN (SELECT label_value_id FROM flow_tag.app_label_map WHERE label_name_id=%d)", appLabel.AppLabelColumnIndex, labelNameID)
break
}
}
}
if !isAppLabel {
filter = fmt.Sprintf("toUInt64(target_id) GLOBAL IN (SELECT target_id FROM flow_tag.target_label_live_view WHERE metric_id=%d and label_name_id=%d)", metricID, labelNameID)
filter = fmt.Sprintf("toUInt64(target_id) GLOBAL IN (SELECT target_id FROM flow_tag.target_label_map WHERE metric_id=%d and label_name_id=%d)", metricID, labelNameID)
}
return &view.Expr{Value: "(" + filter + ")"}, true
}
Expand Down

0 comments on commit 9e70909

Please sign in to comment.