All Apps and Add-ons

SVG vizualization does not generate if there is no data found

stanwin
Contributor

tokens that are passed to the SVG viz xml need to be populated else it will be blank & u will see SVG Error.

Usually in other viz you will see no data found, but here you will get a SVG error text.

host=popeyeOtherEye does not exist i assume

   index=_internal host=popeyeOtherEye
    | stats count 
    | eval KOLOR = case( count > 0,"limegreen",count ==0,"RED" ,true(),"orange")
    |eval svg_viz = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
    <!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">
    <svg viewBox=\"0 0 1200 250\" width=\"1200\" height=\"250\">
       <style>
         .small { font: bold  11px Calibri; }
        .heavy { font: bold 20px Calibri; }
      </style>   

      <rect x=\"0\" y=\"20\" rx=\"3\" ry=\"3\" width=\"90\" height=\"40\" style=\"fill:"+KOLOR+";stroke:black;stroke-width:2;opacity:1.0\" /> 

      <text x=\"10\" y=\"50\" fill=\"black\" style=\"opacity:0.8\"   class=\"heavy\"  >"+count+"</text>
      <text x=\"0\" y=\"75\" fill=\"black\" style=\"opacity:0.8\"  class=\"small\" >_internal Count</text>

    </svg> 
    "
0 Karma
1 Solution

stanwin
Contributor

Posting this to help anyone that has similar issues.

Although you probably would do this for even non svg vizualizations!

use an eval with coalesce or whatever you prefer to set default catch all value for all the tokens passed to the svg viz xml..

index=_internal 
| stats count 
| eval count = coalesce(count,"0")
| eval KOLOR = case( count > 0,"limegreen",count ==0,"RED" ,true(),"orange")

alt text

View solution in original post

stanwin
Contributor

Posting this to help anyone that has similar issues.

Although you probably would do this for even non svg vizualizations!

use an eval with coalesce or whatever you prefer to set default catch all value for all the tokens passed to the svg viz xml..

index=_internal 
| stats count 
| eval count = coalesce(count,"0")
| eval KOLOR = case( count > 0,"limegreen",count ==0,"RED" ,true(),"orange")

alt text

msivill_splunk
Splunk Employee
Splunk Employee

Version 3.0.1 of the Scalable Vector Graphics - Custom Visualization app has been updated to show different error messages.

  • If there are no events from the query results then
    the standard "No results found" will
    be returned
  • Errors with the svg_viz
    field not appearing in the query results or not having a value will return "SVG field error"
  • Errors with bad SVG in
    svg_viz filed will return "SVG parse
    error"

While this does not solve the original issue it should help narrow down any potential issues quicker by identifying where the error may be.

0 Karma

msivill_splunk
Splunk Employee
Splunk Employee

Good catch and workaround.

I'll need to dig into how to fix this the next time I get to look at the code behind the SVG app.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...