In this article we will see how to join multiple datasets in Splunk using Lookup. Consider below two datasets:
Vendor Sales Data: Provides the detail of which vendors have sold what products.
Prices Data: Master data of the products like product name, price, sale price and code for each product.
Code is the common field between 2 data sets
Requirement is to display the Products sold by the vendors along with the vendor details and product details To get this information we would need to join the two datasets on a common field which is "Code" Splunk provides lookup command in order to do that.
I already have uploaded the vendor sales data to the index "index2". You can refer to my blog
"Upload a dataset to Splunk" for the steps to upload the data. Next step is to upload the prices data, which will be used as a lookup table to get the information on additional fields.
"Upload a dataset to Splunk" for the steps to upload the data. Next step is to upload the prices data, which will be used as a lookup table to get the information on additional fields.
Goto Settings -> Lookups -> Lookup table files -> New Lookup Table File
Leave the destination app field to default.
Upload your lookup file "Prices.csv"
Provide a destination, for example "prices.csv"
Hit Save
Goto Settings -> Lookups -> Lookup definitions -> New Lookup Definition
Leave the destination app as default "search"
Provide a name, for example "prices"
Select a type -> File-based
Select the lookup file you uploaded "prices.csv"
Go back to Search & Reporting app
Now we can use a command similar to below to join the two datasets using lookup command on the Common field "Code"
index=index2 source="tutorialdata.zip:./vendor_sales/vendor_sales.log" | lookup prices Code | table AcctID, VendorID, Code, productId, product_name
Comments
Post a Comment