Wiki » History » Version 2
Luke Murphey, 07/29/2015 11:06 PM
1 | 1 | Luke Murphey | h1. Wiki |
---|---|---|---|
2 | 2 | Luke Murphey | |
3 | 2 | Luke Murphey | h2. What is this? |
4 | 2 | Luke Murphey | |
5 | 2 | Luke Murphey | This is a Splunk app showing how to use a custom chunk of Javascript that allows users to put their own JavaScripting in dashboards. |
6 | 2 | Luke Murphey | |
7 | 2 | Luke Murphey | h2. How do I use this? |
8 | 2 | Luke Murphey | |
9 | 2 | Luke Murphey | 1. Download the app; you can get the bits from "here":(http://lukemurphey.net/attachments/download/334/javascript_on_dashboards.tar.gz). |
10 | 2 | Luke Murphey | 2. Install the app using the configuration page within Splunk |
11 | 2 | Luke Murphey | 3. Make a view and include a div with a class of "Javascript"; this code will be executed automatically when you open the view within this app. |
12 | 2 | Luke Murphey | |
13 | 2 | Luke Murphey | h2. How to add scripting to your view |
14 | 2 | Luke Murphey | |
15 | 2 | Luke Murphey | You will need to make your view with a special div that will inlcude your Javascript. All you need to do is to make an html block that includes a div with a class of "javascript". The code within this div will be interpreted as Javascript and executed automatically. |
16 | 2 | Luke Murphey | |
17 | 2 | Luke Murphey | The app includes a view titled "javascript_dashboard_example" that shows an example. |
18 | 2 | Luke Murphey | |
19 | 2 | Luke Murphey | Here is the example: |
20 | 2 | Luke Murphey | |
21 | 2 | Luke Murphey | {code} |
22 | 2 | Luke Murphey | <dashboard> |
23 | 2 | Luke Murphey | <label>Javascript on Dashboard Example</label> |
24 | 2 | Luke Murphey | <row> |
25 | 2 | Luke Murphey | <html> |
26 | 2 | Luke Murphey | Current time (being updated with Javascript): |
27 | 2 | Luke Murphey | <div style="margin-top:12px" id="time"></div> |
28 | 2 | Luke Murphey | <div class="javascript"> |
29 | 2 | Luke Murphey | setInterval(function(){ |
30 | 2 | Luke Murphey | $('#time').html(new Date()); |
31 | 2 | Luke Murphey | }, 1000); |
32 | 2 | Luke Murphey | </div> |
33 | 2 | Luke Murphey | </html> |
34 | 2 | Luke Murphey | </row> |
35 | 2 | Luke Murphey | </dashboard> |
36 | 2 | Luke Murphey | {code} |
37 | 2 | Luke Murphey | |
38 | 2 | Luke Murphey | Notice the div with the class of "javascript". The app will run this code automatically, but only when you load the view within the javascript_on_dashboards app (i.e. viewing it in another app will not work). |