Splunk Search

Splunk data for a particular time span

aditya22
New Member

Hi ,

I am looking to get a data in the format from tomcat access logs for particular time span.

alt text

0 Karma

DalJeanis
Legend

You need to give us more about the problem.

First, what does the data look like now?

Second, what is meaningful about that format?

It looks like you are dividing time up into 3 minute increments.

It looks like you want two different sets of information for each increment.

Let's suppose you do this:

your search that calculates for each event, values for the _time, User and TicketType 
| table _time TicketType User
| bin _time span=3m

| rename COMMENT as "we count the total number of each thing in each 3m time period" 
| eventstats count as TypeCount by _time TicketType
| eventstats count as UserCount by _time User

| rename COMMENT as "we set the value of a display field based on the total number for that _time" 
| rename COMMENT as "if there were 5 count for a user, there will be 5 identical messages." 
| eval TicketLine=TicketType." = ".TypeCount." hits"
| eval UserLine=User." = ".UserCount." times"

| rename COMMENT as "when we take the 'values' of each message, then all the duplicates will go away." 
| stats values(TicketLine) as "Nature of Hits" values(UserLine) as "User Profile" by _time
| eval TimeSpan = strftime(_time,"%H:%M")."-".strftime(_time+180,"%H:%M")
| table _time TimeSpan "Nature of Hits" "User Profile"

And for anyone who wants to play with it, here's a random test data generator that goes above the code.

| makeresults 
| rename COMMENT as "Create records for 24 minutes"
| eval _time =relative_time(_time,"@h") | eval myTime=mvrange(_time,_time+1440,60)| mvexpand myTime | eval _time = myTime 
| table _time 

| rename COMMENT as "Create three possible users, randomly delete some records"
| eval User=mvappend("Barney","Fred","Wilma") | mvexpand User
| eval myrand = random()%100 | where myrand>50

| rename COMMENT as "Barney is lazy, so kill a few more of his records."
| where myrand<90 OR User!="Barney"

| rename COMMENT as "Create three possible types, randomly delete some records"
| eval TicketType=mvappend("Type1","Type2","Type3","Type1","Type1") | mvexpand TicketType
| eval myrand = random()%100 | where myrand>40

| rename COMMENT as "Surviving records, we'll clone up to 8 times, then randomly delete more, leaving hills and gaps"
| eval myrand= random() % 8
| eval myfan=mvrange(0,myrand) | mvexpand myfan 

| rename COMMENT as "The above creates test data."
| table _time TicketType User
0 Karma

richgalloway
SplunkTrust
SplunkTrust

What is your question? Have you checked splunkbase to see if there's an app available to help onboard the data?

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...