Splunk Search

Retrieve lookup data with JS

ppatrikfr
Path Finder

Hello splunkers, i'm gonna try to be short, I'm trying to create an HTML homepage for Splunk APP and I've been trying to get some information through a lookup without splunkJS or any splunk code (i'm doing this because splunk is spoiling my CSS pages and I need to customize this page view and customize either the way I handle this lookup data).

OBS.: I have my JS and lookup in the same app, I tried to do something like this:
$.ajax({
url: '../../../../lookups/ccm_links.csv',
dataType: 'text',
}).done(successFunction);

0 Karma

jkat54
SplunkTrust
SplunkTrust

Way too few details for me to help here. I know you were being short...

So I see you’re working with Ajax. What is your preferred language to do this in? php, js, whatever?

What are you doing with the lookup once you have it? Writing,
Reading, Parsing, etc.?

0 Karma

ppatrikfr
Path Finder

Sorry for missing information.
1) I preferred js, but I can work with everything and I'm just using AJAX because it worked when I was testing on my computer but when I tried to do the same on server it didn't got the same result.

2) I'll read this information and split it up depending to the categories I'll determinate (using REGEX or a simple string comparison).

I'm just having some trouble while i'm trying to get lookup's data from splunk's folder.

EX: Lookups path : MYDISK:\Splunk\etc\apps\(APP_NAME)\lookups
My script path: MYDISK:\Splunk\etc\apps\(APP_NAME)\appserver\static

Thanks for your help.

0 Karma

jkat54
SplunkTrust
SplunkTrust

Would this help?

var loc = window.location.pathname;
var dir = loc.substring(0, loc.lastIndexOf('/'));

first uses js to find the current working directory the other is just a way to grab the last directory name in the current working directory.

What I would do is print the first var and see what it says. Then I would use the same method you have with the ../../../ etc to get back to the apps main directory and into the lookups folder and file.

Be sure to check permissions and that the user running your js UI has permissions on that lookup file.

Also check your logs to see
If there are any permissions errors, file not found, etc

0 Karma

jkat54
SplunkTrust
SplunkTrust
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...