Hi All,
I am new to splunk. Just using this wonderful application for my day to day activity. Below is the search which I use daily to pull the table, with the little change in source information.
The file name (source) has a big name with current date in YYYYMMDD format.
Example : E:/Program Files/Quintiq/Quintiq 4.4.0/Log/QTCE_64_1516_20150626_0223_0.xml
Is it possible to derive the source information from
eval nowstring=strftime(now(), "%Y%m%d") with wildcard character *.
I wish to write a search in such a way that there should not be a requirement of changing the "Source" tag everyday.
The easiest - and most splunky - approach would be to make sure your log's timestamps are extracted correctly and then use the time range picker to the right of the search bar to filter for Today
or whatever time range you need. What file name the events came from becomes less relevant and less of a problem to maintain in your search.
That'd solve your requirement, but not your suggested solution - that can be achieved, but I'd recommend first trying the splunky way. If you need help with timestamp extraction you can post some sample events from that log file along with any sourcetype settings you may already have set.
I agree with @martin_mueller in that you are putting your search string "cart" ahead of your config settings "horse". The way to do what you are asking is to make sure that your evens get properly timestamped. The easiest and quickest way to get "pretty close" is to use DATETIME_CONFIG = CURRENT
but a better solution is to use DATETIME_CONFIG = datetime.xml
to set each event's timestamp from the source
. The best would be to set each event's timestamp from some time in the event's data but you have not shared any sample events so we don't know about feasability of this.
The easiest - and most splunky - approach would be to make sure your log's timestamps are extracted correctly and then use the time range picker to the right of the search bar to filter for Today
or whatever time range you need. What file name the events came from becomes less relevant and less of a problem to maintain in your search.
That'd solve your requirement, but not your suggested solution - that can be achieved, but I'd recommend first trying the splunky way. If you need help with timestamp extraction you can post some sample events from that log file along with any sourcetype settings you may already have set.
You could post sample events to try and figure out timestamp extraction - assuming the log even has timestamps.
Alternatively, use this to calculate today's date dynamically within the search:
index=wdm_main [stats count as source | eval source = "*" . strftime(now(), "%Y%m%d") . "*"] sourcetype=...
That subsearch will evaluate to source="*YYYYMMDD*"
.
Thanks a loads. your solution solved my problem.
Cheers
Rishi
Thanks for your response but application logs are not splunk friendly and a bit weird. When i select "Today" it shows my "No results found"