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

当然,这里只是简单举例,实际应用中可以根据自己的业务做更为复杂的逻辑处理。
边栏推荐
- Introduction à l'objet blob
- 【无标题】
- Leetcode medium question my schedule I
- Understanding of out covariance, in inversion and invariance in kotlin
- Réplication de vulnérabilité - désrialisation fastjson
- WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
- [quick start of Digital IC Verification] 14. Basic syntax of SystemVerilog learning 1 (array, queue, structure, enumeration, string... Including practical exercises)
- CTF-WEB shrine模板注入nmap的基本使用
- Openjudge noi 2.1 1752: chicken and rabbit in the same cage
- 青龙面板--花花阅读
猜你喜欢

Fast parsing intranet penetration escorts the document encryption industry

JS复制图片到剪切板 读取剪切板

Excel import function of jeesite form page

Lua 编程学习笔记

Jmeter 的使用

在Rainbond中实现数据库结构自动化升级

【雅思口语】安娜口语学习记录 Part2
![[quick start of Digital IC Verification] 12. Introduction to SystemVerilog testbench (svtb)](/img/dc/a809f2ec5f9e85a02e68c88bdcdb5e.png)
[quick start of Digital IC Verification] 12. Introduction to SystemVerilog testbench (svtb)

轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷

快解析内网穿透为文档加密行业保驾护航
随机推荐
[quick start of Digital IC Verification] 11. Introduction to Verilog testbench (VTB)
The simple problem of leetcode is to judge whether the number count of a number is equal to the value of the number
buureservewp(2)
ZCMU--1396: 队列问题(2)
The zblog plug-in supports the plug-in pushed by Baidu Sogou 360
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
雅思考试自己的复习进度以及方法使用【日更版】
offer收割机:两个长字符串数字相加求和(经典面试算法题)
Detailed explanation of apply, also, let, run functions and principle analysis of internal source code in kotlin
Full text query classification
Niu Mei's mathematical problem --- combinatorial number
云原生存储解决方案Rook-Ceph与Rainbond结合的实践
Hisense TV starts the developer mode
Network learning (II) -- Introduction to socket
Offer harvester: add and sum two long string numbers (classic interview algorithm question)
饥荒云服管理脚本
电池、电机技术受到很大关注,反而电控技术却很少被提及?
Introduction à l'objet blob
JS cross browser parsing XML application
Don't stop chasing the wind and the moon. Spring mountain is at the end of Pingwu