func CreateOpenTSDBSink(uri *url.URL, _ extpoints.HeapsterConf) ([]sink_api.ExternalSink, error) { host := defaultOpentsdbHost if len(uri.Host) > 0 { host = uri.Host } tsdbSink, err := new(host) if err != nil { return nil, err } glog.Infof("created opentsdb sink with host: %v", host) tsdbSink.ci = sinkutil.NewClientInitializer(sinkRegisterName, tsdbSink.setupClient, tsdbSink.ping, 10*time.Second) return []sink_api.ExternalSink{tsdbSink}, nil }
func NewFakeOpenTSDBSink(successfulPing, successfulPut bool) fakeOpenTSDBSink { client := &fakeOpenTSDBClient{ successfulPing: successfulPing, successfulPut: successfulPut, } cfg := opentsdbcfg.OpenTSDBConfig{OpentsdbHost: fakeOpenTSDBHost} return fakeOpenTSDBSink{ &openTSDBSink{ client: client, config: cfg, ci: sink_util.NewClientInitializer("test", func() error { return nil }, func() error { return nil }, time.Millisecond), }, client, } }
// Returns a fake kafka sink. func NewFakeSink() fakeKafkaSink { producer := NewFakeKafkaProducer() fakeTimeSeriesTopic := "kafkaTime-test-topic" fakeEventsTopic := "kafkaEvent-test-topic" fakesinkBrokerHosts := make([]string, 2) return fakeKafkaSink{ &kafkaSink{ producer: producer, timeSeriesTopic: fakeTimeSeriesTopic, eventsTopic: fakeEventsTopic, sinkBrokerHosts: fakesinkBrokerHosts, ci: sinkutil.NewClientInitializer("test", func() error { return nil }, func() error { return nil }, time.Millisecond), }, producer, } }
func CreateRiemannSink(uri *url.URL, _ extpoints.HeapsterConf) ([]sink_api.ExternalSink, error) { c := riemannConfig{ host: "riemann-heapster:5555", ttl: 60.0, state: "", tags: make([]string, 0), storeEvents: true, } if len(uri.Host) > 0 { c.host = uri.Host } options := uri.Query() if len(options["ttl"]) > 0 { var ttl, err = strconv.ParseFloat(options["ttl"][0], 32) if err != nil { return nil, err } c.ttl = float32(ttl) } if len(options["state"]) > 0 { c.state = options["state"][0] } if len(options["tags"]) > 0 { c.tags = options["tags"] } if len(options["storeEvents"]) > 0 { var storeEvents, err = strconv.ParseBool(options["storeEvents"][0]) if err != nil { return nil, err } c.storeEvents = storeEvents } glog.Infof("Riemann sink URI: '%+v', host: '%+v', options: '%+v', ", uri, c.host, options) rs := &riemannSink{ client: riemann_api.NewGorymanClient(c.host), config: c, } rs.ci = util.NewClientInitializer("riemann", rs.setupRiemannClient, rs.ping, 10*time.Second) runtime.SetFinalizer(rs.client, func(c riemannClient) { c.Close() }) return []sink_api.ExternalSink{rs}, nil }
func NewKafkaSink(uri *url.URL, _ extpoints.HeapsterConf) ([]sink_api.ExternalSink, error) { var kafkaSink kafkaSink opts, err := url.ParseQuery(uri.RawQuery) if err != nil { return nil, fmt.Errorf("failed to parser url's query string: %s", err) } kafkaSink.timeSeriesTopic = timeSeriesTopic if len(opts["timeseriestopic"]) > 0 { kafkaSink.timeSeriesTopic = opts["timeseriestopic"][0] } kafkaSink.eventsTopic = eventsTopic if len(opts["eventstopic"]) > 0 { kafkaSink.eventsTopic = opts["eventstopic"][0] } if len(opts["brokers"]) < 1 { return nil, fmt.Errorf("There is no broker assigned for connecting kafka broker") } kafkaSink.sinkBrokerHosts = append(kafkaSink.sinkBrokerHosts, opts["brokers"]...) glog.V(2).Infof("initializing kafka sink with brokers - %v", kafkaSink.sinkBrokerHosts) //connect to kafka cluster brokerConf := kafka.NewBrokerConf(brokerClientID) brokerConf.DialTimeout = brokerDialTimeout brokerConf.DialRetryLimit = brokerDialRetryLimit brokerConf.DialRetryWait = brokerDialRetryWait brokerConf.LeaderRetryLimit = brokerLeaderRetryLimit brokerConf.LeaderRetryWait = brokerLeaderRetryWait brokerConf.AllowTopicCreation = true // Store broker configuration. kafkaSink.brokerConf = brokerConf kafkaSink.ci = sinkutil.NewClientInitializer("kafka", kafkaSink.setupClient, kafkaSink.ping, 10*time.Second) return []sink_api.ExternalSink{&kafkaSink}, nil }