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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...