Splunk Search

How to use a field other than _time in timecharts

mmpratt
Observer

I have an issue, and I found a posting here that I thought would fix me up, but there is something wrong and I am not sure what it is. I want to create a stacked barchart showing a date from a datestamp field we have, an error code and the number of devices that get that error code on that day. now if I run my current search just using the | timechart dc(field1), it works just fine, but uses the _time field. My datestamp field is a string, with the format of "2021-07-30". I tried using this code to assign the datestamp field to _ time:

| eval NewTime=strptime(datestamp,"%Y-%m-%d %H:%M:%S")
| eval _time=NewTime | timechart dc(field1) by field2

The search runs, but returns no values. Any suggestions would be helpful.

Labels (1)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If your datestamp field is "2021-07-30" you should only need "%Y-%m-%d" as the format string in your strptime function. If that doesn't work, try append midnight to the string strptime(datestamp." 00:00:00","%Y-%m-%d %H:%M:%S")

0 Karma

mmpratt
Observer

Thank you for that, I had tried that before and it gave me an error, tried it again and it worked, must've been a typo the first time (facepalm)

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In November, the Splunk Threat Research Team had one release of new security content via the Enterprise ...

Index This | Divide 100 by half. What do you get?

November 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Stay Connected: Your Guide to December Tech Talks, Office Hours, and Webinars!

❄️ Celebrate the season with our December lineup of Community Office Hours, Tech Talks, and Webinars! ...