Skip to content

Commit 89a3c8e

Browse files
author
Karolis Rusenas
committed
Merge pull request #8 from rusenask/develop
Develop
2 parents eed900a + 2a7ecc4 commit 89a3c8e

File tree

3 files changed

+1
-94
lines changed

3 files changed

+1
-94
lines changed

docker-compose.yml

-32
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,16 @@ app:
44
- .:/app:rw
55
links:
66
- redis:redis
7-
- influx:influx
87
ports:
98
- "8500:8500"
109
- "8888:8888"
1110
environment:
1211
- RedisAddress=redis:6379
1312
- RedisPassword=very_secret
14-
- InfluxAddress=influx
15-
- InfluxDBName=events
16-
- INFLUX_USER=root
17-
- INFLUX_PWD=root
1813

1914
redis:
2015
image: tutum/redis
2116
environment:
2217
- REDIS_PASS=very_secret
2318
- REDIS_MAXMEMORY_POLICY="allkeys-lru"
2419
- REDIS_MAXMEMORY="512mb"
25-
26-
influx:
27-
image: tutum/influxdb:0.9
28-
environment:
29-
- ADMIN_USER=root
30-
- INFLUXDB_INIT_PWD=root
31-
- PRE_CREATE_DB=events
32-
ports:
33-
- "8083:8083"
34-
- "8086:8086"
35-
36-
grafana:
37-
image: tutum/grafana
38-
links:
39-
- influx:influx
40-
ports:
41-
- "80:80"
42-
environment:
43-
- HTTP_USER=grafanauser
44-
- HTTP_PASS=grafanapass
45-
- INFLUXDB_PROTO=http
46-
- INFLUXDB_HOST=influx
47-
- INFLUXDB_PORT=8086
48-
- INFLUXDB_NAME=logrus
49-
- INFLUXDB_USER=root
50-
- INFLUXDB_PASS=root
51-
- INFLUXDB_IS_GRAFANADB=true

genproxy.go

-57
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
package main
22

33
import (
4-
"github.com/Abramovic/logrus_influxdb"
54
log "github.com/Sirupsen/logrus"
65
"github.com/codegangsta/negroni"
76
"github.com/elazarl/goproxy"
8-
_ "github.com/influxdb/influxdb/client/v2"
97
"github.com/meatballhat/negroni-logrus"
108

11-
"errors"
129
"flag"
1310
"fmt"
1411
"net/http"
1512
"os"
1613
"regexp"
17-
"time"
1814
)
1915

2016
const DefaultPort = ":8500"
@@ -29,15 +25,6 @@ func main() {
2925
// getting settings
3026
initSettings()
3127

32-
// adding influxdb hook
33-
err := addInfluxLoggingHook()
34-
35-
if err != nil {
36-
log.WithFields(log.Fields{
37-
"Error": err.Error(),
38-
}).Error("Failed to add InfluxDB hook")
39-
}
40-
4128
// overriding default settings
4229
AppConfig.recordState = *record
4330

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

146133
n.Run(AppConfig.adminInterface)
147134
}
148-
149-
func addInfluxLoggingHook() error {
150-
// checking whether app should send logs to influxdb
151-
influxdbAddress := os.Getenv("InfluxAddress")
152-
153-
if influxdbAddress != "" {
154-
155-
// getting default events database
156-
influxDatabaseName := os.Getenv("InfluxDBName")
157-
if influxDatabaseName == "" {
158-
influxDatabaseName = "events"
159-
}
160-
161-
var maxRetries = 10
162-
var errMaxRetriesReached = errors.New("exceeded retry limit")
163-
var err error
164-
165-
attempt := 1
166-
for {
167-
hook, err := logrus_influxdb.NewInfluxDBHook(influxdbAddress, influxDatabaseName, nil)
168-
log.Info("Hook created, next step - adding to logrus")
169-
if err == nil {
170-
log.AddHook(hook)
171-
log.Info("Hook to InfluxDB added successfuly")
172-
break
173-
}
174-
attempt++
175-
log.Warn("Failed to connect to InfluxDB, maybe it is not running yet? Waiting...")
176-
time.Sleep(5 * time.Second)
177-
if attempt > maxRetries {
178-
log.WithFields(log.Fields{
179-
"Error": err.Error(),
180-
"InfluxDB": influxdbAddress,
181-
"InfluxDatabaseName": influxDatabaseName,
182-
}).Error("Unable to add InfluxDB hook")
183-
return errMaxRetriesReached
184-
}
185-
}
186-
return err
187-
188-
} else {
189-
return nil
190-
}
191-
}

glide.yaml

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@ import:
77
- package: github.com/elazarl/goproxy
88
- package: github.com/meatballhat/negroni-logrus
99
- package: github.com/codegangsta/negroni
10-
- package: github.com/go-zoo/bone
11-
- package: github.com/influxdb/influxdb
12-
subpackages:
13-
- /client/v2
14-
- package: github.com/Abramovic/logrus_influxdb
10+
- package: github.com/go-zoo/bone

0 commit comments

Comments
 (0)