Splunk Search

How to combine CMDB tables?

navb
Loves-to-Learn

We have two CMDB tables logs in to Splunk

1.  CMDB Business application - Business related info

2. CMDB Rel - Relationship table

We need business application info along with host name

CMDB Business application table fields are,

AppNumber  AppName    AppOwner     ServerStatus

     1                          APP 1                                 X                                 Operational
     2                          APP 2                                 Y                                 Operational
     3                          APP 3                                 Z                                 Operational

CMDB Relationship table fields are,

AppParent       AppChild

    APP 1             APP 1 Production
    APP 2            App 2 Dev
    APP 3            APP 3 Test
                            HostName 1
                            HostName 2 
                            HostName 3

The common Fields  from these tables are ApplicationName  and AppParent(Which is the application name). We need to combine the Application number from the business application with hostnames. Is there any way to combine these two tables via Splunk search?

There is no direct relationship between  AppNumber or AppName  with HostNames.

 These two CMDB tables are in different sourcetype from same Index.

Tags (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

First, the illustrated CMDB Relationship table is nonsensical.  This is more obvious if I put your illustration in strict table format:

AppParentAppChild
APP 1APP 1 Production
APP 2APP 2 Dev
APP 3APP 3 Test
 HostName 1
 HostName 2
 HostName 3

The last three rows contain no key other than hostname; and HostName appears in AppChild column.  There is no solution to your problem under these conditions.

Now, If the table is like the following, you can hope to establish some sort of relationship between the Business application table and this table.

AppParentAppChildHostName
APP 1APP 1 ProductionHostName 1
APP 2APP 2 DevHostName 2
APP 3APP 3 TestHostName 3

Let us know.

0 Karma

navb
Loves-to-Learn

Hello yuanliu,

Here is the updated Rel table fields,

AppParentAppChild
APP 1APP 1 Production
APP 2APP 2 Dev
APP 3APP 3 Test
APP 1 ProductionHostName 1
APP 2 DevHostName 2
APP 3 TestHostName 3
APP 1 ProductionHostName 4
APP 2 DevHostName 5
APP 3 TestHostName 6
0 Karma

yuanliu
SplunkTrust
SplunkTrust

OK.  Now I can see the intention.  But if these tables are in production, the designer needs to be fired😏.  The second table cannot possibly be a single table.

In completely normalized form, the intended CMDB can be represented in three tables like these:

Table 1

AppNumber

AppNameAppOwnerServerStatus
1APP 1XOperational
2APP 2YOperational
3APP 3ZOperational

 

Table 2

AppParentAppChild
APP 1APP 1 Production
APP 2APP 2 Dev
APP 3APP 3 Test

 

Table 3

AppChildhost
APP 1 ProductionHostName 1
APP 2 DevHostName 2
APP 3 TestHostName 3
APP 1 ProductionHostName 4
APP 2 DevHostName 5
APP 3 TestHostName 6

Because (Dev, Test, Production) is an extremely limited set, you can probably merge Table 1 and Table 2 into one slightly bloated one without sacrificing much efficiency.  But Table 2 and Table 3 cannot easily merge, and definitely not in the way illustrated.

Table 2 is a static table best represented in a lookup.  It can be file based or KV store based.  I'll call this lookup table2.  Dynamic tables 1 and 3 are represented in the same index as different sourcetypes.  I'll call them sourcetypes table1 and table3.  I'll call the index cmdb.

The following is a prototype to associate table 1 with table 3 (via table 2):

index=cmdb sourcetype IN (table1, table3)
| lookup table2 AppParent AS AppName ``` OUTPUT AppChild ```
| stats values(host) as host values(AppNumber) as AppNumber values(AppName) as AppName values(AppOwner) as AppOwner values(ServerStatus) as ServerStatus by AppChild
| mvexpand host

 I now have doubts whether ServerStatus should be in Table 1.  But that's not a Splunk question.  The difference is: If ServerStatus is also in Table 3, Table 1 is also static and should be put in a CSV file or KV store as lookup.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...