From 9e709091de6f4e805e1e2c15755d1c942557e449 Mon Sep 17 00:00:00 2001 From: Liu Chao Date: Fri, 27 Sep 2024 11:17:52 +0800 Subject: [PATCH] feat: querier delete live_view --- .../querier/engine/clickhouse/client/client.go | 2 +- server/querier/engine/clickhouse/filter.go | 16 ++++++++-------- server/querier/engine/clickhouse/group.go | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/querier/engine/clickhouse/client/client.go b/server/querier/engine/clickhouse/client/client.go index 51517a5c09c..0aa9f343865 100644 --- a/server/querier/engine/clickhouse/client/client.go +++ b/server/querier/engine/clickhouse/client/client.go @@ -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) } diff --git a/server/querier/engine/clickhouse/filter.go b/server/querier/engine/clickhouse/filter.go index 6f172abd908..0c959f4be6d 100644 --- a/server/querier/engine/clickhouse/filter.go +++ b/server/querier/engine/clickhouse/filter.go @@ -1178,9 +1178,9 @@ 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 } @@ -1188,9 +1188,9 @@ func GetPrometheusFilter(promTag, table, op, value string, e *CHEngine) (string, } 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 @@ -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, @@ -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) diff --git a/server/querier/engine/clickhouse/group.go b/server/querier/engine/clickhouse/group.go index 9cebb8120eb..1e852051035 100644 --- a/server/querier/engine/clickhouse/group.go +++ b/server/querier/engine/clickhouse/group.go @@ -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 }