Splunk Search

How to add a column with date field in a chart

sfmandmdev
Path Finder

I have this query-

index=myIndex logRecordTypeX=1 
(logName="abc" OR logName="def" OR logName="ghi" OR logName="jkl" OR logName="mno") 
starttime="08/31/2010:00:00:00.000" endtime="08/31/2010:23:59:59.999" | fields logName, organizationId | eval logName=lower(logName) | chart count as pageViews over organizationId by logName limit=50 | addtotals fieldname=totalPageviews | sort –totalPageviews

I want to add another columns to my search results called Date ( it will display the same value in all rows- ie 8/31/2010). How can I do that?

Tags (1)
0 Karma

sfmandmdev
Path Finder

I finally used this as a workaround(ie appending date to one of the column values)

index=myIndex logRecordTypeX=1 (logName="abc" OR logName="def" OR logName="ghi" OR logName="jkl" OR logName="mno") starttime="08/31/2010:00:00:00.000" endtime="08/31/2010:23:59:59.999" | fields logName, organizationId,_time | eval Time=strftime(_time,"%m/%d") | eval NewOid = organizationId+" "+Time | chart count as pageViews over NewOid by logName limit=50

0 Karma

Stephen_Sorkin
Splunk Employee
Splunk Employee

If you want to hardcode the date here, you can just add | eval Date = "8/31/2010" but I suppose you want to be more clever and have it be based on the search itself.

In that case you should add:

... | addinfo | eval Date = strftime(info_min_time, "%m/%d/%Y") | fields - info_*
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...