From bf076dab7362d6db74245210781e26b8205bc1a5 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Tue, 3 Jul 2018 16:10:55 -0700 Subject: [PATCH] Adjust enum readme and sample config style --- plugins/processors/enum/README.md | 43 +++++++++++++++---------------- plugins/processors/enum/enum.go | 39 ++++++++++++---------------- 2 files changed, 37 insertions(+), 45 deletions(-) diff --git a/plugins/processors/enum/README.md b/plugins/processors/enum/README.md index 8ed3f1323..f0ed58566 100644 --- a/plugins/processors/enum/README.md +++ b/plugins/processors/enum/README.md @@ -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 source field is overwritten. -### 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: -Configuration using inline syntax: -`toml -# Configure a status mapping for field 'status' -[[processors.enum.fields]] - source = "status" - destination = "code" - default = -1 - value_mappings = {green = 0, yellow = 1, red = 2 } -` +```toml +[[processors.enum]] + [[processors.enum.fields]] + ## Name of the field to map + source = "name" + + ## Destination field to be used for the mapped value. By default the source + ## 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 +``` diff --git a/plugins/processors/enum/enum.go b/plugins/processors/enum/enum.go index 17706c8d6..134a02bb1 100644 --- a/plugins/processors/enum/enum.go +++ b/plugins/processors/enum/enum.go @@ -8,30 +8,23 @@ import ( ) var sampleConfig = ` -## NOTE This processor will map metric values to different values. It is aimed -## to map enum values to numeric values. + [[processors.enum.fields]] + ## Name of the field to map + source = "name" -## Fields to be considered -# [[processors.enum.fields]] -# -# Name of the field source field to map -# source = "name" -# -# Optional destination field to be used for the mapped value. Source field is -# used, when no explicit destination is configured. -# destination = "mapped" -# -# Optional default value to be used for all values not contained in the mapping -# table. Only applied when configured. -# default = 0 -# -# 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} + ## Destination field to be used for the mapped value. By default the source + ## 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 ` type EnumMapper struct {