Splunk Search

Split Single columns in equal multiple columns

jerinvarghese
Communicator

Hi All,

I have a code, that gives below output.

CODE: 

| inputlookup ONMS_nodes.csv
| table nodelabel

OUTPUT : 

nodelabel
LANCUA005
LANCUA008
LANCUA012
LANCUA014
LANCUA016
LANCUA018
LANCUA019
LANCUA020
LANCUA022
LANCUA023

 

This is a sample output. List can goes more than 600 or 700 devices. 

Requirement is like : 

Can we split this into multiple columns within the panel.

nodelabelnodelabel
LANCUA005LANCUA016
LANCUA008LANCUA018
LANCUA012LANCUA019
LANCUA014LANCUA020
LANCUA023LANCUA022

 

SO that the content can be used the whole single panel  page to display the entire content.

Labels (6)
0 Karma
1 Solution

tscroggins
Influencer

@jerinvarghese 

In SPL, you can count rows and columns and add xyseries to reformat by row/column:

| inputlookup ONMS_nodes.csv
| table nodelabel
| streamstats reset_after="rows==10" count as rows
| streamstats count as columns
| eval columns=floor((columns-1)/10)
| xyseries rows columns nodelabel
| sort rows
| fields - rows

 In this example, the columns (fields) are labeled 0, 1, 2, ..., 9. You can't give multiple fields the same label, but you can prefix them with "nodelabel" to make them a little more descriptive:

| inputlookup ONMS_nodes.csv
| table nodelabel
| streamstats reset_after="rows==10" count as rows
| streamstats count as columns
| eval columns=floor((columns-1)/10)
| xyseries rows columns nodelabel
| sort rows
| fields - rows
| foreach * [ rename <<FIELD>> as nodelabel_<<FIELD>> ]

 

View solution in original post

0 Karma

tscroggins
Influencer

@jerinvarghese 

In SPL, you can count rows and columns and add xyseries to reformat by row/column:

| inputlookup ONMS_nodes.csv
| table nodelabel
| streamstats reset_after="rows==10" count as rows
| streamstats count as columns
| eval columns=floor((columns-1)/10)
| xyseries rows columns nodelabel
| sort rows
| fields - rows

 In this example, the columns (fields) are labeled 0, 1, 2, ..., 9. You can't give multiple fields the same label, but you can prefix them with "nodelabel" to make them a little more descriptive:

| inputlookup ONMS_nodes.csv
| table nodelabel
| streamstats reset_after="rows==10" count as rows
| streamstats count as columns
| eval columns=floor((columns-1)/10)
| xyseries rows columns nodelabel
| sort rows
| fields - rows
| foreach * [ rename <<FIELD>> as nodelabel_<<FIELD>> ]

 

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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