enabling prometheus metrics should be a config option

This commit is contained in:
Chelsea Holland Komlo 2017-09-11 13:47:44 +00:00
parent d8e9f2fef7
commit 035fab0c8d
6 changed files with 14 additions and 3 deletions

View File

@ -663,9 +663,11 @@ func (c *Command) setupTelemetry(config *Config) (*metrics.InmemSink, error) {
}
// Configure the prometheus sink
promSink, err := prometheus.NewPrometheusSink()
if err != nil {
fanout = append(fanout, promSink)
if telConfig.PrometheusMetrics {
promSink, err := prometheus.NewPrometheusSink()
if err != nil {
fanout = append(fanout, promSink)
}
}
// Configure the datadog sink

View File

@ -92,6 +92,7 @@ acl {
telemetry {
statsite_address = "127.0.0.1:1234"
statsd_address = "127.0.0.1:2345"
prometheus_metrics = true
disable_hostname = true
collection_interval = "3s"
publish_allocation_metrics = true

View File

@ -356,6 +356,7 @@ type Telemetry struct {
StatsiteAddr string `mapstructure:"statsite_address"`
StatsdAddr string `mapstructure:"statsd_address"`
DataDogAddr string `mapstructure:"datadog_address"`
PrometheusMetrics bool `mapstructure:"prometheus_metrics"`
DisableHostname bool `mapstructure:"disable_hostname"`
UseNodeName bool `mapstructure:"use_node_name"`
CollectionInterval string `mapstructure:"collection_interval"`
@ -1148,6 +1149,9 @@ func (a *Telemetry) Merge(b *Telemetry) *Telemetry {
if b.DataDogAddr != "" {
result.DataDogAddr = b.DataDogAddr
}
if b.PrometheusMetrics {
result.PrometheusMetrics = b.PrometheusMetrics
}
if b.DisableHostname {
result.DisableHostname = true
}

View File

@ -620,6 +620,7 @@ func parseTelemetry(result **Telemetry, list *ast.ObjectList) error {
"publish_allocation_metrics",
"publish_node_metrics",
"datadog_address",
"prometheus_metrics",
"circonus_api_token",
"circonus_api_app",
"circonus_api_url",

View File

@ -113,6 +113,7 @@ func TestConfig_Parse(t *testing.T) {
Telemetry: &Telemetry{
StatsiteAddr: "127.0.0.1:1234",
StatsdAddr: "127.0.0.1:2345",
PrometheusMetrics: true,
DisableHostname: true,
UseNodeName: false,
CollectionInterval: "3s",

View File

@ -54,6 +54,7 @@ func TestConfig_Merge(t *testing.T) {
StatsiteAddr: "127.0.0.1:8125",
StatsdAddr: "127.0.0.1:8125",
DataDogAddr: "127.0.0.1:8125",
PrometheusMetrics: true,
DisableHostname: false,
DisableTaggedMetrics: true,
BackwardsCompatibleMetrics: true,
@ -182,6 +183,7 @@ func TestConfig_Merge(t *testing.T) {
StatsiteAddr: "127.0.0.2:8125",
StatsdAddr: "127.0.0.2:8125",
DataDogAddr: "127.0.0.1:8125",
PrometheusMetrics: true,
DisableHostname: true,
PublishNodeMetrics: true,
PublishAllocationMetrics: true,