schema

package
Version: v5.6.16+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package schema contains helper utilities to parse, convert, rename, and reorganize data from the format returned by the various monitored systems to the data model used by Metricbeat.

See the docs in the mapstrstr and mapstriface sub-packages for usage examples.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conv

type Conv struct {
	Func     Converter // Convertor function
	Key      string    // The key in the data map
	Optional bool      // Whether to log errors if the key is not found
}

A Conv object represents a conversion mechanism from the data map to the event map.

func Optional

func Optional(c Conv) Conv

The optional flag suppresses the error message in case the key doesn't exist or results in an error.

func SetOptions

func SetOptions(c Conv, opts []SchemaOption) Conv

setOptions adds the optional flags to the Conv object

func (Conv) HasKey

func (conv Conv) HasKey(key string) bool

func (Conv) Map

func (conv Conv) Map(key string, event common.MapStr, data map[string]interface{})

Map applies the conversion on the data and adds the result to the event on the key.

type Converter

type Converter func(key string, data map[string]interface{}) (interface{}, error)

Convertor function type

type Mapper

type Mapper interface {
	// Map applies the Mapper conversion on the data and adds the result
	// to the event on the key.
	Map(key string, event common.MapStr, data map[string]interface{})

	HasKey(key string) bool
}

Mapper interface represents a valid type to be used in a schema.

type Object

type Object map[string]Mapper

implements Mapper interface for structure

func (Object) HasKey

func (o Object) HasKey(key string) bool

func (Object) Map

func (o Object) Map(key string, event common.MapStr, data map[string]interface{})

type Schema

type Schema map[string]Mapper

Schema describes how a map[string]interface{} object can be parsed and converted into an event. The conversions can be described using an (optionally nested) common.MapStr that contains Conv objects.

func (Schema) Apply

func (s Schema) Apply(data map[string]interface{}) common.MapStr

Apply converts the fields extracted from data, using the schema, into a new map.

func (Schema) ApplyTo

func (s Schema) ApplyTo(event common.MapStr, data map[string]interface{}) common.MapStr

ApplyTo adds the fields extracted from data, converted using the schema, to the event map.

func (Schema) HasKey

func (s Schema) HasKey(key string) bool

HasKey checks if the key is part of the schema

type SchemaOption

type SchemaOption func(c Conv) Conv

SchemaOption is for adding optional parameters to the conversion functions

Source Files

Directories

Path Synopsis
Package mapstriface contains utilities for transforming map[string]interface{} objects into metricbeat events.
Package mapstriface contains utilities for transforming map[string]interface{} objects into metricbeat events.
Package mapstrstr contains utilities for transforming map[string]string objects into metricbeat events.
Package mapstrstr contains utilities for transforming map[string]string objects into metricbeat events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL