Splunk - 如何在一段时间内获得一天的累积值?

时间:2018-03-31 12:05:19

标签: splunk accumulate

我使用Splunk监控的其中一项是用电,其中一个索引的字段是当天的累计Kw值,如何获得给定时间跨度的当天最后一个值?因此,输出一个月每天的总Kw - 我尝试使用

host=Electricity earliest=-4w@w1 latest=+w@w1 | timechart last(live_day_kw) as Kw

但是对于我所拥有的数据,它似乎每天都在增加,因此它日复一日而不是每日价值,所以例如day1是7kw而day2是14kw而day3是21kw - 我期待它每天~7kw。也只是检查并且live_day_kw值在午夜重置为零

2 个答案:

答案 0 :(得分:0)

不太确定你在寻找什么,但也许这会有所帮助。

const left = [
    query(':enter, :leave', style({ position: 'fixed', width: '100%' }), { optional: true }),
    group([
        query(':enter', [style({ transform: 'translateX(-100%)' }), animate('.3s ease-out', style({ transform: 'translateX(0%)' }))], {
            optional: true,
        }),
        query(':leave', [style({ transform: 'translateX(0%)' }), animate('.3s ease-out', style({ transform: 'translateX(100%)' }))], {
            optional: true,
        }),
    ]),
];

const right = [
    query(':enter, :leave', style({ position: 'fixed', width: '100%' }), { optional: true }),
    group([
        query(':enter', [style({ transform: 'translateX(100%)' }), animate('.3s ease-out', style({ transform: 'translateX(0%)' }))], {
            optional: true,
        }),
        query(':leave', [style({ transform: 'translateX(0%)' }), animate('.3s ease-out', style({ transform: 'translateX(-100%)' }))], {
            optional: true,
        }),
    ]),
];

答案 1 :(得分:0)

为了那些寻求相同解决方案的人的利益,我设法解决了这个问题:

host=Electricity earliest=-4w@w1 | timechart latest(live_day_kw) as "Kw_Day" | eval Kw_Day = round(Kw_Day,2)

还需要将搜索设置为“月初至今”,它正是我所需要的。