Adjust enum readme and sample config style

This commit is contained in:
Daniel Nelson 2018-07-03 16:10:55 -07:00
parent 500e136844
commit bf076dab73
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
2 changed files with 37 additions and 45 deletions

View File

@ -9,26 +9,25 @@ used for all values, which are not contained in the value_mappings. The
processor supports explicit configuration of a destination field. By default the processor supports explicit configuration of a destination field. By default the
source field is overwritten. source field is overwritten.
### Configuration ### Configuration:
Configuration using table syntax:
`toml
# Configure a status mapping for field 'status'
[[processors.enum.fields]]
source = "status"
destination = "code"
default = -1
[processors.enum.fields.value_mappings]
green = 0
yellow = 1
red = 2
`
Configuration using inline syntax: ```toml
`toml [[processors.enum]]
# Configure a status mapping for field 'status' [[processors.enum.fields]]
[[processors.enum.fields]] ## Name of the field to map
source = "status" source = "name"
destination = "code"
default = -1 ## Destination field to be used for the mapped value. By default the source
value_mappings = {green = 0, yellow = 1, red = 2 } ## field is used, overwriting the original value.
` # destination = "mapped"
## Default value to be used for all values not contained in the mapping
## table. When unset, the unmodified value for the field will be used if no
## match is found.
# default = 0
## Table of mappings
[processors.enum.fields.value_mappings]
value1 = 1
value2 = 2
```

View File

@ -8,30 +8,23 @@ import (
) )
var sampleConfig = ` var sampleConfig = `
## NOTE This processor will map metric values to different values. It is aimed [[processors.enum.fields]]
## to map enum values to numeric values. ## Name of the field to map
source = "name"
## Fields to be considered ## Destination field to be used for the mapped value. By default the source
# [[processors.enum.fields]] ## field is used, overwriting the original value.
# # destination = "mapped"
# Name of the field source field to map
# source = "name" ## Default value to be used for all values not contained in the mapping
# ## table. When unset, the unmodified value for the field will be used if no
# Optional destination field to be used for the mapped value. Source field is ## match is found.
# used, when no explicit destination is configured. # default = 0
# destination = "mapped"
# ## Table of mappings
# Optional default value to be used for all values not contained in the mapping [processors.enum.fields.value_mappings]
# table. Only applied when configured. value1 = 1
# default = 0 value2 = 2
#
# Value Mapping Table
# [processors.enum.value_mappings]
# value1 = 1
# value2 = 2
#
## Alternatively the mapping table can be given in inline notation
# value_mappings = {value1 = 1, value2 = 2}
` `
type EnumMapper struct { type EnumMapper struct {