如何解决所需帮助如何在 splunk 查询中的文件名中添加具有相同字符串日期的特定源文件
我有一个要求,即我们每天都获取文件中提到的相应日期的文件:
例如文件名是:
test_dev_08_07_2021.json
test_dev_09_07_2021.json
test_prod_08_07_2021.json
test_prod_09_07_2021.json
现在我们这里的要求是添加具有相同日期的文件内容。我们使用的 splunk 查询如下:
eventtype="metric:sample:example" source="test_dev_.json" OR source="test_prod_.json" | stats sum(number_of_car) as "# Total_Car ",sum(Parked_cars) as "# Stopped_Cars",sum(Buses) as "# Total_Bus",sum(Parked_buses) as "# Stopped_Buses " by source | addcoltotals
但是它得到了所有四个文件的组合结果:
source # Total Car # Stopped Cars # Total Bus # Stopped Buses
test_dev_08_07_2021.json 23 21 295 124
test_dev_09_07_2021.json 22 22 297 123
test_prod_08_07_2021.json 2 3 429 66
test_prod_09_07_2021.json 2 3 427 66
49 49 1448 379
应该添加我们试图实现的仅具有相同日期的文件内容。例如,如果在 test_dev 和 test_prod 中提到了日期 08_07_2021,那么应该只添加这两个文件内容,并且它应该显示日期为 09_07_2021 的文件的结果和相同的结果。加法后我们应该得到单独的结果。
请注意:我们每天都会收到这些文件。因此每个文件中的日期和月份范围会有所不同,我们现在无法更改文件名
我们有什么办法可以完成这项任务,或者如果有人可以帮助我们进行相应的 splunk 查询,将会大有帮助。
请帮忙。
解决方法
诀窍是提取日期并将其用作分组字段。
const makeReportLink = (reportPath,reportParams = {},zoom = 100) => {
const reportViewerUrl = 'http://report-server-host/ReportServer_SSRS/Pages/ReportViewer.aspx';
const reportParamDefaults = {
'rs:Command': 'Render','rc:Parameters' : 'false','rc:Zoom': zoom,};
let reportSP = new URLSearchParams({...reportParamDefaults,...reportParams});
return `${reportViewerUrl}?${reportPath}&${reportSP.toString()}`;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。