From 5fd2377d8a96be06bd521a41e2dcacb789922250 Mon Sep 17 00:00:00 2001 From: Nikolay Sivko Date: Thu, 9 Jun 2022 18:20:56 +0300 Subject: [PATCH] coroot-pg-agent updated to v1.0.4 --- go.mod | 2 +- go.sum | 4 ++++ main.go | 2 ++ rds/collector.go | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 234c2e5..b9896b7 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/aws/aws-sdk-go v1.40.51 - github.com/coroot/coroot-pg-agent v1.0.0 + github.com/coroot/coroot-pg-agent v1.0.4 github.com/coroot/logger v1.0.0 github.com/coroot/logparser v1.0.4 github.com/google/go-cmp v0.5.6 // indirect diff --git a/go.sum b/go.sum index 7ba8ddf..4d03c96 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,8 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/coroot/coroot-pg-agent v1.0.0 h1:+TrTiJpYkaJJwUwS/L/N75NURofO1kUI/Sgz6+Qti4M= github.com/coroot/coroot-pg-agent v1.0.0/go.mod h1:N3X0m2Z2TXln+7blrGdygPOBERaykKC/4d+nO6RecYE= +github.com/coroot/coroot-pg-agent v1.0.4 h1:hprCVy+fsv3d6w/pNDgTdhQghh36Z1yu7NxTmZfEvPQ= +github.com/coroot/coroot-pg-agent v1.0.4/go.mod h1:8z3BLlH1tAN3mzKgguLkgznFBetwopHgI5v2snXanOg= github.com/coroot/logger v1.0.0 h1:n8iNkGk6ete9wp/L49FXsZlNiySuA+IJ7TsTkYkiqPc= github.com/coroot/logger v1.0.0/go.mod h1:rEO5EQqDbB4bnCoo5Ot9Dj51Bkl40RUVqB03rba54HE= github.com/coroot/logparser v1.0.4 h1:xp3Tc6/3gVFcm6t9TD/zJrHCCu16e7wA/VnnFLtoseU= @@ -25,6 +27,8 @@ github.com/coroot/logparser v1.0.4/go.mod h1:GHsVO1xE8pR5mmu9Eiop9IXHwN/QzNRx1s0 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= diff --git a/main.go b/main.go index fac37cc..80e1021 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ func main() { rdsDbConnectTimeout := kingpin.Flag("rds-db-connect-timeout", "RDS db connect timeout").Default("1s").Duration() rdsDbQueryTimeout := kingpin.Flag("rds-db-query-timeout", "RDS db query timeout").Default("30s").Duration() rdsLogsScrapeInterval := kingpin.Flag("rds-logs-scrape-interval", "RDS logs scrape interval (0 to disable)").Default("30s").Duration() + dbScrapeInterval := kingpin.Flag("db-scrape-interval", "How often to scrape DB system views").Default("30s").Duration() listenAddress := kingpin.Flag("listen-address", `Listen address (env: LISTEN_ADDRESS) - ":" or ":".`).Envar("LISTEN_ADDRESS").Default("0.0.0.0:80").String() kingpin.HelpFlag.Short('h').Hidden() kingpin.Version(version) @@ -48,6 +49,7 @@ func main() { QueryTimeout: *rdsDbQueryTimeout, LogsScrapeInterval: *rdsLogsScrapeInterval, + DbScrapeInterval: *dbScrapeInterval, } go rds.NewDiscoverer(reg, awsSession, *rdsDiscoveryInterval, rdsDbConf).Run() diff --git a/rds/collector.go b/rds/collector.go index cb1a881..39e3799 100644 --- a/rds/collector.go +++ b/rds/collector.go @@ -56,6 +56,7 @@ type DbCollectorConf struct { QueryTimeout time.Duration LogsScrapeInterval time.Duration + DbScrapeInterval time.Duration } type DbCollector interface { @@ -123,7 +124,7 @@ func (c *Collector) startDbCollector() { } statementTimeout := int(c.dbConf.QueryTimeout.Milliseconds()) dsn := fmt.Sprintf("postgresql://%s@%s/postgres?connect_timeout=%d&statement_timeout=%d", userPass, endpoint, connectTimeout, statementTimeout) - if collector, err := postgres.New(dsn, c.logger); err != nil { + if collector, err := postgres.New(dsn, c.dbConf.DbScrapeInterval, c.logger); err != nil { c.logger.Warning("failed to init postgres collector:", err) } else { c.logger.Info("started postgres collector:", endpoint)