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!

New This Month in Splunk Observability Cloud - Metrics Usage Analytics, Enhanced K8s ...

The latest enhancements across the Splunk Observability portfolio deliver greater flexibility, better data and ...

Alerting Best Practices: How to Create Good Detectors

At their best, detectors and the alerts they trigger notify teams when applications aren’t performing as ...

Discover Powerful New Features in Splunk Cloud Platform: Enhanced Analytics, ...

Hey Splunky people! We are excited to share the latest updates in Splunk Cloud Platform 9.3.2408. In this ...