diff --git a/server/controller/db/mysql/migration/rawsql/init.sql b/server/controller/db/mysql/migration/rawsql/init.sql index a0902574797..3db76951adb 100644 --- a/server/controller/db/mysql/migration/rawsql/init.sql +++ b/server/controller/db/mysql/migration/rawsql/init.sql @@ -1362,7 +1362,7 @@ set @lcuuid = (select uuid()); INSERT INTO alarm_policy(user_id, sub_view_type, tag_conditions, query_conditions, query_url, query_params, sub_view_metrics, name, level, state, app_type, sub_type, contrast_type, target_line_uid, target_line_name, target_field, threshold_warning, lcuuid) - values(1, 1, "过滤项: N/A | 分组项: tag.host", "", "/v1/stats/querier/UniversalHistory", "{\"DATABASE\":\"deepflow_system\",\"TABLE\":\"deepflow_agent_monitor\",\"interval\":60,\"fill\": \"none\",\"window_size\":5,\"QUERIES\":[{\"QUERY_ID\":\"R1\",\"SELECT\":\"Min(`metrics.cpu_percent`/`metrics.max_cpus`) AS `cpu_usage`\",\"WHERE\":\"1=1\",\"GROUP_BY\":\"`tag.host`\",\"METRICS\":[\"Min(`metrics.cpu_percent`/`metrics.max_cpus`) AS `cpu_usage`\"]}]}", + values(1, 1, "过滤项: N/A | 分组项: tag.host", "", "/v1/stats/querier/UniversalHistory", "{\"DATABASE\":\"deepflow_system\",\"TABLE\":\"deepflow_agent_monitor\",\"interval\":60,\"fill\": \"none\",\"window_size\":5,\"QUERIES\":[{\"QUERY_ID\":\"R1\",\"SELECT\":\"(Min(`metrics.cpu_percent`/`metrics.max_millicpus`)*1000) AS `cpu_usage`\",\"WHERE\":\"1=1\",\"GROUP_BY\":\"`tag.host`\",\"METRICS\":[\"(Min(`metrics.cpu_percent`/`metrics.max_millicpus`)*1000) AS `cpu_usage`\"]}]}", "[{\"METRIC_LABEL\":\"cpu_usage\",\"return_field_description\":\"持续 5 分钟 (CPU用量/阈值)\",\"unit\":\"%\"}]", "采集器 CPU 超限", 0, 1, 1, 21, 1, "", "", "{\"displayName\":\"cpu_usage\", \"unit\": \"%\"}", "{\"OP\":\">=\",\"VALUE\":70}", @lcuuid); set @lcuuid = (select uuid()); @@ -1449,6 +1449,13 @@ INSERT INTO alarm_policy(user_id, sub_view_type, tag_conditions, query_condition values(1, 1, "过滤项: N/A | 分组项: tag.cluster_id", "", "/v1/stats/querier/UniversalHistory", "{\"DATABASE\":\"deepflow_system\",\"TABLE\":\"deepflow_server_controller_genesis_k8sinfo_delay\",\"interval\":60,\"fill\": \"none\",\"window_size\":1,\"QUERIES\":[{\"QUERY_ID\":\"R1\",\"SELECT\":\"Last(`metrics.avg`) AS `delay`\",\"WHERE\":\"1=1\",\"GROUP_BY\":\"`tag.cluster_id`\",\"METRICS\":[\"Last(`metrics.avg`) AS `delay`\"]}]}", "[{\"METRIC_LABEL\":\"delay\",\"return_field_description\":\"资源同步滞后时间\",\"unit\":\" 秒\"}]", "K8s 资源同步滞后", 1, 1, 1, 23, 1, "", "", "{\"displayName\":\"delay\", \"unit\": \"秒\"}", "{\"OP\":\">=\",\"VALUE\":600}", @lcuuid); +set @lcuuid = (select uuid()); +INSERT INTO alarm_policy(user_id, sub_view_type, tag_conditions, query_conditions, query_url, query_params, sub_view_metrics, name, level, state, + app_type, sub_type, contrast_type, target_line_uid, target_line_name, target_field, + threshold_warning, lcuuid) + values(1, 1, "过滤项: N/A | 分组项: tag.db, tag.table", "", "/v1/stats/querier/UniversalHistory", "{\"DATABASE\":\"deepflow_system\",\"TABLE\":\"deepflow_server_ingester_force_delete_clickhouse_data\",\"interval\":60,\"fill\": \"none\",\"window_size\":5,\"QUERIES\":[{\"QUERY_ID\":\"R1\",\"SELECT\":\"Count(row) AS `force_delete_clickhouse_data_count`\",\"WHERE\":\"1=1\",\"GROUP_BY\":\"`tag.db`, `tag.table`\",\"METRICS\":[\"Count(row) AS `force_delete_clickhouse_data_count`\"]}]}", + "[{\"METRIC_LABEL\":\"force_delete_clickhouse_data_count\",\"return_field_description\":\"最近 1 分钟 数据库修改次数\",\"unit\":\"次\"}]", "数据节点数据强制删除", 0, 1, 1, 21, 1, "", "", "{\"displayName\":\"force_delete_clickhouse_data_count\", \"unit\": \"次\"}", "{\"OP\":\">=\",\"VALUE\":1}", @lcuuid); + set @lcuuid = (select uuid()); INSERT INTO alarm_policy(user_id, sub_view_type, tag_conditions, query_conditions, query_url, query_params, sub_view_metrics, name, level, state, app_type, sub_type, contrast_type, target_line_uid, target_line_name, target_field, @@ -1521,6 +1528,14 @@ INSERT INTO alarm_policy(user_id, sub_view_type, tag_conditions, query_condition "[{\"METRIC_LABEL\":\"drop_packets\",\"return_field_description\":\"最近 1 分钟 flow_map.metrics.drop_by_window\",\"unit\":\"\"}]", "采集器数据丢失 (flow_map.metrics.drop_by_window)", 0, 1, 1, 21, 1, "", "", "{\"displayName\":\"flow_map.metrics.drop_by_window\", \"unit\": \"\"}", "{\"OP\":\">=\",\"VALUE\":1}", @lcuuid); +set @lcuuid = (select uuid()); +INSERT INTO alarm_policy(user_id, sub_view_type, tag_conditions, query_conditions, query_url, query_params, sub_view_metrics, name, level, state, + app_type, sub_type, contrast_type, target_line_uid, target_line_name, target_field, + threshold_warning, lcuuid) + values(1, 1, "过滤项: N/A | 分组项: tag.host", "", "/v1/stats/querier/UniversalHistory", "{\"DATABASE\":\"deepflow_system\",\"TABLE\":\"deepflow_agent_flow_map\",\"interval\":60,\"fill\": \"none\",\"window_size\":1,\"QUERIES\":[{\"QUERY_ID\":\"R1\",\"SELECT\":\"Sum(`metrics.drop_by_capacity`) AS `flow_map.metrics.drop_by_capacity`\",\"WHERE\":\"1=1\",\"GROUP_BY\":\"`tag.host`\",\"METRICS\":[\"Sum(`metrics.drop_by_capacity`) AS `flow_map.metrics.drop_by_capacity`\"]}]}", + "[{\"METRIC_LABEL\":\"drop_packets\",\"return_field_description\":\"最近 1 分钟 flow_map.metrics.drop_by_capacity\",\"unit\":\"\"}]", + "采集器数据丢失 (flow_map.metrics.drop_by_capacity)", 0, 1, 1, 21, 1, "", "", "{\"displayName\":\"flow_map.metrics.drop_by_capacity\", \"unit\": \"\"}", "{\"OP\":\">=\",\"VALUE\":1}", @lcuuid); + set @lcuuid = (select uuid()); INSERT INTO alarm_policy(user_id, sub_view_type, tag_conditions, query_conditions, query_url, query_params, sub_view_metrics, name, level, state, app_type, sub_type, contrast_type, target_line_uid, target_line_name, target_field, diff --git a/server/controller/db/mysql/migration/rawsql/issu/6.5.1.30.sql b/server/controller/db/mysql/migration/rawsql/issu/6.5.1.30.sql new file mode 100644 index 00000000000..9a576ba554e --- /dev/null +++ b/server/controller/db/mysql/migration/rawsql/issu/6.5.1.30.sql @@ -0,0 +1,32 @@ +START TRANSACTION; + +-- modify start, add upgrade sql + +UPDATE alarm_policy SET query_params="{\"DATABASE\":\"deepflow_system\",\"TABLE\":\"deepflow_agent_monitor\",\"interval\":60,\"fill\": \"none\",\"window_size\":5,\"QUERIES\":[{\"QUERY_ID\":\"R1\",\"SELECT\":\"(Min(`metrics.cpu_percent`/`metrics.max_millicpus`)*1000) AS `cpu_usage`\",\"WHERE\":\"1=1\",\"GROUP_BY\":\"`tag.host`\",\"METRICS\":[\"(Min(`metrics.cpu_percent`/`metrics.max_millicpus`)*1000) AS `cpu_usage`\"]}]}" WHERE name="采集器 CPU 超限"; + +set @lcuuid = (select uuid()); +INSERT INTO alarm_policy(user_id, sub_view_type, tag_conditions, query_conditions, query_url, query_params, sub_view_metrics, name, level, state, + app_type, sub_type, contrast_type, target_line_uid, target_line_name, target_field, + threshold_warning, lcuuid) + SELECT 1, 1, "过滤项: N/A | 分组项: tag.host", "", "/v1/stats/querier/UniversalHistory", "{\"DATABASE\":\"deepflow_system\",\"TABLE\":\"deepflow_agent_flow_map\",\"interval\":60,\"fill\": \"none\",\"window_size\":1,\"QUERIES\":[{\"QUERY_ID\":\"R1\",\"SELECT\":\"Sum(`metrics.drop_by_capacity`) AS `flow_map.metrics.drop_by_capacity`\",\"WHERE\":\"1=1\",\"GROUP_BY\":\"`tag.host`\",\"METRICS\":[\"Sum(`metrics.drop_by_capacity`) AS `flow_map.metrics.drop_by_capacity`\"]}]}", + "[{\"METRIC_LABEL\":\"drop_packets\",\"return_field_description\":\"最近 1 分钟 flow_map.metrics.drop_by_capacity\",\"unit\":\"\"}]", + "采集器数据丢失 (flow_map.metrics.drop_by_capacity)", 0, 1, 1, 21, 1, "", "", "{\"displayName\":\"flow_map.metrics.drop_by_capacity\", \"unit\": \"\"}", "{\"OP\":\">=\",\"VALUE\":1}", @lcuuid + WHERE NOT EXISTS ( + SELECT * FROM alarm_policy WHERE name="采集器数据丢失 (flow_map.metrics.drop_by_capacity)" +); + +set @lcuuid = (select uuid()); +INSERT INTO alarm_policy(user_id, sub_view_type, tag_conditions, query_conditions, query_url, query_params, sub_view_metrics, name, level, state, + app_type, sub_type, contrast_type, target_line_uid, target_line_name, target_field, + threshold_warning, lcuuid) + SELECT 1, 1, "过滤项: N/A | 分组项: tag.db, tag.table", "", "/v1/stats/querier/UniversalHistory", "{\"DATABASE\":\"deepflow_system\",\"TABLE\":\"deepflow_server_ingester_force_delete_clickhouse_data\",\"interval\":60,\"fill\": \"none\",\"window_size\":5,\"QUERIES\":[{\"QUERY_ID\":\"R1\",\"SELECT\":\"Count(row) AS `force_delete_clickhouse_data_count`\",\"WHERE\":\"1=1\",\"GROUP_BY\":\"`tag.db`, `tag.table`\",\"METRICS\":[\"Count(row) AS `force_delete_clickhouse_data_count`\"]}]}", + "[{\"METRIC_LABEL\":\"force_delete_clickhouse_data_count\",\"return_field_description\":\"最近 1 分钟 数据库修改次数\",\"unit\":\"次\"}]", "数据节点数据强制删除", 0, 1, 1, 21, 1, "", "", "{\"displayName\":\"force_delete_clickhouse_data_count\", \"unit\": \"次\"}", "{\"OP\":\">=\",\"VALUE\":1}", @lcuuid +WHERE NOT EXISTS ( + SELECT * FROM alarm_policy WHERE name="数据节点数据强制删除" +); + +-- update db_version to latest, remeber update DB_VERSION_EXPECT in migrate/init.go +UPDATE db_version SET version='6.5.1.30'; +-- modify end + +COMMIT; diff --git a/server/controller/db/mysql/migration/version.go b/server/controller/db/mysql/migration/version.go index dae2b4ebc23..090cf13c62b 100644 --- a/server/controller/db/mysql/migration/version.go +++ b/server/controller/db/mysql/migration/version.go @@ -18,5 +18,5 @@ package migration const ( DB_VERSION_TABLE = "db_version" - DB_VERSION_EXPECTED = "6.5.1.29" + DB_VERSION_EXPECTED = "6.5.1.30" )