Splunk Search

## Import a matrix

Contributor

Q1:  is there a way to import a matrix into Splunk?

Q2:  What SPL command gives me all values set to true and tells me x, y coordinates?  (object here is to create table)

Here is an example of the matrix that I would like to import.  (Q3:  What would be SPL command provided the field name for the x, y that is true)

 a b c d e f 1 0 1 0 1 1 0 2 1 0 1 0 0 1 3 0 1 0 1 1 0 4 1 0 1 1 1 0 5 0 1 1 0 1 1 6 1 0 1 0 1 0
Labels (5)

• ### table

Tags (5)
1 Solution
Influencer

You'll need to give the first column a name, e.g. row:

 row a b c d e f 1 0 1 0 1 1 0 2 1 0 1 0 0 1 3 0 1 0 1 1 0 4 1 0 1 1 1 0 5 0 1 1 0 1 1 6 1 0 1 0 1 0

Next, convert the table to comma separated values:

row,a,b,c,d,e,f
1,0,1,0,1,1,0
2,1,0,1,0,0,1
3,0,1,0,1,1,0
4,1,0,1,1,1,0
5,0,1,1,0,1,1
6,1,0,1,0,1,0

Save the contents to a file, e.g. youngsuh_matrix.csv, and upload the file to Splunk as a lookup from Settings > Lookups. Click + Add New next to Lookup table files.

Finally, run this search:

| inputlookup youngsuh_matrix.csv
| untable row column value
| where value==1

For "x, y" coordinates:

| inputlookup youngsuh_matrix.csv
| untable row column value
| where value==1
| eval coord=row.", ".column
| table coord

 coord 1, b 1, d 1, e 2, a 2, c 2, f 3, b 3, d 3, e 4, a 4, c 4, d 4, e 5, b 5, c 5, e 5, f 6, a 6, c 6, e

Influencer

You'll need to give the first column a name, e.g. row:

 row a b c d e f 1 0 1 0 1 1 0 2 1 0 1 0 0 1 3 0 1 0 1 1 0 4 1 0 1 1 1 0 5 0 1 1 0 1 1 6 1 0 1 0 1 0

Next, convert the table to comma separated values:

row,a,b,c,d,e,f
1,0,1,0,1,1,0
2,1,0,1,0,0,1
3,0,1,0,1,1,0
4,1,0,1,1,1,0
5,0,1,1,0,1,1
6,1,0,1,0,1,0

Save the contents to a file, e.g. youngsuh_matrix.csv, and upload the file to Splunk as a lookup from Settings > Lookups. Click + Add New next to Lookup table files.

Finally, run this search:

| inputlookup youngsuh_matrix.csv
| untable row column value
| where value==1

For "x, y" coordinates:

| inputlookup youngsuh_matrix.csv
| untable row column value
| where value==1
| eval coord=row.", ".column
| table coord

 coord 1, b 1, d 1, e 2, a 2, c 2, f 3, b 3, d 3, e 4, a 4, c 4, d 4, e 5, b 5, c 5, e 5, f 6, a 6, c 6, e

Contributor

Encountered the following error while trying to save: File has no line endings

any suggestions?

Tags (1)
SplunkTrust

The multikv command will read that table, but it will convert each row into a separate event so the table will no longer be a table.  I'm not aware of any command that will treat the table as an object and there certainly is no command that will return all the 1's in the table.  This could be an opportunity to create an external command.

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

#### Stay Connected: Your Guide to July and August Tech Talks, Office Hours, and Webinars!

Dive into our sizzling summer lineup for July and August Community Office Hours and Tech Talks. Scroll down to ...

#### Edge Processor Scaling, Energy & Manufacturing Use Cases, and More New Articles on ...

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

#### Get More Out of Your Security Practice With a SIEM

Get More Out of Your Security Practice With a SIEMWednesday, July 31, 2024  |  11AM PT / 2PM ETREGISTER ...