From c6504f3418a12eee569ad55ac496298e3509e058 Mon Sep 17 00:00:00 2001 From: matt maier Date: Wed, 9 Nov 2016 15:12:30 -0500 Subject: [PATCH] Update Circonus integration expose Check Display Name and Check Tags configuration options. --- command/agent/command.go | 8 ++------ command/agent/config.go | 13 +++++++++++++ command/agent/config_parse.go | 2 ++ command/agent/config_test.go | 4 ++++ .../docs/agent/configuration/telemetry.html.md | 7 +++++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/command/agent/command.go b/command/agent/command.go index 9b1348c94..589576ee4 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -656,6 +656,8 @@ func (c *Command) setupTelemetry(config *Config) error { cfg.CheckManager.Check.ForceMetricActivation = telConfig.CirconusCheckForceMetricActivation cfg.CheckManager.Check.InstanceID = telConfig.CirconusCheckInstanceID cfg.CheckManager.Check.SearchTag = telConfig.CirconusCheckSearchTag + cfg.CheckManager.Check.Tags = telConfig.CirconusCheckTags + cfg.CheckManager.Check.DisplayName = telConfig.CirconusCheckDisplayName cfg.CheckManager.Broker.ID = telConfig.CirconusBrokerID cfg.CheckManager.Broker.SelectTag = telConfig.CirconusBrokerSelectTag @@ -663,12 +665,6 @@ func (c *Command) setupTelemetry(config *Config) error { cfg.CheckManager.API.TokenApp = "nomad" } - if cfg.CheckManager.Check.InstanceID == "" { - if config.NodeName != "" && config.Datacenter != "" { - cfg.CheckManager.Check.InstanceID = fmt.Sprintf("%s:%s", config.NodeName, config.Datacenter) - } - } - if cfg.CheckManager.Check.SearchTag == "" { cfg.CheckManager.Check.SearchTag = "service:nomad" } diff --git a/command/agent/config.go b/command/agent/config.go index b98784690..bf3ea22a7 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -319,6 +319,13 @@ type Telemetry struct { // narrow down the search results when neither a Submission URL or Check ID is provided. // Default: service:app (e.g. service:nomad) CirconusCheckSearchTag string `mapstructure:"circonus_check_search_tag"` + // CirconusCheckTags is a comma separated list of tags to apply to the check. Note that + // the value of CirconusCheckSearchTag will always be added to the check. + // Default: none + CirconusCheckTags string `mapstructure:"circonus_check_tags"` + // CirconusCheckDisplayName is the name for the check which will be displayed in the Circonus UI. + // Default: value of CirconusCheckInstanceID + CirconusCheckDisplayName string `mapstructure:"circonus_check_display_name"` // CirconusBrokerID is an explicit broker to use when creating a new check. The numeric portion // of broker._cid. If metric management is enabled and neither a Submission URL nor Check ID // is provided, an attempt will be made to search for an existing check using Instance ID and @@ -832,6 +839,12 @@ func (a *Telemetry) Merge(b *Telemetry) *Telemetry { if b.CirconusCheckSearchTag != "" { result.CirconusCheckSearchTag = b.CirconusCheckSearchTag } + if b.CirconusCheckTags != "" { + result.CirconusCheckTags = b.CirconusCheckTags + } + if b.CirconusCheckDisplayName != "" { + result.CirconusCheckDisplayName = b.CirconusCheckDisplayName + } if b.CirconusBrokerID != "" { result.CirconusBrokerID = b.CirconusBrokerID } diff --git a/command/agent/config_parse.go b/command/agent/config_parse.go index 701c9bfa0..0993abf8f 100644 --- a/command/agent/config_parse.go +++ b/command/agent/config_parse.go @@ -540,6 +540,8 @@ func parseTelemetry(result **Telemetry, list *ast.ObjectList) error { "circonus_check_force_metric_activation", "circonus_check_instance_id", "circonus_check_search_tag", + "circonus_check_display_name", + "circonus_check_tags", "circonus_broker_id", "circonus_broker_select_tag", } diff --git a/command/agent/config_test.go b/command/agent/config_test.go index 40c9eca27..453d7250c 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -47,6 +47,8 @@ func TestConfig_Merge(t *testing.T) { CirconusCheckForceMetricActivation: "true", CirconusCheckInstanceID: "node1:nomadic", CirconusCheckSearchTag: "service:nomadic", + CirconusCheckDisplayName: "node1:nomadic", + CirconusCheckTags: "cat1:tag1,cat2:tag2", CirconusBrokerID: "0", CirconusBrokerSelectTag: "dc:dc1", }, @@ -162,6 +164,8 @@ func TestConfig_Merge(t *testing.T) { CirconusCheckForceMetricActivation: "false", CirconusCheckInstanceID: "node2:nomad", CirconusCheckSearchTag: "service:nomad", + CirconusCheckDisplayName: "node2:nomad", + CirconusCheckTags: "cat1:tag1,cat2:tag2", CirconusBrokerID: "1", CirconusBrokerSelectTag: "dc:dc2", }, diff --git a/website/source/docs/agent/configuration/telemetry.html.md b/website/source/docs/agent/configuration/telemetry.html.md index bbab67a24..896fd4822 100644 --- a/website/source/docs/agent/configuration/telemetry.html.md +++ b/website/source/docs/agent/configuration/telemetry.html.md @@ -135,6 +135,13 @@ These `telemetry` parameters apply to search results when neither a Submission URL or Check ID is provided. By default, this is set to service:app (e.g. "service:nomad"). +- `circonus_check_display_name` `(string: "")` - Specifies a name to give a + check when it is created. This name is displayed in the Circonus UI Checks + list. + +- `circonus_check_tags` `(string: "")` - Comma separated list of additional + tags to add to a check when it is created. + - `circonus_broker_id` `(string: "")` - Specifies the ID of a specific Circonus Broker to use when creating a new check. The numeric portion of `broker._cid` field in a Broker API object. If metric management is enabled and neither a