template

package
v6.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultConfig for index template
	DefaultConfig = TemplateConfig{
		Enabled: true,
		Fields:  "fields.yml",
	}
)

Functions

This section is empty.

Types

type ESClient

type ESClient interface {
	LoadJSON(path string, json map[string]interface{}) ([]byte, error)
	Request(method, path string, pipeline string, params map[string]string, body interface{}) (int, []byte, error)
	GetVersion() string
}

TemplateLoader is a subset of the Elasticsearch client API capable of loading the template.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

func NewLoader

func NewLoader(cfg *common.Config, client ESClient, beatInfo beat.Info) (*Loader, error)

func (*Loader) CheckTemplate

func (l *Loader) CheckTemplate(templateName string) bool

CheckTemplate checks if a given template already exist. It returns true if and only if Elasticsearch returns with HTTP status code 200.

func (*Loader) Load

func (l *Loader) Load() error

Load checks if the index mapping template should be loaded In case the template is not already loaded or overwriting is enabled, the template is written to index

func (*Loader) LoadTemplate

func (l *Loader) LoadTemplate(templateName string, template map[string]interface{}) error

LoadTemplate loads a template into Elasticsearch overwriting the existing template if it exists. If you wish to not overwrite an existing template then use CheckTemplate prior to calling this method.

type Processor

type Processor struct {
	EsVersion common.Version
}

type Template

type Template struct {
	// contains filtered or unexported fields
}

func New

func New(beatVersion string, beatName string, esVersion string, config TemplateConfig) (*Template, error)

New creates a new template instance

func (*Template) GetName

func (t *Template) GetName() string

GetName returns the name of the template

func (*Template) GetPattern

func (t *Template) GetPattern() string

GetPattern returns the pattern of the template

func (*Template) Load

func (t *Template) Load(file string) (common.MapStr, error)

Load the given input and generates the input based on it

type TemplateConfig

type TemplateConfig struct {
	Enabled   bool             `config:"enabled"`
	Name      string           `config:"name"`
	Pattern   string           `config:"pattern"`
	Fields    string           `config:"fields"`
	Overwrite bool             `config:"overwrite"`
	Settings  TemplateSettings `config:"settings"`
}

type TemplateSettings

type TemplateSettings struct {
	Index  map[string]interface{} `config:"index"`
	Source map[string]interface{} `config:"_source"`
}

Jump to

Keyboard shortcuts

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