Skip to content

Commit

Permalink
rebase on braydonk-refresh-interval
Browse files Browse the repository at this point in the history
  • Loading branch information
braydonk committed Dec 2, 2021
1 parent 0d2aa4e commit 1f10ccd
Show file tree
Hide file tree
Showing 75 changed files with 122 additions and 154 deletions.
2 changes: 1 addition & 1 deletion apps/apache.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (r MetricsReceiverApache) Pipelines() []otel.Pipeline {
Receiver: otel.Component{
Type: "httpd",
Config: map[string]interface{}{
"collection_interval": r.CollectionIntervalString(),
"collection_interval": r.CollectionInterval,
"endpoint": r.ServerStatusURL,
},
},
Expand Down
14 changes: 9 additions & 5 deletions apps/builtinconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

package apps

import cg "github.com/GoogleCloudPlatform/ops-agent/confgenerator"
import (
"time"

cg "github.com/GoogleCloudPlatform/ops-agent/confgenerator"
)

var (
BuiltInConfStructs = map[string]*cg.UnifiedConfig{
Expand All @@ -39,7 +43,7 @@ var (
Receivers: map[string]cg.MetricsReceiver{
"hostmetrics": &MetricsReceiverHostmetrics{
ConfigComponent: cg.ConfigComponent{Type: "hostmetrics"},
MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: "60s"},
MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: time.Second * 60},
},
},
Processors: map[string]cg.MetricsProcessor{
Expand Down Expand Up @@ -78,15 +82,15 @@ var (
Receivers: map[string]cg.MetricsReceiver{
"hostmetrics": &MetricsReceiverHostmetrics{
ConfigComponent: cg.ConfigComponent{Type: "hostmetrics"},
MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: "60s"},
MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: time.Second * 60},
},
"iis": &MetricsReceiverIis{
ConfigComponent: cg.ConfigComponent{Type: "iis"},
MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: "60s"},
MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: time.Second * 60},
},
"mssql": &MetricsReceiverMssql{
ConfigComponent: cg.ConfigComponent{Type: "mssql"},
MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: "60s"},
MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: time.Second * 60},
},
},
Processors: map[string]cg.MetricsProcessor{
Expand Down
2 changes: 1 addition & 1 deletion apps/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (r MetricsReceiverCassandra) Pipelines() []otel.Pipeline {

config := map[string]interface{}{
"target_system": targetSystem,
"collection_interval": r.CollectionIntervalString(),
"collection_interval": r.CollectionInterval,
"endpoint": r.Endpoint,
"jar_path": jarPath,
}
Expand Down
2 changes: 1 addition & 1 deletion apps/hostmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (r MetricsReceiverHostmetrics) Pipelines() []otel.Pipeline {
Receiver: otel.Component{
Type: "hostmetrics",
Config: map[string]interface{}{
"collection_interval": r.CollectionIntervalString(),
"collection_interval": r.CollectionInterval,
"scrapers": map[string]interface{}{
"cpu": struct{}{},
"load": struct{}{},
Expand Down
2 changes: 1 addition & 1 deletion apps/iis.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (r MetricsReceiverIis) Pipelines() []otel.Pipeline {
Receiver: otel.Component{
Type: "windowsperfcounters",
Config: map[string]interface{}{
"collection_interval": r.CollectionIntervalString(),
"collection_interval": r.CollectionInterval,
"perfcounters": []map[string]interface{}{
{
"object": "Web Service",
Expand Down
2 changes: 1 addition & 1 deletion apps/jvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r MetricsReceiverJVM) Pipelines() []otel.Pipeline {

config := map[string]interface{}{
"target_system": "jvm",
"collection_interval": r.CollectionIntervalString(),
"collection_interval": r.CollectionInterval,
"endpoint": r.Endpoint,
"jar_path": jarPath,
}
Expand Down
2 changes: 1 addition & 1 deletion apps/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (m MetricsReceiverMssql) Pipelines() []otel.Pipeline {
Receiver: otel.Component{
Type: "windowsperfcounters",
Config: map[string]interface{}{
"collection_interval": m.CollectionIntervalString(),
"collection_interval": m.CollectionInterval,
"perfcounters": []map[string]interface{}{
{
"object": "SQLServer:General Statistics",
Expand Down
2 changes: 1 addition & 1 deletion apps/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (r MetricsReceiverNginx) Pipelines() []otel.Pipeline {
Receiver: otel.Component{
Type: "nginx",
Config: map[string]interface{}{
"collection_interval": r.CollectionIntervalString(),
"collection_interval": r.CollectionInterval,
"endpoint": r.StubStatusURL,
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (r MetricsReceiverRedis) Pipelines() []otel.Pipeline {
Receiver: otel.Component{
Type: "redis",
Config: map[string]interface{}{
"collection_interval": r.CollectionIntervalString(),
"collection_interval": r.CollectionInterval,
"endpoint": r.Address,
"password": r.Password,
},
Expand Down
2 changes: 1 addition & 1 deletion confgenerator/built-in-config-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metrics:
receivers:
hostmetrics:
type: hostmetrics
collection_interval: 60s
collection_interval: 1m0s
processors:
metrics_filter:
type: exclude_metrics
Expand Down
6 changes: 3 additions & 3 deletions confgenerator/built-in-config-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ metrics:
receivers:
hostmetrics:
type: hostmetrics
collection_interval: 60s
collection_interval: 1m0s
iis:
type: iis
collection_interval: 60s
collection_interval: 1m0s
mssql:
type: mssql
collection_interval: 60s
collection_interval: 1m0s
processors:
metrics_filter:
type: exclude_metrics
Expand Down
22 changes: 1 addition & 21 deletions confgenerator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,6 @@ func newValidator() *validator.Validate {
v.RegisterValidationCtx("platform", func(ctx context.Context, fl validator.FieldLevel) bool {
return ctx.Value(platformKey) == fl.Param()
})
// duration validates that the value is a valid duration and >= the parameter
v.RegisterValidation("duration", func(fl validator.FieldLevel) bool {
t, err := time.ParseDuration(fl.Field().String())
if err != nil {
return false
}
tmin, err := time.ParseDuration(fl.Param())
if err != nil {
panic(err)
}
return t >= tmin
})
// multipleof_time validates that the value duration is a multiple of the parameter
v.RegisterValidation("multipleof_time", func(fl validator.FieldLevel) bool {
t, ok := fl.Field().Interface().(time.Duration)
Expand Down Expand Up @@ -372,15 +360,7 @@ type MetricsReceiver interface {
}

type MetricsReceiverShared struct {
CollectionInterval string `yaml:"collection_interval" validate:"required,duration=10s"` // time.Duration format
}

func (m MetricsReceiverShared) CollectionIntervalString() string {
// TODO: Remove when https://github.com/goccy/go-yaml/pull/246 is merged
if m.CollectionInterval != "" {
return m.CollectionInterval
}
return "60s"
CollectionInterval time.Duration `yaml:"collection_interval" validate:"required,min=10s"` // time.Duration format
}

var MetricsReceiverTypes = &componentTypeRegistry{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[5:28] "collection_interval" must be a duration of at least 10s
[5:28] "collection_interval" must be a minimum of 10s
2 | receivers:
3 | receiver_1:
4 | type: hostmetrics
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
[5:28] "collection_interval" must be a duration of at least 10s
2 | receivers:
3 | receiver_1:
4 | type: hostmetrics
> 5 | collection_interval: 24
^
6 | service:
7 | pipelines:
8 | default_pipeline:
cannot unmarshal uint64 into Go struct field UnifiedConfig.Metrics of type time.Duration
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[5:28] "collection_interval" must be a duration of at least 10s
[5:28] "collection_interval" must be a minimum of 10s
2 | receivers:
3 | receiver_1:
4 | type: hostmetrics
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
[5:28] "collection_interval" must be a duration of at least 10s
2 | receivers:
3 | receiver_1:
4 | type: hostmetrics
> 5 | collection_interval: 24
^
6 | service:
7 | pipelines:
8 | default_pipeline:
cannot unmarshal uint64 into Go struct field UnifiedConfig.Metrics of type time.Duration
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ processors:
- gce
receivers:
hostmetrics/default__pipeline_hostmetrics:
collection_interval: 60s
collection_interval: 1m0s
scrapers:
cpu: {}
disk: {}
Expand Down
Loading

0 comments on commit 1f10ccd

Please sign in to comment.