Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 清洗字段校验逻辑调整和增加别名功能 #4514

Open
wants to merge 63 commits into
base: beta-20241217
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
ef1a44a
feat: 功能拉取
jidanjuan Dec 5, 2024
bdc4890
feat: 功能拉取
jidanjuan Dec 5, 2024
71e6819
feat: 字段分析调整& echarts升级
jidanjuan Dec 6, 2024
4714a61
feat: 别名切换功能&对接别名的接口
jidanjuan Dec 9, 2024
57b882e
feat: 字段分析列表下载完成
jidanjuan Dec 10, 2024
abf500c
feat: ext字段做特殊的展示 30%
jidanjuan Dec 10, 2024
a0cd4f0
feat: ext字段展开切换功能
jidanjuan Dec 12, 2024
c0c6f8e
feat: ext字段展开切换功能
jidanjuan Dec 12, 2024
3c799fa
feat: 字段配置中,ext字段做树状结构展示;
jidanjuan Dec 12, 2024
15658b1
feat: 清洗字段校验逻辑调整和增加别名功能
jidanjuan Dec 13, 2024
e215258
feat: 字段列表支持object 格式字段的层级展示
jidanjuan Dec 16, 2024
427fe5d
feat: 字段列表支持object 格式字段的层级展示
jidanjuan Dec 16, 2024
ed2612b
feat: 字段列表支持object 格式字段的层级展示
jidanjuan Dec 16, 2024
cd3c514
feat: 字段列表支持object 格式字段的层级展示
jidanjuan Dec 17, 2024
2d82035
feat: 字段列表支持object 格式字段的层级展示
jidanjuan Dec 17, 2024
c3e2a1f
feat: Metadata: 空间路由支持自定义业务ID过滤规则别名 --story=121229408 (#4414)
EASYGOING45 Dec 17, 2024
b869fab
feat: 删除多余打印
jidanjuan Dec 17, 2024
a9ab640
feat: 优化聚类接入异常事件上报内容 --story=121247293 (#4428)
jayjiahua Dec 17, 2024
cdf3040
fix: 修复边聚类结果不能按照service聚合的问题 --bug=135388189 (#4430)
dengyh Dec 17, 2024
014cb16
feat: 完善及联调首页复制查询功能逻辑 (#4370)
chenmanting1 Dec 17, 2024
6608a49
fix: 告警通知查询链接关联指标错误问题
unique0lai Dec 17, 2024
996fe69
fix: 告警详情预览维度缺省时,视图数据查询无数据修复
chenguo367 Dec 17, 2024
1d9a012
chore: ujson升级适配
unique0lai Dec 17, 2024
d27b6c7
chore: 调整json patches logger
unique0lai Dec 17, 2024
63be5eb
chore: 调整json patches logger
unique0lai Dec 17, 2024
0f0bcdf
feat: 支持 RPC 默认告警配置导入 --story=120756266 (#4394)
ZhuoZhuoCrayon Dec 17, 2024
d9591d6
fix: 修复自定义指标页面监控项拉取 (#4432)
pegasusljn Dec 17, 2024
5851852
fix: 修复 profiling 数据针对 inline 函数调用堆栈不正确问题 (#4442)
liuwenping Dec 17, 2024
47d7f39
fix: UI查询转化为es的QueryString-问题修复 --bug=135676537 (#4441)
wencong1724427771 Dec 17, 2024
d2b3d54
chore: trace打点json解析报错问题
unique0lai Dec 17, 2024
a1a1463
chore: json适配set类型
unique0lai Dec 17, 2024
b96d00f
fix: 修复部署k8s为字节的问题 --bug=135694225 (#4447)
rxwycdh Dec 17, 2024
aa9202c
feat: dnspython版本升级到2.3.0 --story=121242270 (#4422)
unique0lai Dec 17, 2024
dcba2b4
fix: 修复 profiling 数据在 graph 展示下数据计算异常问题 (#4448)
liuwenping Dec 17, 2024
f492470
feat: typing-extensions升级&betterproto去除特殊安装流程 --story=121234025 (#4412)
unique0lai Dec 17, 2024
447f6aa
chore: json patch适配bytes
unique0lai Dec 17, 2024
0fe4e8b
fix: 修复 profiling 数据查询异常,在堆栈有收尾重叠的场景下 (#4449)
liuwenping Dec 17, 2024
1cfd03f
chore: 调整json patches
unique0lai Dec 17, 2024
42a385c
Revert "Revert "feat: celery版本升级到5.1.2 --story=121220239 (#4410)""
unique0lai Dec 17, 2024
210351b
chore: redbeat升级适配
unique0lai Dec 17, 2024
96dac3f
Revert "Revert "Revert "feat: celery版本升级到5.1.2 --story=121220239 (#44…
unique0lai Dec 17, 2024
1f02942
fix: 修复 profiling 数据在 graph 展示下曲线重复问题 (#4451)
liuwenping Dec 17, 2024
ee8f378
perf: 优化 profiling 计算 edge 时的性能 (#4452)
liuwenping Dec 17, 2024
5ee1402
fix: 修复 profiling 在 graph 模式下缺失 self 的数值 (#4453)
liuwenping Dec 17, 2024
e963d21
fix: 修改 profiling 数据重复节点导致堆栈过大问题 (#4454)
liuwenping Dec 17, 2024
a5e50ad
fix: 日志聚类默认增加error判断; log LIKE %ERROR% --bug=135712729 (#4458)
xintaoLi Dec 18, 2024
01ba115
feat: 【仪表盘】针对集群模块展示对应的主机数量 --story=121108398 (#4332)
tang202388 Dec 18, 2024
dc69de9
fix: Metadata: 避免StorageClusterRecord脏数据(ES采集项更新时,需仅在storage_cluster_…
EASYGOING45 Dec 18, 2024
e784719
feat: 【trace】瀑布图里已读样式优化 --story=120919468 (#4205)
yzygyin Dec 18, 2024
b1585fd
fix: profiling 检索左边的接口,参数里面也有时间参数 --bug=135246901 (#4426)
goodGai Dec 18, 2024
550466f
feat: 【产品功能】策略服务组件类型的指标监控目标不能选择动态分组 --story=121177640 (#4429)
goodGai Dec 18, 2024
5939e52
fix: po版本不应该有索引集配置、设置等,入口不仅是白色,聚类策略应该屏蔽; --bug=135721811 (#4464)
xintaoLi Dec 18, 2024
9315b89
fix: 修改 profiling 数据下 flamegraph 显示异常问题 (#4466)
liuwenping Dec 18, 2024
8c570cd
feat: 别名和object分割点
jidanjuan Dec 18, 2024
b380d1c
refactor: celery 升级到 5.1.2 (#4470)
unique0lai Dec 18, 2024
63644df
chore: 告警后台任务改为由app注册,进行任务执行数据统计上报
unique0lai Dec 18, 2024
a05ba0e
fix: bkdata数据源查询sql生成,对字段进行转义
chenguo367 Dec 18, 2024
a89daab
fix: bkdata数据源查询sql生成,对字段进行转义
chenguo367 Dec 18, 2024
6cdf371
feat: 别名提交逻辑修改
jidanjuan Dec 18, 2024
022cc0b
Merge branch master of https://github.com/TencentBlueKing/bk-monitor …
jidanjuan Dec 18, 2024
33429c2
Merge branch master of https://github.com/TencentBlueKing/bk-monitor …
jidanjuan Dec 18, 2024
cf0f1b3
feat: 字段清洗支持别名修改和object字段
jidanjuan Dec 20, 2024
b16c068
feat: 字段清洗支持别名修改和object字段
jidanjuan Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

from apps.log_esquery.constants import WILDCARD_PATTERN, WILDCARD_QUERY
from apps.log_esquery.exceptions import BaseSearchDslException
from apps.log_search.constants import FieldDataTypeEnum
from apps.log_search.constants import ES_RESERVED_CHARACTERS, FieldDataTypeEnum
from apps.log_search.handlers.search.mapping_handlers import MappingHandlers

type_wildcard = Dict[str, Dict[str, Any]] # pylint: disable=invalid-name
Expand Down Expand Up @@ -288,6 +288,18 @@ def generate_querystring(field_name, value_list, condition_type="OR"):
transform_result = transform_result if len(value_list) == 1 else f"({transform_result})"
return f"{field_name}: {transform_result}"

@staticmethod
def escape_special_characters(string: str, is_wildcard=False):
wildcard_list = ["*", "?"]
# 转义es的的保留字
for char in ES_RESERVED_CHARACTERS:
if is_wildcard and char in wildcard_list:
# 对于使用通配符的es查询, 不转义通配符
continue
# 使用字符串的 replace 方法进行替换
string = string.replace(char, f"\\{char}")
return string


class Is(BoolQueryOperation):
TARGET = "must"
Expand All @@ -297,9 +309,13 @@ def op(self, field):
self._set_target_value(EsQueryBuilder.build_match_phrase_query(field["field"], field["value"]))

def to_querystring(self):
value_list = []
for value in self._bool_dict["value"]:
value = value.replace('"', '\\"')
value_list.append(f"\"{value}\"")
return self.generate_querystring(
self._bool_dict["field"],
self._bool_dict["value"],
value_list,
)


Expand Down Expand Up @@ -334,9 +350,13 @@ def op(self, field):
self._set_target_value(EsQueryBuilder.build_match_phrase_query(field["field"], field["value"]))

def to_querystring(self):
value_list = []
for value in self._bool_dict["value"]:
value = value.replace('"', '\\"')
value_list.append(f"\"{value}\"")
return "NOT " + self.generate_querystring(
self._bool_dict["field"],
self._bool_dict["value"],
value_list,
)


Expand All @@ -351,9 +371,13 @@ def op(self, field):
self._set_target_value(a_bool)

def to_querystring(self):
value_list = []
for value in self._bool_dict["value"]:
value = value.replace('"', '\\"')
value_list.append(f"\"{value}\"")
return self.generate_querystring(
self._bool_dict["field"],
self._bool_dict["value"],
value_list,
)


Expand Down Expand Up @@ -485,9 +509,13 @@ def op(self, field):
self._set_target_value(a_bool)

def to_querystring(self):
value_list = []
for value in self._bool_dict["value"]:
value = self.escape_special_characters(value, is_wildcard=True)
value_list.append(value)
return self.generate_querystring(
self._bool_dict["field"],
self._bool_dict["value"],
value_list,
)


Expand All @@ -514,6 +542,7 @@ def op(self, field):
def to_querystring(self):
value_list = []
for value in self._bool_dict["value"]:
value = self.escape_special_characters(value)
value_list.append(f"*{value}*")
return self.generate_querystring(
self._bool_dict["field"],
Expand All @@ -526,9 +555,6 @@ class NotContains(Contains):
OPERATOR = "not contains"

def to_querystring(self):
value_list = []
for value in self._bool_dict["value"]:
value_list.append(f"*{value}*")
return "NOT " + super().to_querystring()


Expand Down Expand Up @@ -605,9 +631,13 @@ def op(self, field):
self._set_target_value(a_bool)

def to_querystring(self):
value_list = []
for value in self._bool_dict["value"]:
value = self.escape_special_characters(value, is_wildcard=True)
value_list.append(value)
return self.generate_querystring(
self._bool_dict["field"],
self._bool_dict["value"],
value_list,
condition_type="AND",
)

Expand Down
27 changes: 27 additions & 0 deletions bklog/apps/log_search/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,3 +1677,30 @@ class OperatorEnum:
"is true": "IS TRUE",
"is false": "IS FALSE",
}

# es保留字符
ES_RESERVED_CHARACTERS = [
"\\",
"+",
"-",
"=",
"&&",
"||",
">",
"<",
"!",
"(",
")",
"{",
"}",
"[",
"]",
"^",
"\"",
"~",
"*",
"?",
":",
"/",
" ",
]
37 changes: 18 additions & 19 deletions bklog/apps/tests/log_search/test_querystring.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
{"field": "number", "operator": "gte", "value": [100, 50]},
{"field": "id", "operator": "lte", "value": [500]},
{"field": "gseIndex", "operator": "=~", "value": ["?proz/Saved/Logs/ProjectA_2024.10.20-23.17.50*"]},
{"field": "path", "operator": "!=~", "value": ["?app/*/python.*", "*/python.*"]},
{"field": "cloudId", "operator": "contains", "value": ["6", "9"]},
{"field": "cloudId", "operator": "not contains", "value": ["1", "3"]},
{"field": "path", "operator": "!=~", "value": ["?app python.*", "*/python.*"]},
{"field": "cloudId", "operator": "contains", "value": ["6+6", "9+1=10"]},
{"field": "cloudId", "operator": "not contains", "value": ["1&&2", "3*3"]},
{"field": "is_deleted", "operator": "is false", "value": []},
{"field": "flag", "operator": "is true", "value": [1]},
{"field": "log", "operator": "contains match phrase", "value": ["html", "hello world"]},
{"field": "log", "operator": "not contains match phrase", "value": ["are you ok"]},
{"field": "log", "operator": "all contains match phrase", "value": ["su 7"]},
{"field": "log", "operator": "all not contains match phrase", "value": ["error", "500"]},
{"field": "log", "operator": "all not contains match phrase", "value": ["This is a \"test\" string"]},
{"field": "describe", "operator": "&=~", "value": ["?el*", "wor?d"]},
{"field": "theme", "operator": "&!=~", "value": ["pg*", "?h?"]},
{"field": "describe", "operator": "&=~", "value": ["?e:l*", "w(or)?d"]},
{"field": "theme", "operator": "&!=~", "value": ["pg||db*", r"?h\h?"]},
{"field": "*", "operator": "contains match phrase", "value": ["error"]},
{"field": "querystring", "operator": "contains match phrase", "value": ["success", "200"]},
{"field": "querystring", "operator": "=", "value": []},
Expand All @@ -40,21 +40,20 @@
],
}


TRANSFORM_RESULT = (
"bk_host_id: (1 OR 2)"
"bk_host_id: (\"1\" OR \"2\")"
" AND "
"bk_host_id: (3 OR 4)"
"bk_host_id: (\"3\" OR \"4\")"
" AND "
"bk_host_id: (5 OR 6)"
"bk_host_id: (\"5\" OR \"6\")"
" AND "
"NOT service: php"
"NOT service: \"php\""
" AND "
"NOT service: (a OR b)"
"NOT service: (\"a\" OR \"b\")"
" AND "
"service: (c OR d)"
"service: (\"c\" OR \"d\")"
" AND "
"NOT service: (e OR f)"
"NOT service: (\"e\" OR \"f\")"
" AND "
"count: <200"
" AND "
Expand All @@ -72,13 +71,13 @@
" AND "
"id: <=500"
" AND "
"gseIndex: ?proz/Saved/Logs/ProjectA_2024.10.20-23.17.50*"
r"gseIndex: ?proz\/Saved\/Logs\/ProjectA_2024.10.20\-23.17.50*"
" AND "
"NOT path: (?app/*/python.* OR */python.*)"
r"NOT path: (?app\ python.* OR *\/python.*)"
" AND "
"cloudId: (*6* OR *9*)"
r"cloudId: (*6\+6* OR *9\+1\=10*)"
" AND "
"NOT cloudId: (*1* OR *3*)"
r"NOT cloudId: (*1\&&2* OR *3\*3*)"
" AND "
"is_deleted: false"
" AND "
Expand All @@ -94,9 +93,9 @@
" AND "
"NOT log: \"This is a \\\"test\\\" string\""
" AND "
"describe: (?el* AND wor?d)"
r"describe: (?e\:l* AND w\(or\)?d)"
" AND "
"NOT theme: (pg* AND ?h?)"
r"NOT theme: (pg\||db* AND ?h\\h?)"
" AND "
"(\"error\")"
" AND "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,17 @@ export default class LogFilter extends tsc<object> {
return;
}
let isCanSubmit = true;
const container = this.$refs.filterTableRef as any;

for (const fIndex in this.filterData) {
const container = this.$refs[`filterTableRef-${fIndex}`] as any;
for (const iIndex in this.filterData[fIndex]) {
let matchNotError = true;

// 字符串类型过滤暂时无过滤参数(全文)
if (this.activeType === 'separator') {
matchNotError = await (container?.$refs[`match-${fIndex}-${iIndex}`] as Form)?.validate();
matchNotError = await (container?.$refs[`match-${fIndex}-${fIndex}-${iIndex}`] as Form)?.validate();
}
const valueNotError = await (container?.$refs[`value-${fIndex}-${iIndex}`] as Form)?.validate();

const valueNotError = await (container?.$refs[`value-${fIndex}-${fIndex}-${iIndex}`] as Form)?.validate();
if (isCanSubmit) isCanSubmit = matchNotError && valueNotError;
}
}
Expand Down Expand Up @@ -328,30 +327,36 @@ export default class LogFilter extends tsc<object> {
}

render() {
const fieldIndexInputSlot = {
default: ({ $index, row }) => (
<ValidatorInput
ref={`match-${row.tableIndex}-${$index}`}
v-model={row.fieldindex}
active-type={this.activeType}
input-type={'number'}
original-filter-item-select={this.originalFilterItemSelect}
placeholder={this.$t('请输入列数')}
row-data={row}
table-index={row.tableIndex}
/>
),
const fieldIndexInputSlot = groupid => {
return {
default: ({ $index, row }) => (
<ValidatorInput
ref={`match-${groupid}-${row.tableIndex}-${$index}`}
v-model={row.fieldindex}
active-type={this.activeType}
input-type={'number'}
original-filter-item-select={this.originalFilterItemSelect}
placeholder={this.$t('请输入列数')}
row-data={row}
table-index={row.tableIndex}
/>
),
};
};
const valueInputSlot = {
default: ({ $index, row }) => (
<ValidatorInput
ref={`value-${row.tableIndex}-${$index}`}
v-model={row.word}
active-type={this.activeType}
placeholder={['regex', 'nregex'].includes(row.op) ? this.$t('支持正则匹配,如18*123') : this.$t('请输入')}
row-data={row}
/>
),
const valueInputSlot = groupId => {
return {
default: ({ $index, row }) => (
<div>
<ValidatorInput
ref={`value-${groupId}-${row.tableIndex}-${$index}`}
v-model={row.word}
active-type={this.activeType}
placeholder={['regex', 'nregex'].includes(row.op) ? this.$t('支持正则匹配,如18*123') : this.$t('请输入')}
row-data={row}
/>
</div>
),
};
};
const selectSlot = {
default: ({ row }) => (
Expand Down Expand Up @@ -455,7 +460,7 @@ export default class LogFilter extends tsc<object> {
></i>
</div>
<bk-table
ref='filterTableRef'
ref={`filterTableRef-${index}`}
data={item}
col-border
dark-header
Expand All @@ -475,7 +480,7 @@ export default class LogFilter extends tsc<object> {
<bk-table-column
label='Value'
prop='word'
scopedSlots={valueInputSlot}
scopedSlots={valueInputSlot(index)}
/>
<bk-table-column
width='95'
Expand Down
Loading
Loading