Dashboards & Visualizations

Problem with custom decorations and dashboards

changux
Builder

Hi, everyone!

I am trying to display green/red buttons when a condition returns 0 or 1.

My query is:

index="myindex" sourcetype="mysource"  | eval value=if(maild="running","1","0") | stats count by value  | fields value | rangemap field=value  up=1-1 down=0-0 none=2-2 default=none

Depends on my maild daemon data indexed, it returns value=1 | range=up or value=0 | range=down and works very well.

To show a nice button, i'm using this css:

.custom-result-value {
    font-size: 55px;
    margin: 35px auto;
    text-align: center;
    font-weight: bold;
    color: rgb(85, 85, 85);
}
.custom-result-value:before {
    font-family: "Splunk Icons";
    font-style: normal;
    font-weight: normal;
    text-decoration: inherit;
    font-size: 110%;
}
.down.custom-result-value:before {
    content: "\2297";
}
.down.custom-result-value {
    color: rgb(217, 63, 60);
}
.up.custom-result-value {
    color: rgb(101, 166, 55);
}
.up.custom-result-value:before {
    content: "\ECD3";
}
.custom-result-value.icon-only {
    font-size: 90px;
}

And finally the dashboard:

<dashboard stylesheet="custom_decorations.css">
    <label>temp</label>
    <description>
        This example shows decorations using tokens from search results, HTML panels and some custom CSS. The icon are displayed using the Splunk Icon Font.
    </description>
    <row>
        <panel>
            <search>
                <query>
                index="myindex" sourcetype="mysource"  | eval value=if(maild="running","1","0") | stats count by value  | fields value | rangemap field=value  up=1-1 down=0-0 none=2-2 default=none
                </query>
                <progress>
                    <set token="value1">$result.value$</set>
                    <set token="range1">$result.range$</set>
                </progress>
            </search>
            <html>
                <div class="custom-result-value $range1$">
                    $value1$ 
                </div>
            </html>
        </panel>
....

But doesn't work. The dashboard shows the red button when the value=1. I double checked in other search window and the query returns value=1 | range=up. Why inside my dashboard data doesn't look as desired?

Thanks!

Tags (3)
0 Karma
1 Solution

changux
Builder

I changed my query by:

index="myindex" sourcetype="mysource"  | eval value=if(maild="running","1","0") | top value showcount=f showperc=f | rangemap  field=value  up=1-1 down=0-0 none=2-2 default=none

And works!!!!

View solution in original post

0 Karma

changux
Builder

I changed my query by:

index="myindex" sourcetype="mysource"  | eval value=if(maild="running","1","0") | top value showcount=f showperc=f | rangemap  field=value  up=1-1 down=0-0 none=2-2 default=none

And works!!!!

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud | Unified Identity - Now Available for Existing Splunk ...

Raise your hand if you’ve already forgotten your username or password when logging into an account. (We can’t ...

Index This | How many sides does a circle have?

February 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...