Getting Data In

How to draw a table that digests a field which varies differently

Saer000
Engager

Hi, I wanna plot a table to indicate the scanner status of Gitlab repos in the dashboard, like below: (1 means enabled, 0 means no used).

fullPathSASTSAST_IACDASTDEPENDENCY_SCANNINGCONTAINER_SCANNINGSECRET_DETECTIONCOVERAGE_FUZZING
API_FUZZING
CLUSTER_IMAGE_SCANNING
repos1100101000
repos2111111000
repos3100111110

 

And my raw data stream look like below:

 

{"fullPath": "repos1", "securityScanners": {"available": ["SAST", "SAST_IAC", "DAST", "DEPENDENCY_SCANNING", "CONTAINER_SCANNING", "SECRET_DETECTION", "COVERAGE_FUZZING", "API_FUZZING", "CLUSTER_IMAGE_SCANNING"], "enabled": ["SAST", "DEPENDENCY_SCANNING", "SECRET_DETECTION"], "pipelineRun": ["SAST", "DEPENDENCY_SCANNING", "SECRET_DETECTION"]}}

{"fullPath": "repos2", "securityScanners": {"available": ["SAST", "SAST_IAC", "DAST", "DEPENDENCY_SCANNING", "CONTAINER_SCANNING", "SECRET_DETECTION", "COVERAGE_FUZZING", "API_FUZZING", "CLUSTER_IMAGE_SCANNING"], "enabled": ["SAST", "DEPENDENCY_SCANNING", "SECRET_DETECTION"], "pipelineRun": ["SAST", "DEPENDENCY_SCANNING", "SECRET_DETECTION", "DAST"]}}

 


Could anyone help me build a search language to achieve the above?

Labels (1)
Tags (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Here is an example using your example data 

| makeresults
| eval x=split("{\"fullPath\": \"repos1\", \"securityScanners\": {\"available\": [\"SAST\", \"SAST_IAC\", \"DAST\", \"DEPENDENCY_SCANNING\", \"CONTAINER_SCANNING\", \"SECRET_DETECTION\", \"COVERAGE_FUZZING\", \"API_FUZZING\", \"CLUSTER_IMAGE_SCANNING\"], \"enabled\": [\"SAST\", \"DEPENDENCY_SCANNING\", \"SECRET_DETECTION\"], \"pipelineRun\": [\"SAST\", \"DEPENDENCY_SCANNING\", \"SECRET_DETECTION\"]}}X{\"fullPath\": \"repos2\", \"securityScanners\": {\"available\": [\"SAST\", \"SAST_IAC\", \"DAST\", \"DEPENDENCY_SCANNING\", \"CONTAINER_SCANNING\", \"SECRET_DETECTION\", \"COVERAGE_FUZZING\", \"API_FUZZING\", \"CLUSTER_IMAGE_SCANNING\"], \"enabled\": [\"SAST\", \"DEPENDENCY_SCANNING\", \"SECRET_DETECTION\"], \"pipelineRun\": [\"SAST\", \"DEPENDENCY_SCANNING\", \"SECRET_DETECTION\", \"DAST\"]}}","X")
| mvexpand x
| rename x as _raw
| spath
| fields - _raw
| rename securityScanners.* as *
| chart values(enabled{}) by fullPath available{}
| foreach * [ eval <<FIELD>>=if("<<MATCHSTR>>"="fullPath", <<FIELD>>, if(isnull(mvfind(<<FIELD>>, "<<MATCHSTR>>")), 0, 1)) ]

The search fragment you need will be the last 3 lines and it assumes that your JSON fields have been extracted based on their JSON names.

 

 

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

Here is an example using your example data 

| makeresults
| eval x=split("{\"fullPath\": \"repos1\", \"securityScanners\": {\"available\": [\"SAST\", \"SAST_IAC\", \"DAST\", \"DEPENDENCY_SCANNING\", \"CONTAINER_SCANNING\", \"SECRET_DETECTION\", \"COVERAGE_FUZZING\", \"API_FUZZING\", \"CLUSTER_IMAGE_SCANNING\"], \"enabled\": [\"SAST\", \"DEPENDENCY_SCANNING\", \"SECRET_DETECTION\"], \"pipelineRun\": [\"SAST\", \"DEPENDENCY_SCANNING\", \"SECRET_DETECTION\"]}}X{\"fullPath\": \"repos2\", \"securityScanners\": {\"available\": [\"SAST\", \"SAST_IAC\", \"DAST\", \"DEPENDENCY_SCANNING\", \"CONTAINER_SCANNING\", \"SECRET_DETECTION\", \"COVERAGE_FUZZING\", \"API_FUZZING\", \"CLUSTER_IMAGE_SCANNING\"], \"enabled\": [\"SAST\", \"DEPENDENCY_SCANNING\", \"SECRET_DETECTION\"], \"pipelineRun\": [\"SAST\", \"DEPENDENCY_SCANNING\", \"SECRET_DETECTION\", \"DAST\"]}}","X")
| mvexpand x
| rename x as _raw
| spath
| fields - _raw
| rename securityScanners.* as *
| chart values(enabled{}) by fullPath available{}
| foreach * [ eval <<FIELD>>=if("<<MATCHSTR>>"="fullPath", <<FIELD>>, if(isnull(mvfind(<<FIELD>>, "<<MATCHSTR>>")), 0, 1)) ]

The search fragment you need will be the last 3 lines and it assumes that your JSON fields have been extracted based on their JSON names.

 

 

Saer000
Engager

Thanks a lot, it really works on my side.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

What have you tried so far?  How have those efforts not met expectations?

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...