Splunk Search
Highlighted

using multiselect to concatenate fields into a compound key

Path Finder

We have a dashboard where the user can select multiple in a multiselect input field. Those values correspond to column in a splunk table. We want to be able to concatenate those columns, based on selection, so that we can easily chart the timeseries. We are struggling to get the dynamic list resolved in SPL to concatenate the fields.

multiselect options -
Host
Environment
Node Group
etc...

If we select all three, we want to create a new field in each row of the data that contains the 'Host':'Environment':'Node Group'. Sort of like creating a compound key for that summary row. The next user might select 'Node Group':'Environment'. Any suggestions?

0 Karma
Highlighted

Re: using multiselect to concatenate fields into a compound key

Super Champion

if you use a regex, you might be able to do something. The regex below is saying that the input itself is input=Environment OR input=....

|makeresults|eval input="$token$"|rex field=input mode=sed "s/ OR input=/':'/g"|rex field=input mode=sed "s/input=|$/'/g"

0 Karma
Highlighted

Re: using multiselect to concatenate fields into a compound key

Builder

@mschellhouse , can you try this please:

<fieldset submitButton="false">
    <input type="multiselect" token="field1">
      <label>field1</label>
      <choice value="Host">Host</choice>
      <choice value="Environment">Environment</choice>
      <choice value="Node Group">Node Group</choice>
      <delimiter>:</delimiter>
      <valuePrefix>'</valuePrefix>
      <valueSuffix>'</valueSuffix>
    </input>
  </fieldset>
0 Karma
Highlighted

Re: using multiselect to concatenate fields into a compound key

Path Finder

Thanks for trying but neither examples work for us. here is the exact query. The idea is to use the multiselect on a dashboard to replace what is currently a static list. The example below highlights one static selection ('host'+ ":"+ 'assetGroup').

| tstats max("CPU.lparvpusage") AS vpusage max("CPU.cpuPCT") AS pctusage values(CPU.assetGroup) AS assetGroup values(CPU.assetAreaName) AS assetAreaName values(CPU.assetName) AS assetName values(CPU.assetColor) AS assetColor values(CPU.nodeType) AS nodeType values(CPU.nodeGroup) AS nodeGroup values(CPU.cluster) AS cluster values(CPU.awsAutoScalingGroupId) AS awsAutoScalingGroupId
from datamodel=NMON
DataCPU
where (nodename = CPU) (CPU.type="CPU
ALL" OR CPU.type="LPAR") (host="")
by _time, host, CPU.assetGroup, CPU.assetAreaName, CPU.assetName span=1m
| search (assetGroup="prod") (assetAreaName ="
") (assetName ="USA") (assetColor = "") (nodeType="") (nodeGroup="") (cluster ="") (awsAutoScalingGroupId="*")
| eval dd1='host'+ ":"+ 'assetGroup'
| stats dedupsplitvals=t max("pctusage") AS pctusage by _time, host, assetGroup, assetAreaName, assetName, dd1
| eval usage=if(isnum(vp
usage), vpusage, pctusage)
| timechart useother=f limit=0 avg(usage) AS "CPU usage" by dd1

0 Karma
Highlighted

Re: using multiselect to concatenate fields into a compound key

Path Finder

Answering my own question on this one...
A simple delimiter of +":"+ on the multiselect input did the trick.

View solution in original post

0 Karma