Fei
Fei

Reputation: 13

Splunk: How to add cells of two tables

I have multiple tables, can I add/OR/AND... on each cell of all the tables?

For example, if I have below two tables, and add the corresponding cells,

file1.csv

row_id,0,2,4
0,     0,1,1
2,     0,0,1

file2.csv

row_id,0,2,4
0,     0,1,1
2,     0,1,0

The expected output is:

row_id,0,2,4
0,     0,2,2
2,     0,1,1

Thanks a lot!

Upvotes: 1

Views: 566

Answers (1)

pjnike
pjnike

Reputation: 181

The following should add the value of cells for the 2 tables:

| inputlookup file1.csv
| inputlookup append=t file2.csv
| stats sum(column1), sum(column2) by row_id 

The first line outputs the content of the first csv file. The append=t in the next line makes sure that the contents of the second csv file are appended at the end of the first.

Assuming row_id as the primary key, we can then sum the values of different columns using the Splunk stats command.

Upvotes: 1

Related Questions