Splunk Search
Highlighted

Timechart with sum at single value level

Path Finder

Splunkers!
Need your help...

I created a search piping the following fields (simplified)

time AppID Incidentduration

I have to group incidents duration by week, running a timechart, at AppID level:

| timechart span=1w values(AppID) as AppID, sum(incidentduration) as WeeklyInc_duration

Unfortunately, returned AppID field is a multivaluefield (whenever in the same week there are multiple AppID with an incident event) and in this case WeeklyIncduration is the sum of the duration for all those AppIDs.
I'd like to get as output the sum at AppID level.

Can you help me?

Tks!
CArmine

0 Karma
Highlighted

Re: Timechart with sum at single value level

Champion

Do you mean like:

| timechart span=1w sum(incident_duration) as Weekly_Inc_duration BY AppID
0 Karma
Highlighted

Re: Timechart with sum at single value level

Path Finder

This is an option,
but I'd like to get a tabular output, like

incident duration AppID WeeklyIncduration

in order to have the chance afterwards to append some further column and import this search as DataSet for further processing.

Tks!
Carmine

0 Karma
Highlighted

Re: Timechart with sum at single value level

Path Finder

Probably i found the solution
Timechart was the wrong way to create the dataset i was looking for.

I add within the search the calculation of fa field, dateweek_year, extracting Year+Week from _time
Than i simply run the stats command, in this way

| stats sum(incidentunavailability) as Unavailability by dateweekyear, CI

It seems to work 🙂

0 Karma
Highlighted

Re: Timechart with sum at single value level

SplunkTrust
SplunkTrust

hey

looking at your comments section you can try

| eval dateyearweek=strftime(_time,"%Y-%U") | stats  sum(incident_duration) as Weekly_Inc_duration BY AppID dateyearweek

Depending of your country, you have 2 variations :

%U is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number [00,53].

%V is replaced by the week number of the year (Monday as the first day of the week) as a decimal number [01,53]. If the week containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1.

Let me know if this helps!

View solution in original post