# Options of key=value parsers

The `kv-parser` has the following options.

## extract-stray-words-into()

|   
---|---  
Synopsis: | extract-stray-words-into(")  
  
_Description:_ Specifies the name-value pair where AxoSyslog stores any stray words that appear before or between the parsed key-value pairs (mainly when the [`pair-separator()`](../../../docs/axosyslog-core/chapter-parsers/key-value-parser/kv-parser-options/index.md) option is also set). If multiple stray words appear in a message, then AxoSyslog stores them as a comma-separated list. Note that the `prefix()` option does not affect the name-value pair storing the stray words. Default value:`N/A`

### Example: Extracting stray words in key-value pairs

For example, consider the following message:
```
 
       VSYS=public; Slot=5/1; protocol=17; source-ip=10.116.214.221; source-port=50989; destination-ip=172.16.236.16; destination-port=162;time=2016/02/18 16:00:07; interzone-emtn_s1_vpn-enodeb_om; inbound; policy=370;
    
```

This is a list of key-value pairs, where the value separator is `=` and the pair separator is `;`. However, before the last key-value pair (`policy=370`), there are two stray words: `interzone-emtn_s1_vpn-enodeb_om inbound`. If you want to store or process these, specify a name-value pair to store them in the `extract-stray-words-into()` option, for example, `extract-stray-words-into("my-stray-words")`. The value of `${my-stray-words}` for this message will be `interzone-emtn_s1_vpn-enodeb_om, inbound`

## prefix()

|   
---|---  
Synopsis: | prefix()  
  
_Description:_ Insert a prefix before the name part of the parsed name-value pairs to help further processing. For example:

  * To insert the `my-parsed-data.` prefix, use the `prefix(my-parsed-data.)` option.
  * To refer to a particular data that has a prefix, use the prefix in the name of the macro, for example, `${my-parsed-data.name}`.
  * If you forward the parsed messages using the IETF-syslog protocol, you can insert all the parsed data into the SDATA part of the message using the `prefix(.SDATA.my-parsed-data.)` option.



Names starting with a dot (for example, `.example`) are reserved for use by AxoSyslog. If you use such a macro name as the name of a parsed value, it will attempt to replace the original value of the macro (note that only soft macros can be overwritten, see [Hard versus soft macros](../../../docs/axosyslog-core/chapter-manipulating-messages/customizing-message-format/macros-hard-vs-soft/index.md) for details). To avoid such problems, use a prefix when naming the parsed values, for example, `prefix(my-parsed-data.)`

By default, `kv-parser()` uses the `.kv.` prefix. To modify it, use the following format:
```
 
       parser {
            kv-parser(prefix("myprefix."));
        };
    
```

## pair-separator()

|   
---|---  
Synopsis: | pair-separator(")  
  
_Description:_ Specifies the character or string that separates the key-value pairs from each other. Default value: `,` .

For example, to parse `key1=value1;key2=value2` pairs, use `kv-parser(pair-separator(";"));` .

## template()

|   
---|---  
Synopsis: | `template("${<macroname>}")`  
  
_Description:_ The macro that contains the part of the message that the parser will process. It can also be a macro created by a previous parser of the log path. By default, the parser processes the entire message (`${MESSAGE}`).

## value-separator()

|   
---|---  
Synopsis: | value-separator("")  
  
_Description:_ Specifies the character that separates the keys from the values. Default value: `=`.

For example, to parse `key:value` pairs, use `kv-parser(value-separator(":"));`.

Last modified July 2, 2023: [Change highlight mode of code examples (2f8a9593)](<https://github.com/axoflow/axosyslog-core-docs/commit/2f8a95937c6498193e7168ce8b0dc831e9f0f8ad>)