I am trying to get the following query to show the related_vulnerabilities as a count column, instead of showing all the related vulns.
My query without the count produces this result:
However after adding the logic for the count, I get this result:
This is what my query looks like with the added stats count statement:
index=xxx md_type=xxx
info_owner_orgID="xxx"
| dedup id
| rex mode=sed field="related_vulnerabilities" "s/[][]//g"
| rex mode=sed field="related_vulnerabilities" "s/'//g"
| makemv delim="," related_vulnerabilities
| eval RV = mvindex(related_vulnerabilities,0)
| stats count(related_vulnerabilities) by info_name
| table info_name info_class related_vulnerabilities
How can I add a count column that shows the count of related_vulnerabilities?
@ rkassabov
you need to provide a alias name for the filed in stats and use that alias name in table .. While using stats, If you want to display any field in table. Then you need to do some operation or at-least you need to simply use that field in stats by using function like values(distinct values will be shown ) or list(duplicate values also shown ) as i shown below (info_class). I have used eval for showcasing the data. you dont want to consider it .. you can use stats and table in ur query.
Sample for ur understanding
|makeresults
| eval related_vulnerabilities="values"
| eval info_name="search"
| eval info_class="class name"
| stats count(related_vulnerabilities) as related_vulnerabilities, values(info_class) as info_class by info_name
| table info_name info_class related_vulnerabilities
Use This Query
index=xxx md_type=xxx
info_owner_orgID="xxx"
| dedup id
| rex mode=sed field="related_vulnerabilities" "s/[][]//g"
| rex mode=sed field="related_vulnerabilities" "s/'//g"
| makemv delim="," related_vulnerabilities
| eval RV = mvindex(related_vulnerabilities,0)
| stats count(related_vulnerabilities) as related_vulnerabilities, values(info_class) as info_class by info_name
| table info_name info_class related_vulnerabilities
once u got what u needed .. please accept the answer 🙂 ..
@ rkassabov
you need to provide a alias name for the filed in stats and use that alias name in table .. While using stats, If you want to display any field in table. Then you need to do some operation or at-least you need to simply use that field in stats by using function like values(distinct values will be shown ) or list(duplicate values also shown ) as i shown below (info_class). I have used eval for showcasing the data. you dont want to consider it .. you can use stats and table in ur query.
Sample for ur understanding
|makeresults
| eval related_vulnerabilities="values"
| eval info_name="search"
| eval info_class="class name"
| stats count(related_vulnerabilities) as related_vulnerabilities, values(info_class) as info_class by info_name
| table info_name info_class related_vulnerabilities
Use This Query
index=xxx md_type=xxx
info_owner_orgID="xxx"
| dedup id
| rex mode=sed field="related_vulnerabilities" "s/[][]//g"
| rex mode=sed field="related_vulnerabilities" "s/'//g"
| makemv delim="," related_vulnerabilities
| eval RV = mvindex(related_vulnerabilities,0)
| stats count(related_vulnerabilities) as related_vulnerabilities, values(info_class) as info_class by info_name
| table info_name info_class related_vulnerabilities
once u got what u needed .. please accept the answer 🙂 ..
Brilliant, thanks!
@rkassabov
your welcome. Thank you..
Happy Splunking 🙂