Created
January 9, 2018 15:12
-
-
Save thibodux/a4eeed8e43dcebb1e0d08f03ccd0927c to your computer and use it in GitHub Desktop.
Splunk marcro to list datamodel fields and their calling paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Splunk search macro to list all of the fields and their respective | |
# path / calling hierarchy within the passed datamodel | |
# (the $dm_name$ argument). This is useful for figuring | |
# out how to reference datamodel field names in tstats commands. | |
# Note, you need to prepend a leading pipe (|) to use this macro | |
# in a search, e.g., | `list_fields_by_datamodel_object("my_datamodel")` | |
[list_fields_by_datamodel_object(1)] | |
description = List of all fields in datamodel (arg1) | |
iseval = 0 | |
args = dm_name | |
definition = datamodel $dm_name$ | spath output=foo path=objects{} | mvexpand foo | table foo | spath input=foo path=objectName output=objectName | spath input=foo path=lineage output=lineage | spath input=foo output=fields path=fields{} | mvexpand fields | spath input=fields | table objectName lineage fieldName owner | append [| datamodel $dm_name$ | spath output=foo path=objects{} | mvexpand foo | table foo | spath input=foo path=objectName output=objectName | spath input=foo path=lineage output=lineage | spath input=foo output=fields path=calculations{}.outputFields{} | mvexpand fields | spath input=fields | table objectName lineage fieldName owner ] | eval path = owner.".".fieldName | eval path = "\"".replace(path,"^(BaseEvent\.)(.*)","\2")."\"" | rename fieldName as field |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment