当前位置:网站首页>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的结果:

当然,这里只是简单举例,实际应用中可以根据自己的业务做更为复杂的逻辑处理。
边栏推荐
- Use of out covariance and in inversion in kotlin
- Network learning (I) -- basic model learning
- Niu Mei's mathematical problem --- combinatorial number
- Game attack and defense world reverse
- Summary of redis functions
- It's too true. There's a reason why I haven't been rich
- Vulnerability recurrence easy_ tornado
- Qinglong panel - today's headlines
- Recursive method to construct binary tree from preorder and inorder traversal sequence
- 追风赶月莫停留,平芜尽处是春山
猜你喜欢

在 Rainbond 中一键安装高可用 Nacos 集群

Rainbond 5.6 版本发布,增加多种安装方式,优化拓扑图操作体验

复杂网络建模(一)

运放电路的反馈电阻上并联一个电容是什么作用

JS copy picture to clipboard read clipboard

发挥创客教育空间的广泛实用性

调用 pytorch API完成线性回归

Unityhub cracking & unity cracking

Network learning (III) -- highly concurrent socket programming (epoll)

Uniapp mobile terminal forced update function
随机推荐
Leetcode simple question: find the K beauty value of a number
JS cross browser parsing XML application
漏洞复现-easy_tornado
利用 Helm 在各类 Kubernetes 中安装 Rainbond
【Go ~ 0到1 】 第七天 获取时间戳,时间比较,时间格式转换,Sleep与定时器
让Livelink初始Pose与动捕演员一致
数据库实时同步利器——CDC(变化数据捕获技术)
Understanding of out covariance, in inversion and invariance in kotlin
追风赶月莫停留,平芜尽处是春山
Register of assembly language by Wang Shuang
快解析内网穿透助力外贸管理行业应对多种挑战
Dedecms collects content without writing rules
The zblog plug-in supports the plug-in pushed by Baidu Sogou 360
offer收割机:两个长字符串数字相加求和(经典面试算法题)
Hisense TV starts the developer mode
[quick start of Digital IC Verification] 11. Introduction to Verilog testbench (VTB)
Complex network modeling (III)
Fast parsing intranet penetration escorts the document encryption industry
Réplication de vulnérabilité - désrialisation fastjson
Use of JMeter