当前位置:网站首页>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的结果:
当然,这里只是简单举例,实际应用中可以根据自己的业务做更为复杂的逻辑处理。
边栏推荐
- Find the mode in the binary search tree (use medium order traversal as an ordered array)
- 提高企业产品交付效率系列(1)—— 企业应用一键安装和升级
- Function extension, attribute extension and non empty type extension in kotlin
- The largest 3 same digits in the string of leetcode simple question
- Myabtis_ Plus
- ZCMU--1492: Problem D(C语言)
- 贝叶斯定律
- Domain specific language / DSL in kotlin
- It took "7" years to build the robot framework into a micro service
- 青龙面板--整理能用脚本
猜你喜欢
随机推荐
Uniapp mobile terminal forced update function
Dedecms collects content without writing rules
太真实了,原来自己一直没有富裕起来是有原因的
eBPF Cilium实战(1) - 基于团队的网络隔离
船载雷达天线滑环的使用
UnityHub破解&Unity破解
Summary of redis functions
Network learning (II) -- Introduction to socket
Quick analysis of Intranet penetration helps the foreign trade management industry cope with a variety of challenges
Recursive method to verify whether a tree is a binary search tree (BST)
ZCMU--1396: 队列问题(2)
藏书馆App基于Rainbond实现云原生DevOps的实践
Use of JMeter
Interactive book delivery - signed version of Oracle DBA work notes
Make LIVELINK's initial pose consistent with that of the mobile capture actor
Rainbond结合NeuVector实践容器安全管理
机器人教育在动手实践中的真理
积分商城管理系统中应包含的四大项
柯基数据通过Rainbond完成云原生改造,实现离线持续交付客户
It took "7" years to build the robot framework into a micro service