Getting Data In

index start date

sushil_borah
Explorer

I need to generate a daily report in splunk with the list of all the indexes and their earliest event(timestamp) and their latest(timestamp). Is there a way to do it? I have the below queries.

For the start and end time:

| metadata type=sourcetypes index=XXX | stats min(firstTime) AS begin max(lastTime) AS end

For the list of indexes:

| eventcount summarize=false index=* dedup=index | top 0 index | fields index
1 Solution

araitz
Splunk Employee
Splunk Employee

Schedule this to run daily:

| rest /services/data/indexes 
| search totalEventCount > 0 
| eval now=strftime(now(), "%Y-%m-%d")
| stats first(maxTime) as maxTime first(minTime) as minTime first(now) as now first(currentDBSizeMB) as currentDBSizeMB by title 

View solution in original post

andygerber
Path Finder

Awesome answer. For me this refinement was helpful.

 | rest /services/data/indexes 
 | search totalEventCount > 0 
 | eval now=strftime(now(), "%Y-%m-%d")
 | stats first(maxTime) as "Earliest Event Time" first(minTime) as "Latest Event Time" first(now) as "Current Date" first(currentDBSizeMB) as currentDBSizeMB by title 
 | rename title as "Index" | sort - currentDBSizeMB
 | eval "Index Size in GB"= round(currentDBSizeMB/1000,2)
 | table Index "Earliest Event Time" "Latest Event Time" "Current Date" "Index Size in GB"

myacoub
Engager

Hello Andygerber,

I just believe you switched the Earliest with the latest in your search , Am i right ?

Thanks

0 Karma

andygerberkp
Explorer

Yes, I believe so... using a different account, or I would edit it. Corrected below:

 | rest /services/data/indexes 
  | search totalEventCount > 0 
  | eval now=strftime(now(), "%Y-%m-%d")
  | stats first(minTime) as "Earliest Event Time" first(maxTime) as "Latest Event Time" first(now) as "Current Date" first(currentDBSizeMB) as currentDBSizeMB by title 
  | rename title as "Index" | sort - currentDBSizeMB
  | eval "Index Size in GB"= round(currentDBSizeMB/1000,2)
  | table Index "Earliest Event Time" "Latest Event Time" "Current Date" "Index Size in GB"
0 Karma

araitz
Splunk Employee
Splunk Employee

Schedule this to run daily:

| rest /services/data/indexes 
| search totalEventCount > 0 
| eval now=strftime(now(), "%Y-%m-%d")
| stats first(maxTime) as maxTime first(minTime) as minTime first(now) as now first(currentDBSizeMB) as currentDBSizeMB by title 

araitz
Splunk Employee
Splunk Employee

It is the total size of the index in MB at the time that the search was run.

0 Karma

sushil_borah
Explorer

does currentDBSizeMB lists the total index volume?

0 Karma

araitz
Splunk Employee
Splunk Employee

see my update above.

0 Karma

sushil_borah
Explorer

is it possible to add the index volume to the above genertated report?

0 Karma

araitz
Splunk Employee
Splunk Employee

That's why I am here 🙂

0 Karma

sushil_borah
Explorer

thanks thats exactly what i needed

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