Dashboards & Visualizations

Splunk app include js fail

faustf
Communicator

Hi Guys,

I was creating my Splunk application. My folder structure is this one:

drwxrwxr-x 3 user user 4096 Feb 17 15:19 appserver/
drwxrwxrwx 2 user user 4096 Feb 16 17:29 bin/
drwxrwxrwx 3 user user 4096 Feb 17 14:02 default/
drwx------ 2 root root 4096 Feb 17 14:39 local/
drwxrwxrwx 2 root root 4096 Feb 17 11:04 lookups/
drwxrwxrwx 2 user user 4096 Feb 17 15:01 metadata/
drwxrwxr-x 2 user user 4096 Feb 17 15:30 static/

I've a script in appserver/static/home.js
I've an html script in default/data/ui/html/home.html

<!DOCTYPE html>
<html lang="en">
<head>
   ........
</head>
<body class="simplexml preload locale-en" data-splunk-version="6.5.2" data-splunk-product="enterprise">
<!-- 
BEGIN LAYOUT
This section contains the layout for the dashboard. Splunk uses proprietary
styles in <div> tags, similar to Bootstrap's grid system. 
-->
<header>
    .....
</header>
<div class="dashboard-body container-fluid main-section-body" data-role="main">
....
</div>

<script src="/static/home.js"></script>

I tried to incude home.js n different way:

-

But, looking at the chrome console, I've a 404 error

Also every time that I modify the .html I call http://localhost:8000/en-US/debug/refresh
What I'm doing wrong?

Thanks

0 Karma
1 Solution

rjthibod
Champion

Try updating the script statement to one of the following where you need to put in your apps name.

<script src="/static/app/<YOUR_APP_NAME>/home.js"></script>

OR

<script src="{{SPLUNKWEB_URL_PREFIX}}/static/app/<YOUR_APP_NAME>/home.js"></script>

View solution in original post

rjthibod
Champion

Try updating the script statement to one of the following where you need to put in your apps name.

<script src="/static/app/<YOUR_APP_NAME>/home.js"></script>

OR

<script src="{{SPLUNKWEB_URL_PREFIX}}/static/app/<YOUR_APP_NAME>/home.js"></script>

faustf
Communicator

Perfect. It worked.
I used:

<script src="/static/app/<YOUR_APP_NAME>/home.js"></script>
0 Karma

faustf
Communicator

I tried also:
- home.js
- /home.js
- /static/home.js
- static/home.js

What should be the right way to include the script?

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...