Dashboards & Visualizations

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

venus699
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

kamlesh_vaghela
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

kamlesh_vaghela
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

venus699
Explorer

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

0 Karma

venus699
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
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...