Skip to content

Commit

Permalink
changed endpoint config syntax
Browse files Browse the repository at this point in the history
simpler. Don't need to name endpoints now. No indentation necessary.
  • Loading branch information
thraxil committed Sep 17, 2017
1 parent 7985998 commit 6b61f64
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGES.org
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
defined for the endpoint)
- metric ignore list
- metric renaming
- changed endpoint config syntax
18 changes: 8 additions & 10 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,14 @@ CarbonPort = 2003
CheckInterval = 60000
Timeout = 3000

[endpoints]

[endpoints.app1]
URL = "http://localhost:14001/debug/vars"
Prefix = "apps.app1"

[endpoints.app2]
URL = "http://localhost:14002/debug/vars"
Prefix = "apps.app2"
FailureMetric = "apps.app1.failure"
[[endpoint]]
URL = "http://localhost:14001/debug/vars"
Prefix = "apps.app1"

[[endpoint]]
URL = "http://localhost:14002/debug/vars"
Prefix = "apps.app2"
FailureMetric = "apps.app1.failure"

[[rename]]
From = "BuckHashSys"
Expand Down
6 changes: 3 additions & 3 deletions samlare.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type config struct {
IgnoreMetrics []string
Renames []renameConfig

Endpoints map[string]endpointconfig
Endpoint []endpointconfig
}

func loadConfig(configFile string) (*config, error) {
Expand Down Expand Up @@ -95,8 +95,8 @@ func startEndpoints(conf *config, logger log.Logger) context.CancelFunc {

g := newGraphiteServer(conf.CarbonHost, conf.CarbonPort)

for k, endpoint := range conf.Endpoints {
elogger := log.With(logger, "endpoint", k)
for _, endpoint := range conf.Endpoint {
elogger := log.With(logger, "endpoint", endpoint.Prefix)
e := newEndpoint(endpoint, conf.CheckInterval, conf.Timeout, conf.IgnoreMetrics, conf.Renames, g, httpFetcher{}, elogger)
go e.Run(ctx)
}
Expand Down
15 changes: 6 additions & 9 deletions sample-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ To = "sys"
From = "BuckHashSys"
To = "buck_hash_sys"

[[endpoint]]
URL = "http://localhost:14001/debug/vars"
Prefix = "apps.app1"

[endpoints]

[endpoints.app1]
URL = "http://localhost:14001/debug/vars"
Prefix = "apps.app1"

[endpoints.app2]
URL = "http://localhost:14002/debug/vars"
Prefix = "apps.app2"
[[endpoint]]
URL = "http://localhost:14002/debug/vars"
Prefix = "apps.app2"

0 comments on commit 6b61f64

Please sign in to comment.