Skip to content

Commit

Permalink
Merge pull request #8 from rusenask/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Karolis Rusenas committed Nov 27, 2015
2 parents eed900a + 2a7ecc4 commit 89a3c8e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 94 deletions.
32 changes: 0 additions & 32 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,16 @@ app:
- .:/app:rw
links:
- redis:redis
- influx:influx
ports:
- "8500:8500"
- "8888:8888"
environment:
- RedisAddress=redis:6379
- RedisPassword=very_secret
- InfluxAddress=influx
- InfluxDBName=events
- INFLUX_USER=root
- INFLUX_PWD=root

redis:
image: tutum/redis
environment:
- REDIS_PASS=very_secret
- REDIS_MAXMEMORY_POLICY="allkeys-lru"
- REDIS_MAXMEMORY="512mb"

influx:
image: tutum/influxdb:0.9
environment:
- ADMIN_USER=root
- INFLUXDB_INIT_PWD=root
- PRE_CREATE_DB=events
ports:
- "8083:8083"
- "8086:8086"

grafana:
image: tutum/grafana
links:
- influx:influx
ports:
- "80:80"
environment:
- HTTP_USER=grafanauser
- HTTP_PASS=grafanapass
- INFLUXDB_PROTO=http
- INFLUXDB_HOST=influx
- INFLUXDB_PORT=8086
- INFLUXDB_NAME=logrus
- INFLUXDB_USER=root
- INFLUXDB_PASS=root
- INFLUXDB_IS_GRAFANADB=true
57 changes: 0 additions & 57 deletions genproxy.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package main

import (
"github.com/Abramovic/logrus_influxdb"
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/negroni"
"github.com/elazarl/goproxy"
_ "github.com/influxdb/influxdb/client/v2"
"github.com/meatballhat/negroni-logrus"

"errors"
"flag"
"fmt"
"net/http"
"os"
"regexp"
"time"
)

const DefaultPort = ":8500"
Expand All @@ -29,15 +25,6 @@ func main() {
// getting settings
initSettings()

// adding influxdb hook
err := addInfluxLoggingHook()

if err != nil {
log.WithFields(log.Fields{
"Error": err.Error(),
}).Error("Failed to add InfluxDB hook")
}

// overriding default settings
AppConfig.recordState = *record

Expand Down Expand Up @@ -145,47 +132,3 @@ func (d *DBClient) startAdminInterface() {

n.Run(AppConfig.adminInterface)
}

func addInfluxLoggingHook() error {
// checking whether app should send logs to influxdb
influxdbAddress := os.Getenv("InfluxAddress")

if influxdbAddress != "" {

// getting default events database
influxDatabaseName := os.Getenv("InfluxDBName")
if influxDatabaseName == "" {
influxDatabaseName = "events"
}

var maxRetries = 10
var errMaxRetriesReached = errors.New("exceeded retry limit")
var err error

attempt := 1
for {
hook, err := logrus_influxdb.NewInfluxDBHook(influxdbAddress, influxDatabaseName, nil)
log.Info("Hook created, next step - adding to logrus")
if err == nil {
log.AddHook(hook)
log.Info("Hook to InfluxDB added successfuly")
break
}
attempt++
log.Warn("Failed to connect to InfluxDB, maybe it is not running yet? Waiting...")
time.Sleep(5 * time.Second)
if attempt > maxRetries {
log.WithFields(log.Fields{
"Error": err.Error(),
"InfluxDB": influxdbAddress,
"InfluxDatabaseName": influxDatabaseName,
}).Error("Unable to add InfluxDB hook")
return errMaxRetriesReached
}
}
return err

} else {
return nil
}
}
6 changes: 1 addition & 5 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ import:
- package: github.com/elazarl/goproxy
- package: github.com/meatballhat/negroni-logrus
- package: github.com/codegangsta/negroni
- package: github.com/go-zoo/bone
- package: github.com/influxdb/influxdb
subpackages:
- /client/v2
- package: github.com/Abramovic/logrus_influxdb
- package: github.com/go-zoo/bone

0 comments on commit 89a3c8e

Please sign in to comment.