You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,17 +155,21 @@ Becomes...
155
155
156
156
So it seems very easy to search for Tags{}.Value=Premier if you wanted to find all of the things with a Premier Intersight.LicenseTier tag, but this is not safe. The problem is that if there is also a tag named, for example, SLA that also has a value of Premier you'd match it. In this default model, the Key and the Value have no relationship so using these fields is desceptively dangerous from a data integrity standpoint.
157
157
158
-
The solution that I've come up with so far is pretty complex but appears to be safe to use. Here is an example...
158
+
The solution that I've come up with using only native Splunk SPL is pretty complex but appears to be safe to use. Here is an example...
159
159
160
-
`index=* sourcetype="cisco:intersight:*" | dedup Moid | rename Tags{}.Key as Key, Tags{}.Value as Value | eval zip=mvzip(Key,Value, ":") | mvexpand zip |rex field=zip mode=sed "s/$/\"}/g" |rex field=zip mode=sed "s/^/{\"tag./g"| rex field=zip mode=sed "s/:/\": \"/g" | spath input=zip | transaction Moid | search tag.Intersight.LicenseTier=Premier`
160
+
`index=* sourcetype="cisco:intersight:*" | dedup Moid | rename Tags{}.Key as Key, Tags{}.Value as Value | eval zip=mvzip(Key,Value, ":") | mvexpand zip |rex field=zip mode=sed "s/$/\"}/g" |rex field=zip mode=sed "s/^/{\"Tags./g"| rex field=zip mode=sed "s/:/\": \"/g" | spath input=zip | transaction Moid | search Tags.Intersight.LicenseTier=Premier`
161
161
162
-
This approach returns all of the available tags as separate fields named `tag.<Key>`. This certainly seems much more convenient to use as we can now search the value of specific tags.
162
+
This approach returns all of the available tags as separate fields named `Tags.<Key>`. This certainly seems much more convenient to use as we can now search the value of specific tags.
163
163
164
-

164
+

165
165
166
-
You could also use this approach to create a report of the tags in use.
166
+
An alternate (and perhaps better) approach is using the [array2object](https://splunkbase.splunk.com/app/6161/) application that is available from Splunkbase.
167
167
168
-
`index=* sourcetype="cisco:intersight:*" | dedup Moid | rename Tags{}.Key as Key, Tags{}.Value as Value | search Key=* | eval zip=mvzip(Key,Value, ":") | mvexpand zip |rex field=zip mode=sed "s/$/\"}/g" |rex field=zip mode=sed "s/^/{\"tag./g"| rex field=zip mode=sed "s/:/\": \"/g" | spath input=zip | transaction Moid | table sourcetype, Moid, tag.*`
0 commit comments