Splunk Search

Joining records in a table

DexterWard
New Member

I have an audit table with before and after records of changes made to a user table. So every time an update is made to the user table, a record is logged to the audit table with the current value for each field, and and a second record is logged with the new value for each field. So if a record was disabled and that was the only change made, the 2 records would look like this:

Mod_type user IDEmailchange #Active
OLD123Me@hotmail.com152No
NEW123Me@hotmail.com152Yes

 

I need to match the 2 records by user ID and change # so I can find all the records where specific changes were made, such as going from inactive to active, or where the email address changed, etc. I've looked into selfjoin, appendpipe, etc., but none of them seem to be what I need. I'm trying to say "give me all the records where the active field was changed from "No" to "Yes" and the Mod_Type is "New"". 

Thanks for any help.

Labels (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Your "table" must come with a sequence or the whole problem is unsolvable.  The sequence may come in the form of a _time field, or a special field such as sequence_number, or in the form of sheer order of the table.

The whole point is, you can use transaction command to get what you need if your table

  1. Has a _time field and
  2. Is in reverse time order.
| transaction "change #" "user ID" startswith="Mod_type=OLD" endswith="Mod_type=NEW"

If, for any reason, your "table" doesn't come with a _time field, you can always make sure it is in reverse time order, and make up a _time field.  You can also use stats to do the same.  The bottom line is: join is seldom the answer.

Here is a data emulation for you to play with and compare with real data.

| makeresults format=csv data="Mod_type, user ID,Email,change #,Active
NEW,123,Me@hotmail.com,152,Yes
OLD,123,Me@hotmail.com,152,No"
| eval _time = now()
Tags (1)
0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...