Knowledge Management

How to count the logs quickly that with eventtypes

xsstest
Communicator

I have an eventtype, but I want to count number of eventtype from nginx access log . then show on dashboard.

eventtype web_spider :

ua="spider" OR uri="spider" OR ua="bot" OR ua="monitor"

But nginx has a lot of logs , if use index=nginx eventtype="web_spider"|stats count,search speed will be very slow. Could I use tstats command to count ?

Tags (1)
0 Karma
1 Solution

mayurr98
Super Champion

yes you can use tstats command but you would need to build a datamodel for that.
Refer this for creating a data model
http://docs.splunk.com/Documentation/Splunk/7.0.1/PivotTutorial/Buildtutorialdatamodel

After creating a datamodel you can use tstats command

| tstats count FROM datamodel=<datamodel_name> where index=nginx eventtype="web_spider"

If you have a single query that you want it to run faster then you can try report acceleration as well.

Save a search index=nginx eventtype="web_spider"|stats count as report and then refer below link to do report acceleration
http://docs.splunk.com/Documentation/Splunk/7.0.2/Report/Acceleratereports

let me know if this helps!

View solution in original post

mayurr98
Super Champion

yes you can use tstats command but you would need to build a datamodel for that.
Refer this for creating a data model
http://docs.splunk.com/Documentation/Splunk/7.0.1/PivotTutorial/Buildtutorialdatamodel

After creating a datamodel you can use tstats command

| tstats count FROM datamodel=<datamodel_name> where index=nginx eventtype="web_spider"

If you have a single query that you want it to run faster then you can try report acceleration as well.

Save a search index=nginx eventtype="web_spider"|stats count as report and then refer below link to do report acceleration
http://docs.splunk.com/Documentation/Splunk/7.0.2/Report/Acceleratereports

let me know if this helps!

xsstest
Communicator

thank you very much ~I am a SPLUNK novice

0 Karma

logloganathan
Motivator

very good answer...

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 ...