Documentation
¶
Overview ¶
Package mapstrstr contains utilities for transforming map[string]string objects into metricbeat events. For example, given this input object:
input := map[string]interface{}{
"testString": "hello",
"testInt": "42",
"testBool": "true",
"testFloat": "42.1",
"testObjString": "hello, object",
}
And the requirement to transform it into this one:
common.MapStr{
"test_string": "hello",
"test_int": int64(42),
"test_bool": true,
"test_float": 42.1,
"test_obj": common.MapStr{
"test_obj_string": "hello, object",
},
}
It can be done with the following code:
schema := s.Schema{
"test_string": Str("testString"),
"test_int": Int("testInt"),
"test_bool": Bool("testBool"),
"test_float": Float("testFloat"),
"test_obj": s.Object{
"test_obj_string": Str("testObjString"),
},
}
schema.Apply(input)
Note that this allows parsing, renaming of fields and restructuring the result object.
Index ¶
- func Bool(key string, opts ...schema.SchemaOption) schema.Conv
- func Float(key string, opts ...schema.SchemaOption) schema.Conv
- func Int(key string, opts ...schema.SchemaOption) schema.Conv
- func Str(key string, opts ...schema.SchemaOption) schema.Conv
- func Time(layout, key string, opts ...schema.SchemaOption) schema.Conv
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
func Bool(key string, opts ...schema.SchemaOption) schema.Conv
Bool creates a Conv object for parsing booleans
func Float ¶
func Float(key string, opts ...schema.SchemaOption) schema.Conv
Float creates a Conv object for parsing floats
func Int ¶
func Int(key string, opts ...schema.SchemaOption) schema.Conv
Int creates a Conv object for parsing integers
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.