当前位置:网站首页>Splunk查询csv lookup table数据动态查询
Splunk查询csv lookup table数据动态查询
2022-07-07 05:19:00 【QYHuiiQ】
在实际应用中,我们可能会遇到有些数据信息需要动态管理,并在spl中根据这些信息动态执行查询。也就是说我们以往我们可能会把查询条件直接放在| search后面执行,先在我们想把这个条件定义在lookup中,然后将lookup中的这个条件追加在| search后面。当然,这个实现你可以用在| search后面,也可网易用在各种splunk的命令行后面,只不过这里为了方便理清功能,就以| search为例。
以下面的案例为例:
在学校举行的各次考试中,可能有些时候考试难度较大,有些时候难度较小,那么我们在判定学生每次考试成绩的等级时就需要根据开始难度来评定,而不是单纯地以60作为每次考试的及格线,所以这个动态评定的等级我们就可以放在一个lookup table中,每次考试之后可以修改这个lookup table中的条件来实现对学生成绩的评定。
- 创建lookup table
| makeresults
| eval level_condition="grade>80",subject="Math"
| fields - _time
| outputlookup level.csv- 测试数据
| makeresults
| eval name="Sam",grade="85",subject="Math"
| table name,grade,subject
- 通过looukp table中的条件作为过滤条件
| makeresults
| eval name="Sam",grade="85",subject="Math"
| search
[| inputlookup level.csv
| eval standard=level_condition." AND subject=".subject
| return $standard]
| fields - _time可以看到过滤条件生效了:


所以大体上来说,要想使用动态获取lookup table中的数据直接引用到spl中,就需要对lookup中的数据进行加工处理成可以直接被引用的spl语法,然后使用return $fieldname的方式放在splunk命令行后面。
可以看一下拼接lookup table的结果:

当然,这里只是简单举例,实际应用中可以根据自己的业务做更为复杂的逻辑处理。
边栏推荐
- 运放电路的反馈电阻上并联一个电容是什么作用
- buureservewp(2)
- Leetcode simple question: find the K beauty value of a number
- Zcmu--1396: queue problem (2)
- Introduction à l'objet blob
- Complex network modeling (III)
- CDC (change data capture technology), a powerful tool for real-time database synchronization
- LeetCode简单题之判断一个数的数字计数是否等于数位的值
- 云原生存储解决方案Rook-Ceph与Rainbond结合的实践
- 复杂网络建模(二)
猜你喜欢

Qinglong panel - today's headlines

机器人教育在动手实践中的真理

【踩坑系列】uniapp之h5 跨域的问题

The zblog plug-in supports the plug-in pushed by Baidu Sogou 360

CCTV is so warm-hearted that it teaches you to write HR's favorite resume hand in hand
![[quick start of Digital IC Verification] 13. SystemVerilog interface and program learning](/img/d8/ffc1b7527f0269cecb2946ab402a2e.png)
[quick start of Digital IC Verification] 13. SystemVerilog interface and program learning

让Livelink初始Pose与动捕演员一致
![[quick start of Digital IC Verification] 14. Basic syntax of SystemVerilog learning 1 (array, queue, structure, enumeration, string... Including practical exercises)](/img/60/011b3ccdffa978d691436449a99e10.png)
[quick start of Digital IC Verification] 14. Basic syntax of SystemVerilog learning 1 (array, queue, structure, enumeration, string... Including practical exercises)

Myabtis_Plus

Make LIVELINK's initial pose consistent with that of the mobile capture actor
随机推荐
Application of slip ring of shipborne radar antenna
Use of any superclass and generic extension function in kotlin
【踩坑系列】uniapp之h5 跨域的问题
Register of assembly language by Wang Shuang
The element with setfieldsvalue set is obtained as undefined with GetFieldValue
Interactive book delivery - signed version of Oracle DBA work notes
DNS server configuration
It's too true. There's a reason why I haven't been rich
贝叶斯定律
发挥创客教育空间的广泛实用性
eBPF Cilium实战(2) - 底层网络可观测性
Lua 编程学习笔记
复杂网络建模(一)
追风赶月莫停留,平芜尽处是春山
利用 Helm 在各类 Kubernetes 中安装 Rainbond
CDC (change data capture technology), a powerful tool for real-time database synchronization
ZCMU--1396: 队列问题(2)
Recursive method constructs binary tree from middle order and post order traversal sequence
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
海信电视开启开发者模式