Skip to content

Commit

Permalink
Merge pull request #574 from joyent-compute/circonus-submission-url
Browse files Browse the repository at this point in the history
metrics.circonus: Add support for circonus.submissionurl
  • Loading branch information
magiconair authored Nov 20, 2018
2 parents 92c6115 + 87f6813 commit 1f3ad2e
Show file tree
Hide file tree
Showing 123 changed files with 35,050 additions and 1,305 deletions.
11 changes: 6 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ type Runtime struct {
}

type Circonus struct {
APIKey string
APIApp string
APIURL string
CheckID string
BrokerID string
APIKey string
APIApp string
APIURL string
CheckID string
BrokerID string
SubmissionURL string
}

type Log struct {
Expand Down
1 change: 1 addition & 0 deletions config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
f.StringVar(&cfg.Metrics.Circonus.APIURL, "metrics.circonus.apiurl", defaultConfig.Metrics.Circonus.APIURL, "Circonus API URL")
f.StringVar(&cfg.Metrics.Circonus.BrokerID, "metrics.circonus.brokerid", defaultConfig.Metrics.Circonus.BrokerID, "Circonus Broker ID")
f.StringVar(&cfg.Metrics.Circonus.CheckID, "metrics.circonus.checkid", defaultConfig.Metrics.Circonus.CheckID, "Circonus Check ID")
f.StringVar(&cfg.Metrics.Circonus.SubmissionURL, "metrics.circonus.submissionurl", defaultConfig.Metrics.Circonus.SubmissionURL, "Circonus Check SubmissionURL")
f.StringVar(&cfg.Registry.Backend, "registry.backend", defaultConfig.Registry.Backend, "registry backend")
f.DurationVar(&cfg.Registry.Timeout, "registry.timeout", defaultConfig.Registry.Timeout, "timeout for registry to become available")
f.DurationVar(&cfg.Registry.Retry, "registry.retry", defaultConfig.Registry.Retry, "retry interval during startup")
Expand Down
7 changes: 7 additions & 0 deletions config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,13 @@ func TestLoad(t *testing.T) {
return cfg
},
},
{
args: []string{"-metrics.circonus.submissionurl", "value"},
cfg: func(cfg *Config) *Config {
cfg.Metrics.Circonus.SubmissionURL = "value"
return cfg
},
},
{
args: []string{"-runtime.gogc", "555"},
cfg: func(cfg *Config) *Config {
Expand Down
3 changes: 2 additions & 1 deletion docs/content/ref/metrics.circonus.apikey.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ title: "metrics.circonus.apikey"

`metrics.circonus.apikey` configures the API token key to use when
submitting metrics to Circonus. See: https://login.circonus.com/user/tokens
This is required when [metrics.target](/ref/metrics.target/) is set to `circonus`.
This is optional when [metrics.target](/ref/metrics.target/) is set to `circonus`
but [metrics.circonus.submissionurl](/ref/metrics.circonus.submissionurl/) is specified}

The default is

Expand Down
17 changes: 17 additions & 0 deletions docs/content/ref/metrics.circonus.submissionurl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "metrics.circonus.submissionurl"
---

`metrics.circonus.submissionurl` configures a specific check submission url
for a Check API object of a previously created HTTPTRAP check.

This is optional when [metrics.target](/ref/metrics.target/) is set to `circonus`
but [metrics.circonus.apikey](/ref/metrics.circonus.apikey/) is specified}.

#### Example

`http://127.0.0.1:2609/write/fabio`

The default is

metrics.circonus.submissionurl =
18 changes: 16 additions & 2 deletions fabio.properties
Original file line number Diff line number Diff line change
Expand Up @@ -900,13 +900,27 @@

# metrics.circonus.apikey configures the API token key to use when
# submitting metrics to Circonus. See: https://login.circonus.com/user/tokens
# This is required when ${metrics.target} is set to "circonus".
# This is optional when ${metrics.target} is set to "circonus" but
# ${metrics.circonus.submissionurl is specified}.
#
# The default is
#
# metrics.circonus.apikey =


# metrics.circonus.submissionurl configures a specific check submission url
# for a Check API object of a previously created HTTPTRAP check
# This is optional when ${metrics.target} is set to "circonus" but
# ${metrics.circonus.apikey is specified}.
# #### Example
#
# `http://127.0.0.1:2609/write/fabio`
#
# The default is
#
# metrics.circonus.submissionurl =


# metrics.circonus.apiapp configures the API token app to use when
# submitting metrics to Circonus. See: https://login.circonus.com/user/tokens
# This is optional when ${metrics.target} is set to "circonus".
Expand Down Expand Up @@ -1080,4 +1094,4 @@
# This is used to specify additional information when sending spans to a collector
#
# The default is
# tracing.SpanHost = localhost:9998
# tracing.SpanHost = localhost:9998
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/armon/go-radix v1.0.0 // indirect
github.com/aws/aws-sdk-go v1.15.76 // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/circonus-labs/circonus-gometrics v1.0.0
github.com/circonus-labs/circonus-gometrics v2.2.4+incompatible
github.com/circonus-labs/circonusllhist v0.0.0-20160526043813-d724266ae527 // indirect
github.com/coreos/bbolt v1.3.0 // indirect
github.com/coreos/etcd v3.3.10+incompatible // indirect
Expand All @@ -40,11 +40,10 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.5.1 // indirect
github.com/hashicorp/consul v1.4.0
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect
github.com/hashicorp/go-cleanhttp v0.0.0-20160407174126-ad28ea4487f0 // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-msgpack v0.0.0-20150518234257-fa3f63826f7c // indirect
github.com/hashicorp/go-multierror v0.0.0-20150916205742-d30f09973e19 // indirect
github.com/hashicorp/go-retryablehttp v0.0.0-20160810172255-f4ed9b0fa01a // indirect
github.com/hashicorp/go-retryablehttp v0.5.0 // indirect
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 // indirect
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 // indirect
github.com/hashicorp/hcl v0.0.0-20160607001940-d7400db7143f // indirect
Expand Down Expand Up @@ -84,6 +83,7 @@ require (
github.com/sirupsen/logrus v1.2.0 // indirect
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 // indirect
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 // indirect
github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f // indirect
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 // indirect
go.opencensus.io v0.18.0 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ github.com/census-instrumentation/opencensus-proto v0.0.2-0.20180913191712-f303a
github.com/census-instrumentation/opencensus-proto v0.0.2-0.20180913191712-f303ae3f8d6a/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/circonus-labs/circonus-gometrics v1.0.0 h1:pMILaNgfEYrx8qdBukpsVU3muDkqfyPK/kmz1Ww4tQ4=
github.com/circonus-labs/circonus-gometrics v1.0.0/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonus-gometrics v2.2.4+incompatible h1:+ZwGzyJGsOwSxIEDDOXzPagR167tQak/1P5wBwH+/dM=
github.com/circonus-labs/circonus-gometrics v2.2.4+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.0.0-20160526043813-d724266ae527 h1:g5Ns3zGpLJ0T+1YJ0d3VVPrlMMyFHXV4x82xNgIT9z0=
github.com/circonus-labs/circonusllhist v0.0.0-20160526043813-d724266ae527/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand Down Expand Up @@ -99,6 +101,8 @@ github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce h1:prjrVgOk2Yg6w
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-cleanhttp v0.0.0-20160407174126-ad28ea4487f0 h1:2l0haPDqCzZEO160UR5DSrrl8RWptFCoxFsSbRLJBaI=
github.com/hashicorp/go-cleanhttp v0.0.0-20160407174126-ad28ea4487f0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-msgpack v0.0.0-20150518234257-fa3f63826f7c h1:BTAbnbegUIMB6xmQCwWE8yRzbA4XSpnZY5hvRJC188I=
Expand All @@ -107,6 +111,8 @@ github.com/hashicorp/go-multierror v0.0.0-20150916205742-d30f09973e19 h1:gb61U/o
github.com/hashicorp/go-multierror v0.0.0-20150916205742-d30f09973e19/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
github.com/hashicorp/go-retryablehttp v0.0.0-20160810172255-f4ed9b0fa01a h1:EyMMojcpa0OFWj8zjSPQ+8SsBVm+hMDqQlxjGdCxUDQ=
github.com/hashicorp/go-retryablehttp v0.0.0-20160810172255-f4ed9b0fa01a/go.mod h1:fXcdFsQoipQa7mwORhKad5jmDCeSy/RCGzWA08PO0lM=
github.com/hashicorp/go-retryablehttp v0.5.0 h1:aVN0FYnPwAgZI/hVzqwfMiM86ttcHTlQKbBVeVmXPIs=
github.com/hashicorp/go-retryablehttp v0.5.0/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 h1:9HVkPxOpo+yO93Ah4yrO67d/qh0fbLLWbKqhYjyHq9A=
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90/go.mod h1:o4zcYY1e0GEZI6eSEr+43QDYmuGglw1qSO6qdHUHCgg=
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 h1:7YOlAIO2YWnJZkQp7B5eFykaIY7C9JndqAFQyVV5BhM=
Expand Down Expand Up @@ -212,6 +218,8 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 h1:lYIiVDtZnyTWlNwiAxLj0bbpTcx1BWCFhXjfsvmPdNc=
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f h1:y3Vj7GoDdcBkxFa2RUUFKM25TrBbWVDnjRDI0u975zQ=
github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4MEFmbnK4h3BD7AUmskWv2+EeZJCCs=
Expand Down
5 changes: 3 additions & 2 deletions metrics/circonus.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func circonusRegistry(prefix string, circ config.Circonus, interval time.Duratio
var initError error

once.Do(func() {
if circ.APIKey == "" {
initError = errors.New("metrics: Circonus API token key")
if circ.APIKey == "" && circ.SubmissionURL == "" {
initError = errors.New("metrics: Circonus API token key or SubmissionURL")
return
}

Expand All @@ -41,6 +41,7 @@ func circonusRegistry(prefix string, circ config.Circonus, interval time.Duratio

cfg := &cgm.Config{}

cfg.CheckManager.Check.SubmissionURL = circ.SubmissionURL
cfg.CheckManager.API.TokenKey = circ.APIKey
cfg.CheckManager.API.TokenApp = circ.APIApp
cfg.CheckManager.API.URL = circ.APIURL
Expand Down
15 changes: 8 additions & 7 deletions metrics/circonus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@ func TestTimer(t *testing.T) {
func TestAll(t *testing.T) {
start := time.Now()

if os.Getenv("CIRCONUS_API_TOKEN") == "" {
t.Skip("skipping test; $CIRCONUS_API_TOKEN not set")
if os.Getenv("CIRCONUS_API_TOKEN") == "" && os.Getenv("CIRCONUS_SUBMISSION_URL") == "" {
t.Skip("skipping test; $CIRCONUS_API_TOKEN or $CIRCONUS_SUBMISSION_URL not set")
}

t.Log("Testing cgm functionality -- this *will* create/use a check")

cfg := config.Circonus{
APIKey: os.Getenv("CIRCONUS_API_TOKEN"),
APIApp: os.Getenv("CIRCONUS_API_APP"),
APIURL: os.Getenv("CIRCONUS_API_URL"),
CheckID: os.Getenv("CIRCONUS_CHECK_ID"),
BrokerID: os.Getenv("CIRCONUS_BROKER_ID"),
SubmissionURL: os.Getenv("CIRCONUS_SUBMISSION_URL"),
APIKey: os.Getenv("CIRCONUS_API_TOKEN"),
APIApp: os.Getenv("CIRCONUS_API_APP"),
APIURL: os.Getenv("CIRCONUS_API_URL"),
CheckID: os.Getenv("CIRCONUS_CHECK_ID"),
BrokerID: os.Getenv("CIRCONUS_BROKER_ID"),
}

interval, err := time.ParseDuration("60s")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1f3ad2e

Please sign in to comment.