Dashboards & Visualizations

Need to parse Bluecoat VPM-XML file. this is not a XML format

danje57
Path Finder

Dear all,

I need your help as I need to parse a file generated by bluecoat, wich contain data relative to our web proxy policy.

The format is like this:

;; CPL generated by Visual Policy Manager: [Thu Mar 26 14:00:04 CET 2020]
;*************************************************************
; WARNING:
;     THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT!
;     ANY MANUAL CHANGES TO THIS FILE WILL BE LOST WHEN VPM
;     POLICY IS REINSTALLED.
;*************************************************************


define category "Blacklisted"
    isdsdsd.com
    *sdsds.com
end category "Blacklisted"

define condition __GROUP5
    realm=admin group="admonui"
end condition __GROUP5

define condition __GROUP7
    realm=admin group="user1"
end condition __GROUP7

define condition __GROUP25
    realm=blablablabla"
end condition __GROUP25

define condition __GROUP28
    realm=bliblibli
end condition __GROUP28

;; Description:
define condition __CondList1
    url.domain="*ecurity.com"
    url.domain="sdsds*ecurity.com"
end condition __CondList1

It seams that value are between words:
define XXXXX and end XXXXX

We cannot predict the XXXX

However XXXXX are the same to start with define and end for example
define MY_OWN_Policy
value1="dsdsds"
value2="fdfdfdfd"
end MY_OWN_Policy

In addition, comments are allowed using ;; before the define statement.

Do you have idea on how to parse such format?

Regards

0 Karma

danje57
Path Finder

Thanks to4kawa,

There is no way to create a source type instead to parse inline the file?

Indeed the file has 300line like this.

0 Karma

to4kawa
Ultra Champion

make transforms.conf with REGEX and FORMAT
good luck

0 Karma

to4kawa
Ultra Champion
|makeresults
| eval _raw=" ;; CPL generated by Visual Policy Manager: [Thu Mar 26 14:00:04 CET 2020]
 ;*************************************************************
 ; WARNING:
 ;     THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT!
 ;     ANY MANUAL CHANGES TO THIS FILE WILL BE LOST WHEN VPM
 ;     POLICY IS REINSTALLED.
 ;*************************************************************


 define category \"Blacklisted\"
     isdsdsd.com
     *sdsds.com
 end category \"Blacklisted\"

 define condition __GROUP5
     realm=admin group=\"admonui\"
 end condition __GROUP5

 define condition __GROUP7
     realm=admin group=\"user1\"
 end condition __GROUP7

 define condition __GROUP25
     realm=blablablabla\"
 end condition __GROUP25

 define condition __GROUP28
     realm=bliblibli
 end condition __GROUP28

 ;; Description:
 define condition __CondList1
     url.domain=\"*ecurity.com\"
     url.domain=\"sdsds*ecurity.com\"
 end condition __CondList1"
 | rex max_match=0 "(?ms)define (category|condition) (\"|__)(?<fieldname>\w+)[\"\s]+(?<fieldvalue>.*?)end"
 | rex field=fieldvalue mode=sed "s/\s+/ /g"
 | eval counter=mvrange(0,mvcount(fieldname))
 | stats list(field*) as field* by counter
 | foreach field* [ eval <<FIELD>> = mvindex('<<FIELD>>', counter) ]
 | eval {fieldname} = fieldvalue
 | fields - counter field*
 | stats values(*) as *
0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...