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 |
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 |
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 |
Encountered the following error while trying to save: File has no line endings
any suggestions?
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.