Splunk Search
Highlighted

Display time in chart/table?

Path Finder

I'm trying to have a table that displays

Time | Country | City | Very Short |Short | Long

right now I've managed to get it to show everything I need, except the time.

My query is

| stats earliest(_time) as first_login latest(_time) as last_login by IP_address User   
| eval term=last_login-first_login   
| eval term=case(term<86400, "Very Short", term>86400 AND term<(86400*7), "Short", term>(86400*7), "Long") 
| chart dc(User) as usercount by IP_address,term
| iplocation IP_address  
| dedup City
| where (isnotnull(Country) AND isnotnull(City) AND NOT Country="United States" AND trim(Country)!="" AND trim(City)!="")
| table Country City "Very Short" Short Long

I tried using eval to do a first_login=strftime(first_login,"F%") and then aggregate it with stats first() but that made it so the term columns didn't display (VS/S/L).

Any ideas? I've googled for hours and can't seem to come up with much.

0 Karma
Highlighted

Re: Display time in chart/table?

Legend

Which time are you looking for. There's a time, firstlogin & last_login.

0 Karma
Highlighted

Re: Display time in chart/table?

Path Finder

to be honest i'm not 100% sure. I think the firstlogin but i tried putting _time as a column in the chart also firstlogin and didn't get any results.

0 Karma
Highlighted

Re: Display time in chart/table?

Legend

Try this

| stats earliest(_time) as first_login latest(_time) as last_login by IP_address User | eval term=last_login-first_login | eval term=case(term<86400, "Very Short", term>86400 AND term<(86400*7), "Short", term>(86400*7), "Long")  | eval ti=first_login."#".IP_address | chart dc(User) as usercount by ti ,term | rex field=ti "(?<FirstLogin>[^#]+)#(?<IP_address>.*)" | iplocation IP_address | dedup City | where (isnotnull(Country) AND isnotnull(City) AND NOT Country="United States" AND trim(Country)!="" AND trim(City)!="") | table Country City "Very Short" Short Long
Highlighted

Re: Display time in chart/table?

Path Finder

is there another field i should be adding to the table? because its just giving me the same results as the query I started with.

0 Karma
Highlighted

Re: Display time in chart/table?

Legend

🙂 Yes, you should add FirstLogin

0 Karma
Highlighted

Re: Display time in chart/table?

Path Finder

Thanks it's showing up now. I don't totally understand what format its displayed in... for example it says 1467082744.850 for the time. Is there a way i can convert that to M/D/Y?

0 Karma
Highlighted

Re: Display time in chart/table?

Legend

... | eval FirstLogin=strftime(FirstLogin, "%m/%d/%Y")

0 Karma
Highlighted

Re: Display time in chart/table?

Esteemed Legend

Like this:

... | stats earliest(_time) as first_login latest(_time) as last_login by IP_address User   
| eval term=last_login-first_login   
| eval term=case(term<86400, "Very Short", term>86400 AND term<(86400*7), "Short", term>(86400*7), "Long") 
| eval chartByComboField = IP_address . ":::" . first_login
| chart dc(User) as usercount BY chartByComboField term
| rex field=chartByComboField "(?<IP_address>.*):::(?<Time>.*)" | fields - chartByComboField 
| iplocation IP_address  
| dedup City
| where (isnotnull(Country) AND isnotnull(City) AND NOT Country="United States" AND trim(Country)!="" AND trim(City)!="")
| table Time Country City "Very Short" Short Long

View solution in original post

0 Karma
Highlighted

Re: Display time in chart/table?

Path Finder

Thanks it's showing up now. I don't totally understand what format its displayed in... for example it says 1467082744.850 for the time. Is there a way i can convert that to M/D/Y?

0 Karma