Splunk Search

Rename row by data case at line chart

Questioner
Path Finder

I want to rename row value by data case. (It is line chart)

The line chart row name changed  by token $value$

if value is "iron" -> row must rename as "metal" -> and graph line become "black"

if value is "steak" -> row must rename as "food". -> and graph line become "red"

so I wrote the code like this, but it's not work at all.

<search>
<query>

...
|eval dt = case("$value$" == "iron", "metal", 1=1, "food")
|rename "row 1" as dt
...
</query>
</search>
<option name="charting.fieldColors">{"metal": 0xffffff, "food" : 0xFF0000}</option>

 How could I solve this problem?

Labels (1)
Tags (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
<search>
<query>
...
  |eval dt = case("$value$" == "iron", "metal", 1=1, "food")
  |eval {dt}='row 1'
...
</query>
</search>
<option name="charting.fieldColors">{"metal": 0xffffff, "food" : 0xFF0000}</option>

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
<search>
<query>
...
  |eval dt = case("$value$" == "iron", "metal", 1=1, "food")
  |eval {dt}='row 1'
...
</query>
</search>
<option name="charting.fieldColors">{"metal": 0xffffff, "food" : 0xFF0000}</option>

Questioner
Path Finder

I added this code under my code, but it show three rows 😢

row 1, "metal", "dt"

How could I solve this?

I added this line

<search>
<query>
...
  |sort total_time
  |transpose
  |eval dt = case("$value$" == "iron", "metal", 1=1, "food")
  |eval {dt}='row 1'
...
</query>
</search>
<option name="charting.fieldColors">{"metal": 0xffffff, "food" : 0xFF0000}</option>
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| fields - dt "row 1"
0 Karma

Questioner
Path Finder

OHHH There is something wrong my code.

It work!
Thank you for your help!!!😀

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Questioner,

could you share the full search? it isn't clear the algorithm you used.

Ciao.

Giuseppe

0 Karma

Questioner
Path Finder
<row>
    <panel>
      <chart>
        <title>checking the making time</title>
        <search>
          <query>
  | where make_end_time &lt;= 50
  | where amount != "None"
              | where total_time &lt;= 15
              | where value_type = case("$v_type$"=="iron", 1, "$v_type$"=="steak", 2, 1=1, value_type)
              | eval get_start_time = prepare - welcome
              | eval wash_time = finish_wash - prepare
              | eval make = make_time - finish_wash
              | chart eval(round(avg(get_start_time), 3)) as "Start time" eval(round(avg(wash_time), 3)) as "cleaning" eval(round(avg(coook), 3)) as "making"
              | sort total_time
              |transpose 
              |rename "row 1" as "metal" |rename "row 2" as "food"</query>
        </search>
        <option name="charting.fieldColors">{"metal": 0xffffff, "food" : 0xFF0000}</option>
<option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisMiddle</option>
        <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
        <option name="charting.axisTitleX.visibility">visible</option>
        <option name="charting.axisTitleY.text">time(s)</option>
        <option name="charting.axisTitleY.visibility">visible</option>
        <option name="charting.axisTitleY2.visibility">visible</option>
        <option name="charting.axisY.abbreviation">none</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.axisY2.enabled">0</option>
        <option name="charting.axisY2.scale">inherit</option>
        <option name="charting.chart">line</option>
        <option name="charting.chart.stackMode">default</option>
        <option name="charting.drilldown">all</option>
        <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
        <option name="charting.legend.mode">standard</option>
        <option name="charting.legend.placement">top</option>
        <option name="height">363</option>
        <option name="refresh.display">progressbar</option>
        <option name="trellis.enabled">0</option>
      </chart>
    </panel>
  </row>


This is my origin code! The data will send to the server
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...