Exemple #1
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	workers = utils.EnvInt("LOCAL_WORKERS", 2)
	processInterval = utils.EnvInt("POSTGRES_INTERVAL", 5)
	numPartitions = utils.EnvUint64("NUM_OUTLET_PARTITIONS", 1)
	lockTTL = utils.EnvUint64("LOCK_TTL", 30)
}
Exemple #2
0
func main() {
	concurrency := utils.EnvInt("LOCAL_WORKERS", 2)
	numPartitions := utils.EnvUint64("NUM_OUTLET_PARTITIONS", 1)
	server, pass, err := utils.ParseRedisUrl()
	if err != nil {
		log.Fatal(err)
	}
	rs := store.NewRedisStore(server, pass, numPartitions, concurrency*2)

	rdr := outlet.NewBucketReader(1000)
	rdr.NumScanners = concurrency
	rdr.NumOutlets = concurrency
	rdr.Store = rs
	rdr.Interval = time.Millisecond * 500

	l := outlet.NewLibratoOutlet(1000, 1000, 1000)
	l.Reader = rdr
	l.NumOutlets = concurrency
	l.NumConverters = concurrency
	l.Retries = 2
	l.User = utils.EnvString("LIBRATO_USER", "")
	l.Pass = utils.EnvString("LIBRATO_TOKEN", "")
	l.Start()
	select {}
}
Exemple #3
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	port = utils.EnvString("PORT", "8000")
	workers = utils.EnvInt("LOCAL_WORKERS", 2)
	reqBuffer = utils.EnvInt("REQUEST_BUFFER", 1000)
	flushInterval = utils.EnvInt("FLUSH_INTERVAL", 1)
	numPartitions = utils.EnvUint64("NUM_OUTLET_PARTITIONS", 1)
}
Exemple #4
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	workers = utils.EnvInt("LOCAL_WORKERS", 2)
	processInterval = utils.EnvInt("LIBRATO_INTERVAL", 5)
	numPartitions = utils.EnvUint64("NUM_OUTLET_PARTITIONS", 1)
	globalTokenUser = utils.EnvString("LIBRATO_USER", "")
	globalTokenPass = utils.EnvString("LIBRATO_TOKEN", "")
	lockTTL = utils.EnvUint64("LOCK_TTL", 30)

	http.DefaultTransport = &http.Transport{
		DisableKeepAlives: true,
		Dial: func(n, a string) (net.Conn, error) {
			c, err := net.DialTimeout(n, a, time.Second*5)
			if err != nil {
				return c, err
			}
			return c, c.SetDeadline(time.Now().Add(time.Second * 7))
		},
	}
}
Exemple #5
0
func main() {
	// The number of partitions that our backends support.
	numPartitions := utils.EnvUint64("NUM_OUTLET_PARTITIONS", 1)
	// The bucket.Store struct will initialize a redis pool for us.
	maxRedisConn := utils.EnvInt("OUTLET_C", 2) + 100
	// We use the store to Put buckets into redis.
	server, pass, err := utils.ParseRedisUrl()
	if err != nil {
		log.Fatal(err)
	}
	rs := store.NewRedisStore(server, pass, numPartitions, maxRedisConn)

	reqBuf := utils.EnvInt("REQUEST_BUFFER", 1000)
	recv := receiver.NewReceiver(reqBuf, reqBuf)
	recv.FlushInterval = time.Millisecond * 200
	recv.NumOutlets = utils.EnvInt("OUTLET_C", 100)
	recv.NumAcceptors = utils.EnvInt("ACCEPT_C", 100)
	recv.Store = rs
	recv.Start()
	go recv.Report()

	http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
		healthCheck(w, r, rs)
	})
	http.HandleFunc("/logs", func(w http.ResponseWriter, r *http.Request) {
		recvLogs(w, r, recv)
	})

	httpOutlet := new(outlet.HttpOutlet)
	httpOutlet.Store = rs
	http.HandleFunc("/metrics", func(w http.ResponseWriter, r *http.Request) {
		httpOutlet.ServeReadBucket(w, r)
	})

	port := utils.EnvString("PORT", "8000")
	err = http.ListenAndServe(":"+port, nil)
	if err != nil {
		fmt.Printf("error=%s msg=%q\n", err, "Unable to start http server.")
		os.Exit(1)
	}
	fmt.Printf("at=l2met-initialized port=%s\n", port)
}
Exemple #6
0
func main() {
	// The number of partitions that our backends support.
	numPartitions := utils.EnvUint64("NUM_OUTLET_PARTITIONS", 1)
	// The bucket.Store struct will initialize a redis pool for us.
	maxRedisConn := utils.EnvInt("OUTLET_C", 2) + 100
	// We use the store to Put buckets into redis.
	server, pass, err := utils.ParseRedisUrl()
	if err != nil {
		log.Fatal(err)
	}
	rs := store.NewRedisStore(server, pass, numPartitions, maxRedisConn)

	interval := time.Millisecond * 200
	rdr := &outlet.BucketReader{Store: rs, Interval: interval}

	g := outlet.NewGraphiteOutlet()
	g.Reader = rdr
	g.ApiToken = utils.EnvString("GRAPHITE_API_TOKEN", "")
	g.Start()
	select {}
}