示例#1
0
func init() {
	config.RegistOutputHandler(ModuleName, func(mapraw map[string]interface{}) (retconf config.TypeOutputConfig, err error) {
		conf := DefaultOutputConfig()
		if err = config.ReflectConfig(mapraw, &conf); err != nil {
			return
		}

		// elastic
		elasticurl, err := url.Parse(conf.URL)
		if err != nil {
			err = errutil.New("parse elastic url failed", err)
			return
		}

		conf.conn = elastigo.NewConn()
		conf.conn.Protocol = elasticurl.Scheme
		conf.conn.Domain = strings.Split(elasticurl.Host, ":")[0]
		conf.conn.Port = strings.Split(elasticurl.Host, ":")[1]
		if _, err = conf.conn.Health(); err != nil {
			err = errutil.New("test elastic connection failed", err)
			return
		}

		retconf = &conf
		return
	})
}
示例#2
0
func init() {
	config.RegistOutputHandler(ModuleName, func(mapraw map[string]interface{}) (retconf config.TypeOutputConfig, err error) {
		conf := DefaultOutputConfig()
		if err = config.ReflectConfig(mapraw, &conf); err != nil {
			return
		}

		retconf = &conf
		return
	})
}