Getting Data In

set up a new field for timestamp - not working

premraj_vs
Path Finder

I am running a search against JSON data, and I am able to get the field I am interested in. Now, I am trying to set that field as a timestamp for charts, but it is not working.

index=idx-index-name "fields.created"="*"
| eval _time=strptime("fields.created","%Y-%m-%dT%H:%M:%SZ")
| timechart span=1d count

Value of field - "fields.created" - 2019-01-09T10:51:34.000-0500

If I remove the second line and run the command, all the events are in index time ( today ), but the records are from the last 1 month.

Can someone help me find what i am missing?

0 Karma
1 Solution

chrisyounger
SplunkTrust
SplunkTrust

Hi @premraj_vs

Give this a try:

 index=idx-index-name "fields.created"="*"
 | eval _time=strptime('fields.created',"%Y-%m-%dT%H:%M:%SZ")
 | timechart span=1d count

Sometimes you need to use single quotes when referring to field names that have strange characters in them.

All the best

View solution in original post

chrisyounger
SplunkTrust
SplunkTrust

Hi @premraj_vs

Give this a try:

 index=idx-index-name "fields.created"="*"
 | eval _time=strptime('fields.created',"%Y-%m-%dT%H:%M:%SZ")
 | timechart span=1d count

Sometimes you need to use single quotes when referring to field names that have strange characters in them.

All the best

premraj_vs
Path Finder

It worked .. Thanks for the help

0 Karma

chrisyounger
SplunkTrust
SplunkTrust

OK Looks like your strptime format is wrong. Try this one instead: %Y-%m-%dT%H:%M:%S.%3Q%z

0 Karma

premraj_vs
Path Finder

yes i made this change

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...