Dashboards & Visualizations

In a Splunk dashboard, how do you create X panels based on an input ?

Explorer

Hi everyone,

So I have been searching for a way to create a dashboard that would generate X number of panels based on an output.

So lets say I have an SQL query that would give me the total number of cars(10 total cars), and the dashboard would generate 10 panels based on a template.

The only thing that would change would be the search ID of the cars.

example:

   <dashboard>
    <row>
      <panel>
        <title>Car number 1</title>
        <event id="myevents">
          <search>
            <query>index=all_my_cars_info car_id = 1 (......)</query>
            <earliest>0</earliest>
          </search>
      </panel>
    </row>
    <row>
      <panel>
        <title>Car number 2</title>
        <event id="myevents">
          <search>
            <query>index=all_my_cars_info car_id = 2 (......)</query>
            <earliest>0</earliest>
          </search>
      </panel>
    </row>
    <row>
    (THE REST OF THE 8 CARS.....)
   </dashboard>

Do you know if this is possible? I know that we can integrate JS on the dashboards or create whole HTML / JS dashboard, but i don't have any knowledge with JS to know if this would do the job / how to implement.

Best Regards.

Tags (3)
0 Karma
1 Solution

SplunkTrust
SplunkTrust

@venus699

Yes, you can achieve this using Splunk Web Framework Component. https://docs.splunk.com/DocumentationStatic/WebFramework/1.0/

You can check below links for learning how to use javascript in Splunk Dashboard with some examples.

http://dev.splunk.com/view/webframework-developapps/SP-CAAAE4A
http://dev.splunk.com/view/webframework-codeexamples/SP-CAAAEVY
http://dev.splunk.com/view/webframework-codeexamples/SP-CAAAEU7
http://dev.splunk.com/view/webframework-developapps/SP-CAAAESV

Your logic should like below.

  • Create a dashboard
  • Add HTML element in dashboard
  • Add div tag with id eg. <html><div id="testDiv" /> </html>
  • Create javascript and include into a dashboard,
  • Create a search which will give you a list of Cars.
  • Iterate Car List and Create a Car wise Panel you want and append in testDiv. Note: Here you have to manage a row or new line in HTML. Which is easily manageable using HTML Tags OR CSS.
  • Load the dashboard.

During javascript development, you need to clear Splunk Enterprise's client-side Splunk Web resources using: _bump

http://<host:port>/<locale_string>/_bump

https://docs.splunk.com/Documentation/Splunk/7.2.4/AdvancedDev/CustomizationOptions#Clear_client_and...

Just try and let me know if you need any help during implementation.

Thanks

View solution in original post

SplunkTrust
SplunkTrust

@venus699

Yes, you can achieve this using Splunk Web Framework Component. https://docs.splunk.com/DocumentationStatic/WebFramework/1.0/

You can check below links for learning how to use javascript in Splunk Dashboard with some examples.

http://dev.splunk.com/view/webframework-developapps/SP-CAAAE4A
http://dev.splunk.com/view/webframework-codeexamples/SP-CAAAEVY
http://dev.splunk.com/view/webframework-codeexamples/SP-CAAAEU7
http://dev.splunk.com/view/webframework-developapps/SP-CAAAESV

Your logic should like below.

  • Create a dashboard
  • Add HTML element in dashboard
  • Add div tag with id eg. <html><div id="testDiv" /> </html>
  • Create javascript and include into a dashboard,
  • Create a search which will give you a list of Cars.
  • Iterate Car List and Create a Car wise Panel you want and append in testDiv. Note: Here you have to manage a row or new line in HTML. Which is easily manageable using HTML Tags OR CSS.
  • Load the dashboard.

During javascript development, you need to clear Splunk Enterprise's client-side Splunk Web resources using: _bump

http://<host:port>/<locale_string>/_bump

https://docs.splunk.com/Documentation/Splunk/7.2.4/AdvancedDev/CustomizationOptions#Clear_client_and...

Just try and let me know if you need any help during implementation.

Thanks

View solution in original post

Explorer

Hi,
Thanks for the fast response. I will have a look and try this out and let you know.

0 Karma

Explorer

well i tyred and created some examples, but my knowledge of JS is not enought to do this, i sopted when trying to creat a token from result of a search, so with that value i could create the numver of panels i needed.
Guess i will have to find other way, thanks anyway.

0 Karma