Dashboards & Visualizations

Help for retrieving a lookup date and to display it in a dashboard

jip31
Motivator

hi

I have a csv file in my lookup folder (host.csv) and I wonder if its possible to retrieve the last modification file of this file and to display it in a panle title?
thanks for your help

Tags (1)
0 Karma
1 Solution

arjunpkishore5
Motivator

Not very clear on what exactly you meant by "last modification file".

If you meant just display the latest version for the file, do this

| inputlookup <filename>.csv

If you want the last modified timestamp of the file, use the rest api, use this

| rest /servicesNS/-/-/data/lookup-table-files/<filename>.csv 
| table updated

View solution in original post

woodcock
Esteemed Legend

If by last modification you mean the current state, then yes, just do this:

| inputlookup YourLookupFileNameHere.csv

If you mean the previous state before the last edit, then this is only possible if you have taken steps to save it before you edit it, or if you are using Lookup File Editor app. If the latter, then there is a Revert to previous version button that allows this.

0 Karma

arjunpkishore5
Motivator

Not very clear on what exactly you meant by "last modification file".

If you meant just display the latest version for the file, do this

| inputlookup <filename>.csv

If you want the last modified timestamp of the file, use the rest api, use this

| rest /servicesNS/-/-/data/lookup-table-files/<filename>.csv 
| table updated

nehamvinchankar
Path Finder

Can you use above rest query for kv store lookup also?

0 Karma

jip31
Motivator

Hi
I want to retrieve the last modification date like when you do "right click" and "properties" on a file
I dont understand your answer
what do you mean by "| inputlookup .csv"??

0 Karma

arjunpkishore5
Motivator

Please mark as answer if this answers your query

0 Karma

jip31
Motivator

hello
The API works but how to format the updated field??
| rest/servicesNS/-/-/data/lookup-table-files/host.csv
| eval updated = strftime(updated, "%d-%m-%y %H:%M")
| table updated

0 Karma

arjunpkishore5
Motivator
| eval updated=strptime(updated,"%FT%T%:z")

strftime converts unix timestamp(number) to string
strptime converts string to unix timestamp

0 Karma

jip31
Motivator

hummm, issue, there is no results when I add your eval...

0 Karma

arjunpkishore5
Motivator

I would guess the time format is different in your Splunk setup. Can you post a sample time without the eval?

0 Karma

jip31
Motivator

here is
1970-01-01T01:00:00+01:00

0 Karma

arjunpkishore5
Motivator

The earliest data strptime can work with is January 1 1971. Try using a more recent date.
https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/DateandTimeFunctions

0 Karma

arjunpkishore5
Motivator

Inputlookup displays the contents of your csv file in a table.

For your use case, use the rest command I pasted in the answer

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...