Getting Data In

Problems with line breaks in a config file

jambajuice
Communicator

I am trying to configure line breaking for a config file that looks like the following (I'm using 4 spaces to indent some of the lines, but it isn't working in the preview). Only the first config and last end start at the beginning of a new line. All of the other lines have multiple spaces or tabs:

config firewall profile-protocol-options  
    edit "strict"  
        config http  
            set port 80   
            set port 8080   
            unset options  
            unset post-lang  
        end  
        config https  
            set port 443   
            set port 8000   
            set options allow-invalid-server-cert no-content-summary  
            unset post-lang  
            set deep-scan enable  
        end  
end

I want to break the event at the first "config" and the last "end". I do not want it to break before/after any config or end line that is preceded by one or more spaces.

I have tried the following at none of them break properly:

[fortinet_config]
SHOULD_LINEMERGE = true
MUST_BREAK_AFTER = [^\s]end
BREAK_ONLY_BEFORE = [^\s]config

[fortinet_config]
SHOULD_LINEMERGE = true
MUST_BREAK_AFTER = (?i)^end
BREAK_ONLY_BEFORE = (?i)^config

[fortinet_config]
SHOULD_LINEMERGE = true
MUST_NOT_BREAK_BEFORE= (?i)^end
MUST_NOT_BREAK_AFTER = (?i)^config

[fortinet_config]
SHOULD_LINEMERGE = true
MUST_NOT_BREAK_BEFORE= (?i)end
MUST_NOT_BREAK_AFTER = (?i)config

Thanks.

Tags (1)

gkanapathy
Splunk Employee
Splunk Employee

Here's the best way:

[fortinet_config]
SHOULD_LINEMERGE = false
LINE_BREAKER = ([\r\n]+)(?=config)

It should get you the same results as the possibly clearer but less performant:

[fortinet_config]
SHOULD_LINEMERGE = true
BREAK_ONLY_BEFORE = ^config
0 Karma

gkanapathy
Splunk Employee
Splunk Employee

You might add a (?i) to the beginning of the LINE_BREAKER regex if in fact it's supposed to be case-insensitive.

0 Karma

jrodman
Splunk Employee
Splunk Employee

I'm feeling stupid tonight, so don't I don't want to get deep into the interaction of MUST_BREAK_AFTER and BREAK_ONLY_BEFORE. If everything is in one of these, you shouldn't need both. We can dig in later if it's needed?

The first ruleset is looking for words like 'config' which have somethig besides backslash or s before them. I think you want BREAK_ONLY_BEFORE = ^config Does that work alone?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...