index=main action="purchase"
| lookup prices.csv productId as productId outputnew product_name,sale_price
| timechart span=1h sum(sale_price) as total_sale_price by VendorID
如果启用了 usenull=f ,他就不会显示这个null列。或者你想给Null列一个名字
index=main action="purchase"
| lookup prices.csv productId as productId outputnew product_name,sale_price
| timechart span=1h sum(sale_price) as total_sale_price by VendorID usenull=f
index=main action="purchase"
| lookup prices.csv productId as productId outputnew product_name,sale_price
| timechart span=1h sum(sale_price) as total_sale_price by VendorID nullstr="No Product Available"
where 分句一般用来过滤事件
index=main action="purchase"
| lookup prices.csv productId as productId outputnew product_name,sale_price
| timechart span=1h sum(sale_price) as total_sale_price by product_name where sum in top2
index=main action="purchase"
| lookup prices.csv productId as productId outputnew product_name,sale_price
| timechart span=1h sum(sale_price) as total_sale_price by product_name where sum in bottom2
timechart中一些时间段没有数据,如果不需要,则使用cont=f参数
fixedrange=f 只会有数据的字段显示出来
假如有两个统计的项
index=main
| lookup prices.csv productId as productId outputnew product_name,sale_price
| timechart span=1h sum(sale_price) as total_sale_price , max(price) as max_price by product_name
上面的字段通过冒号:来分隔。可以修改为. 点,或者format
index=main
| lookup prices.csv productId as productId outputnew product_name,sale_price
| timechart sep="." span=1h sum(sale_price) as total_sale_price , max(price) as max_price by product_name
index=main
| lookup prices.csv productId as productId outputnew product_name,sale_price
| timechart format=$AGG$_$VAL$ span=1h sum(sale_price) as total_sale_price , max(price) as max_price by product_name
timechart从https://docs.splunk.com/Documentation/Splunk/8.1.2/SearchTutorial/Systemrequirements这里下载Prices.csv.zip和tutorialdata.zip ,然后索引进main索引就可以了。而prices.csv解压后创建一个prices.csv的lookup表搜索购买purchase的事件,然后通过查找表去获取关联的字段。index=main action="purchase" | loo