WORKSPACE / EXPLORE
日志探索
从一条查询开始,发现数据中的线索。
搜索结果
日志与趋势,尽在此处SPL 速查(点例子直接搜)
index=demo timeout消息里含 timeout 的日志(不区分大小写)index=demo "card declined"精确短语index=demo level=error service=payment字段等于(不区分大小写)index=demo http.status_code>=500数值比较index=demo service IN (payment, checkout) NOT level=infoIN 和 NOTindex=demo http.path=/api/*通配符index=demo earliest=-1h level=error最近 1 小时(和上面的时间范围取交集)index=demo level=error | stats count by service | sort -count按服务统计错误数index=demo | timechart count by service各服务请求量随时间变化index=demo | timechart span=1h avg(duration_ms) as avg_ms, perc95(duration_ms) as p95延迟趋势index=demo | chart count over service by level服务 × 级别交叉表index=demo level=error | top limit=5 error.type最常见的 5 种错误index=demo | stats dc(user.id) as users, count by region每个地区的用户数和请求数index=demo | eval slow=if(duration_ms>200, "slow", "fast") | stats count by sloweval 分类index=demo | where duration_ms>1000 | table _time, service, http.path, duration_mswhere + tableindex=demo | rex "user=(?<uid>\w+)" | stats count by uid | sort -count | head 5rex 提取字段index=demo level=error | dedup error.type | table _time, service, error.type, _raw每种错误看一条index=main sourcetype=csv | head 20看上传的 CSV
支持的命令:search、where、stats、eventstats、streamstats、tstats、timechart、chart、top、rare、sort、head、tail、table、fields、rename、dedup、eval、rex、regex、spath、extract、fillnull、bin、replace、makemv、mvexpand 等,逐个命令的状态见 SPL 命令覆盖清单。不支持的命令会直接报错,不会悄悄给出不同的结果。每次搜索下面都能展开看对应的 LogsQL。完整说明:SPL 使用说明
LogsQL 速查(点例子直接搜)
*全部日志timeout消息里含单词 timeout(区分大小写;不区分用i(TIMEOUT))"card declined"精确短语level:=ERROR字段等于某值service:in(payment, checkout)字段等于其中之一http.status_code:>=500数值比较(> >= < <=)service:=payment AND level:=ERROR与(空格也表示 AND)failed -service:=gateway排除(- 或 NOT)level:=ERROR | stats by (service) count() as n | sort by (n desc)按服务统计错误数* | stats by (_time:1h, service) count() as n按小时和服务统计level:=ERROR | top 5 by (error.type)最常见的 5 种错误
完整说明:LogsQL 速查表
输入查询并点击搜索,开始探索日志。
对应的 LogsQL(实际执行的查询)
租户(客户)
每个租户的数据单独存放,互相看不到开一个客户:在下面新建租户,同时设好它的管理员账号。把管理员的用户名、密码和 API Key 交给客户;之后客户自己登录、加员工、接日志。配额留空表示不限。
新建租户
我的仪表盘
关键指标,一目了然点「✦ 自动生成仪表盘」,助理会看你的数据自己做好面板;也可以在搜索页做出图表后点「加入仪表盘」。仪表盘目前保存在这台设备的浏览器里。
导入日志
预览、配置、上传
选择 CSV 文件(.csv / .tsv / .txt,也可以是 .gz 压缩包)
查找表(lookup)
上传 CSV 对照表,在 SPL 里用 lookup / inputlookup第一行是表头。同名上传会覆盖,只有和原表不同的行会写入(改了几行就只写几行)。用法:... | lookup 表名 匹配列 OUTPUT 输出列,查看:| inputlookup 表名;也可以用 ... | outputlookup 表名 把搜索结果存成查找表。
「谁能用」决定只能看部分 index 的用户能不能用这张表:新表默认只有管理员能用;同名上传不改原来的设置;outputlookup 存的表可能含任何 index 的数据,所以每次保存后都只有管理员能用,需要时再在列表里点「谁能用」放开。