Skip to content

Commit

Permalink
Revert "Merge pull request #1378 from findkim/metrics"
Browse files Browse the repository at this point in the history
This reverts commit a6404e0, reversing
changes made to 15b9f25.
  • Loading branch information
eikenb committed Jul 23, 2020
1 parent 3250aa0 commit 6bc149b
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 1,456 deletions.
105 changes: 0 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ this functionality might prove useful.
- [Multi-phase Execution](#multi-phase-execution)
- [Running and Process Lifecycle](#running-and-process-lifecycle)
- [Debugging](#debugging)
- [Telemetry](#telemetry)
- [FAQ](#faq)
- [Contributing](#contributing)

Expand Down Expand Up @@ -625,31 +624,6 @@ template {
}
}
# These are example configurations for monitoring Consul Template metrics.
# This block is an HCL mapping to OpenTelemetry configurations for
# various exporters. Configuring telemetry is only supported in
# configuration files and not as CLI flags. Only one metric provider can
# be used at a given time. More details on the metrics collected can be found
# in the Telemetry section.
telemetry {
stdout {
reporting_interval = "60s"
pretty_print = false
do_not_print_time = false
}
dogstatsd {
// address describes the destination for exporting dogstatsd data.
// e.g., udp://host:port tcp://host:port unix:///socket/path
address = "udp://127.0.0.1:8125"
reporting_interval = "60s"
}
prometheus {
reporting_interval = "60s"
port = 8888
}
}
```

Note that not all fields are required. If you are not retrieving secrets from
Expand Down Expand Up @@ -2645,85 +2619,6 @@ $ consul-template -log-level debug ...
# ...
```

## Telemetry

Consul Template uses the [OpenTelemetry](https://opentelemetry.io/) project for its monitoring engine to collect various runtime metrics. It currently supports metrics exported to stdout, dogstatsd server, and prometheus endpoint.

### Key Metrics

These metrics offer insight into Consul Template and capture subprocess activities. The number of dependencies are aggregated from the configured templates, and metrics are collected around a dependency when it is updated from source. This is useful to correlate any upstream changes to downstream actions originating from Consul Template.

Metrics are monitored around template rendering and execution of template commands. These
metrics indicate the rendering status of a template and how long commands for a template takes
to provide insight on performance of the templates.

| Metric Name | Labels | Description |
|-|:-:|-|
| `consul-template.dependencies` | type=(consul\|vault\|local) | The number of dependencies grouped by types |
| `consul-template.dependencies_received` | type=(consul\|vault\|local), id=dependencyString | A counter of dependencies received from monitoring value changes |
| `consul-template.templates` | | The number of templates configured |
| `consul-template.templates_rendered` | id=templateID, status=(rendered\|would\|quiescence) | A counter of templates rendered |
| `consul-template.runner_actions` | action=(start\|stop\|run) | A count of runner actions |
| `consul-template.commands_exec` | status=(success\|error) | The number of commands executed after rendering templates |
| `consul-template.commands_exec_time` | id=tmplDestination | The execution time (seconds) of a template command |
| `consul-template.vault.token` | status=(configured\|renewed\|expired\|stopped) | A counter of vault token renewal statuses |

### Metric Samples

#### Stdout

```
{"time":"2020-05-05T12:02:16.028883-05:00","updates":[{"name":"consul-template.dependencies{type=consul}","min":2,"max":2,"sum":4,"count":2,"quantiles":[{"q":0.5,"v":2},{"q":0.9,"v":2},{"q":0.99,"v":2}]},{"name":"consul-template.commands_exec_time{destination=out.txt}","min":0.008301234,"max":0.008301234,"sum":0.008301234,"count":1,"quantiles":[{"q":0.5,"v":0.008301234},{"q":0.9,"v":0.008301234},{"q":0.99,"v":0.008301234}]},{"name":"consul-template.runner_actions{action=start}","sum":1},{"name":"consul-template.runner_actions{action=run}","sum":2},{"name":"consul-template.runner_actions{action=stop}","sum":1},{"name":"consul-template.templates_rendered{id=aadcafd7f28f1d9fc5e76ab2e029f844,status=rendered}","sum":1},{"name":"consul-template.dependencies_received{id=kv.block(hello),type=consul}","sum":1},{"name":"consul-template.templates","min":2,"max":2,"sum":2,"count":1,"quantiles":[{"q":0.5,"v":2},{"q":0.9,"v":2},{"q":0.99,"v":2}]},{"name":"consul-template.commands_exec{status=error}","sum":0},{"name":"consul-template.commands_exec{status=success}","sum":1}]}
```

#### DogStatsD

```
2020-05-05 11:57:46.143979 consul-template.runner_actions:1|c|#action:start
consul-template.runner_actions:2|c|#action:run
consul-template.dependencies_received:1|c|#id:kv.block(hello),type:consul
consul-template.dependencies:2|h|#type:consul
consul-template.templates:2|h
consul-template.templates_rendered:1|c|#id:aadcafd7f28f1d9fc5e76ab2e029f844,status:rendered
consul-template.commands_exec:1|c|#status:success
consul-template.commands_exec:0|c|#status:error
consul-template.commands_exec_time:0.011514017|h|#destination:out.txt
```

#### Prometheus

```
$ curl localhost:8888/metrics
# HELP consul_template_commands_exec The number of commands executed with labels status=(success|error)
# TYPE consul_template_commands_exec counter
consul_template_commands_exec{status="error"} 0
consul_template_commands_exec{status="success"} 1
# HELP consul_template_commands_exec_time The execution time (seconds) of a template command. The template destination is used as the identifier
# TYPE consul_template_commands_exec_time histogram
consul_template_commands_exec_time_bucket{destination="out.txt",le="+Inf"} 1
consul_template_commands_exec_time_sum{destination="out.txt"} 0.005063219
consul_template_commands_exec_time_count{destination="out.txt"} 1
# HELP consul_template_dependencies The number of dependencies grouped by types with labels type=(consul|vault|local)
# TYPE consul_template_dependencies histogram
consul_template_dependencies_bucket{type="consul",le="+Inf"} 2
consul_template_dependencies_sum{type="consul"} 4
consul_template_dependencies_count{type="consul"} 2
# HELP consul_template_dependencies_received A counter of dependencies received with labels type=(consul|vault|local) and id=dependencyString
# TYPE consul_template_dependencies_received counter
consul_template_dependencies_received{id="kv.block(hello)",type="consul"} 1
# HELP consul_template_runner_actions A count of runner actions with labels action=(start|stop|run)
# TYPE consul_template_runner_actions counter
consul_template_runner_actions{action="run"} 2
consul_template_runner_actions{action="start"} 1
# HELP consul_template_templates The number of templates configured.
# TYPE consul_template_templates histogram
consul_template_templates_bucket{le="+Inf"} 1
consul_template_templates_sum 2
consul_template_templates_count 1
# HELP consul_template_templates_rendered A counter of templates rendered with labels id=templateID and status=(rendered|would|quiescence)
# TYPE consul_template_templates_rendered counter
consul_template_templates_rendered{id="aadcafd7f28f1d9fc5e76ab2e029f844",status="rendered"} 1
```

## FAQ

Expand Down
8 changes: 0 additions & 8 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/hashicorp/consul-template/logging"
"github.com/hashicorp/consul-template/manager"
"github.com/hashicorp/consul-template/signals"
"github.com/hashicorp/consul-template/telemetry"
"github.com/hashicorp/consul-template/version"
)

Expand Down Expand Up @@ -103,13 +102,6 @@ func (cli *CLI) Run(args []string) int {
return ExitCodeOK
}

// Initialize telemetry
tel, err := telemetry.Init(config.Telemetry)
if err != nil {
return logError(err, ExitCodeConfigError)
}
defer tel.Stop()

// Initial runner
runner, err := manager.NewRunner(config, dry)
if err != nil {
Expand Down
23 changes: 0 additions & 23 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ type Config struct {
// Syslog is the configuration for syslog.
Syslog *SyslogConfig `mapstructure:"syslog"`

// Telemetry is the configuration for collecting and emitting telemetry.
Telemetry *TelemetryConfig `mapstructure:"telemetry"`

// Templates is the list of templates.
Templates *TemplateConfigs `mapstructure:"template"`

Expand Down Expand Up @@ -138,10 +135,6 @@ func (c *Config) Copy() *Config {
o.Syslog = c.Syslog.Copy()
}

if c.Telemetry != nil {
o.Telemetry = c.Telemetry.Copy()
}

if c.Templates != nil {
o.Templates = c.Templates.Copy()
}
Expand Down Expand Up @@ -217,10 +210,6 @@ func (c *Config) Merge(o *Config) *Config {
r.Syslog = r.Syslog.Merge(o.Syslog)
}

if o.Telemetry != nil {
r.Telemetry = r.Telemetry.Merge(o.Telemetry)
}

if o.Templates != nil {
r.Templates = r.Templates.Merge(o.Templates)
}
Expand Down Expand Up @@ -267,10 +256,6 @@ func Parse(s string) (*Config, error) {
"exec.env",
"ssl",
"syslog",
"telemetry",
"telemetry.stdout",
"telemetry.dogstatsd",
"telemetry.prometheus",
"vault",
"vault.retry",
"vault.ssl",
Expand Down Expand Up @@ -428,7 +413,6 @@ func (c *Config) GoString() string {
"PidFile:%s, "+
"ReloadSignal:%s, "+
"Syslog:%#v, "+
"Telemetry:%#v, "+
"Templates:%#v, "+
"Vault:%#v, "+
"Wait:%#v,"+
Expand All @@ -445,7 +429,6 @@ func (c *Config) GoString() string {
StringGoString(c.PidFile),
SignalGoString(c.ReloadSignal),
c.Syslog,
c.Telemetry.GoString(),
c.Templates,
c.Vault,
c.Wait,
Expand Down Expand Up @@ -484,7 +467,6 @@ func DefaultConfig() *Config {
DefaultDelims: DefaultDefaultDelims(),
Exec: DefaultExecConfig(),
Syslog: DefaultSyslogConfig(),
Telemetry: DefaultTelemetryConfig(),
Templates: DefaultTemplateConfigs(),
Vault: DefaultVaultConfig(),
Wait: DefaultWaitConfig(),
Expand Down Expand Up @@ -547,11 +529,6 @@ func (c *Config) Finalize() {
}
c.Syslog.Finalize()

if c.Telemetry == nil {
c.Telemetry = DefaultTelemetryConfig()
}
c.Telemetry.Finalize()

if c.Templates == nil {
c.Templates = DefaultTemplateConfigs()
}
Expand Down
67 changes: 0 additions & 67 deletions config/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ func BoolVal(b *bool) bool {
return *b
}

// BoolCopy returns a copy of the boolean pointer
func BoolCopy(b *bool) *bool {
if b == nil {
return nil
}

return Bool(*b)
}

// BoolGoString returns the value of the boolean for printing in a string.
func BoolGoString(b *bool) string {
if b == nil {
Expand Down Expand Up @@ -111,46 +102,6 @@ func IntPresent(i *int) bool {
return *i != 0
}

// Uint returns a pointer to the given uint.
func Uint(i uint) *uint {
return &i
}

// UintVal returns the value of the uint at the pointer, or 0 if the pointer is
// nil.
func UintVal(i *uint) uint {
if i == nil {
return 0
}
return *i
}

// UintCopy returns a copy of the uint pointer
func UintCopy(i *uint) *uint {
if i == nil {
return nil
}

return Uint(*i)
}

// UintGoString returns the value of the uint for printing in a string.
func UintGoString(i *uint) string {
if i == nil {
return "(*uint)(nil)"
}
return fmt.Sprintf("%d", *i)
}

// UintPresent returns a boolean indicating if the pointer is nil, or if the
// pointer is pointing to the zero value.
func UintPresent(i *uint) bool {
if i == nil {
return false
}
return *i != 0
}

// Signal returns a pointer to the given os.Signal.
func Signal(s os.Signal) *os.Signal {
return &s
Expand Down Expand Up @@ -198,15 +149,6 @@ func StringVal(s *string) string {
return *s
}

// StringCopy returns a copy of the string pointer
func StringCopy(s *string) *string {
if s == nil {
return nil
}

return String(*s)
}

// StringGoString returns the value of the string for printing in a string.
func StringGoString(s *string) string {
if s == nil {
Expand Down Expand Up @@ -237,15 +179,6 @@ func TimeDurationVal(t *time.Duration) time.Duration {
return *t
}

// TimeDurationCopy returns a copy of the time.Duration pointer
func TimeDurationCopy(t *time.Duration) *time.Duration {
if t == nil {
return nil
}

return TimeDuration(*t)
}

// TimeDurationGoString returns the value of the time.Duration for printing in a
// string.
func TimeDurationGoString(t *time.Duration) string {
Expand Down

0 comments on commit 6bc149b

Please sign in to comment.