Splunk Search

Count Dashboard for each ip based on traffic count

New Member

Hi All,

I am trying to build the query to get the website hits for each IP, there are 16 servers ip and wanted to get the traffic served by each ip in every 15 mints. I have schedule script running in every 15 mints and writing below details in logs. Can you help how i can extract the hit counts for all ip and show for timechart span=15m.

Below is the log file capturing the ip and hit counts every 15 mints.

Thanks, Ajay

0 Karma

Re: Count Dashboard for each ip based on traffic count


@ajat_semwal,For the community to assist you better please add more details.
what is the SPL you have tried so far and what is the output? Are above event separate events or multivalue within same event? If separate event do they have the same timestamp or not? Is there a way you can control what gets logged during IP and hits in your log? Is there any lookup kvstore which maintains the list of all available servers whether they have hit by specific server or not during entire timerange or not? Would you still want to always show all servers even if some of them do not have any hits for selected timerange? Is the log of Server IP and hits being stored, fetched in logs in specific format like csv or json?

Finally, if this is a new setup, do you have any Professional Service or Splunk SE contact you can help you with this kind of setup along with best practices?

Following is a run anywhere example which generates comma separated values similar to your question (since regular expression extraction depends on actual data feed this SPL might not directly work with your data). If data is in standard format field extraction can be controlled during ingestion or search time for automatic or predefined extraction.

| makeresults 
| eval data=",25155;,21461;,32736;,15529;,19987;,16751;,27953" 
| append 
    [| makeresults 
    | eval _time=_time-900, data=",10055;,21461;,20736;,20529;,23987;,10751;,32953"] 
| append 
    [| makeresults 
    | eval _time=_time-1800, data=",30055;,15461;,10736;,25529;,13987;,15751;,35953"] 
| append 
    [| makeresults 
    | eval _time=_time-2700, data=",20055;,20461;,15736;,18529;,30987;,25751;,15953"] 
| makemv data delim=";" 
| mvexpand data 
| rename data as _raw 
| rex field=_raw "(?<serverIP>[^,]+),(?<hits>(\d+))" 
| timechart span=15min sum(hits) as hits by serverIP cont=f

1. Commands till rename data as _raw generated raw data of comma separated Server IP and hits count.
2. I have added cont=f argument for timechart since I have generated only 4 data samples in the run anywhere example.

| eval message="Happy Splunking!!!"

0 Karma