4.4 字段规范化
4.4 字段规范化
为什么要规范化
字段标准化是可检索性与可视化的关键。如果每个团队使用不同字段名,会导致搜索与仪表盘不可复用。
常见规范
-
IP:
client_ip -
方法:
http_method -
路径:
request_path -
状态码:
http_status -
耗时:
request_time -
服务名:
service -
环境:
env
建议策略
-
建立 字段字典(Field Dictionary)
-
在 Pipelines 中统一命名
-
对关键字段设置类型(long/double/string)
示例规则
rule "normalize_http"
when
has_field("method")
then
set_field("http_method", to_string($message.method));
set_field("request_path", to_string($message.path));
end
小结
字段规范化是长期收益最高的工作。下一章进入搜索语法。
下一节:5.1 查询语法