diff --git a/README.md b/README.md index 49715d6..324de4c 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,18 @@ Rabbitmq_exporter can be configured using json config file or environment variab Rabbitmq_exporter expects config file in "conf/rabbitmq.conf". If you are running the exporter in a container (docker/kubernetes) the config must be in "/conf/rabbitmq.conf" The name of the file can be overriden with flag: - ./rabbitmq_exporter -config-file config.example.json + ./rabbitmq_exporter --config-file config.example.json --web.config.file web_config.yml --web.listen-address 127.0.0.1:9419 You can find an example [here](config.example.json). *Note:* If you are using a config file, you must provide all values as there is no default value. +## TLS and basic authentication + +The RabbitMQ Exporter supports TLS and basic authentication. + +To use TLS and/or basic authentication, you need to pass a configuration file +using the `--web.config.file` parameter. The format of the file is described +[in the exporter-toolkit repository](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md). + ### Settings Environment variable|default|description @@ -53,10 +61,8 @@ RABBIT_PASSWORD | guest | password for rabbitMQ management plugin RABBIT_CONNECTION | direct | direct or loadbalancer, strips the self label when loadbalancer RABBIT_USER_FILE| | location of file with username (useful for docker secrets) RABBIT_PASSWORD_FILE | | location of file with password (useful for docker secrets) -PUBLISH_PORT | 9419 | Listening port for the exporter -PUBLISH_ADDR | "" | Listening host/IP for the exporter OUTPUT_FORMAT | TTY | Log ouput format. TTY and JSON are suported -LOG_LEVEL | info | log level. possible values: "debug", "info", "warning", "error", "fatal", or "panic" +LOG_LEVEL | info | log level. possible case-insensitive values: "debug", "info", "warning", "error" CAFILE | ca.pem | path to root certificate for access management plugin. Just needed if self signed certificate is used. Will be ignored if the file does not exist CERTFILE | client-cert.pem | path to client certificate used to verify the exporter's authenticity. Will be ignored if the file does not exist KEYFILE | client-key.pem | path to private key used with certificate to verify the exporter's authenticity. Will be ignored if the file does not exist diff --git a/bertmap.go b/bertmap.go index 9c59d4c..fc725ba 100644 --- a/bertmap.go +++ b/bertmap.go @@ -5,7 +5,7 @@ import ( "math/big" bert "github.com/kbudde/gobert" - log "github.com/sirupsen/logrus" + "log/slog" ) // rabbitBERTReply (along with its RabbitReply interface @@ -26,7 +26,7 @@ func (rep *rabbitBERTReply) MakeStatsInfo(labels []string) []StatsInfo { objects, ok := rawObjects.([]bert.Term) if !ok { - log.WithField("got", rawObjects).Error("Statistics reply should contain a slice of objects") + slog.Error("Statistics reply should contain a slice of objects", "got", rawObjects) return make([]StatsInfo, 0) } @@ -35,7 +35,7 @@ func (rep *rabbitBERTReply) MakeStatsInfo(labels []string) []StatsInfo { for _, v := range objects { obj, ok := parseSingleStatsObject(v, labels) if !ok { - log.WithField("got", v).Error("Ignoring unparseable stats object") + slog.Error("Ignoring unparseable stats object", "got", v) continue } statistics = append(statistics, *obj) @@ -50,7 +50,7 @@ func (rep *rabbitBERTReply) MakeMap() MetricMap { err := parseProplist(&flMap, "", term) if err != nil { - log.WithField("error", err).Warn("Error parsing rabbitmq reply (bert, MakeMap)") + slog.Warn("Error parsing rabbitmq reply (bert, MakeMap)", "error", err) } return flMap } @@ -116,7 +116,7 @@ func parseSingleStatsObject(obj interface{}, labels []string) (*StatsInfo, bool) if key == label { tmp, ok := parseBertStringy(value) if !ok { - log.WithField("got", value).WithField("label", label).Error("Non-string field") + slog.Error("Non-string field", "got", value, "label", label) objectOk = false return false } @@ -170,7 +170,7 @@ func parseProplist(toMap *MetricMap, basename string, maybeProplist interface{}) } err := parseProplist(toMap, prefix+key, value) // This can fail, but we don't care - log.WithField("error", err).Debug("Error parsing rabbitmq reply (bert, parseProplist)") + slog.Debug("Error parsing rabbitmq reply (bert, parseProplist)", "error", err) return true }) } @@ -341,7 +341,7 @@ func (rep *rabbitBERTReply) GetString(label string) (string, bool) { return true }) if err != nil { - log.WithField("error", err).Warn("Error parsing rabbitmq reply (bert, GetString)") + slog.Warn("Error parsing rabbitmq reply (bert, GetString)", "error", err) } return resValue, result } diff --git a/bertmap_test.go b/bertmap_test.go index 5fa7598..131cbd0 100644 --- a/bertmap_test.go +++ b/bertmap_test.go @@ -1,7 +1,7 @@ package main import ( - "io/ioutil" + "os" "testing" "github.com/kylelemons/godebug/pretty" @@ -40,13 +40,13 @@ func TestMetricMapEquivalence(t *testing.T) { func tryReadFiles(t *testing.T, base, firstExt, secondExt string) ([]byte, []byte) { firstFile := "testdata/" + base + "." + firstExt - first, err := ioutil.ReadFile(firstFile) + first, err := os.ReadFile(firstFile) if err != nil { t.Fatalf("Error reading %s", firstFile) } secondFile := "testdata/" + base + "." + secondExt - second, err := ioutil.ReadFile(secondFile) + second, err := os.ReadFile(secondFile) if err != nil { t.Fatalf("Error reading %s", secondFile) } diff --git a/config.example.json b/config.example.json index 603cc1b..3273216 100644 --- a/config.example.json +++ b/config.example.json @@ -2,8 +2,6 @@ "rabbit_url": "http://127.0.0.1:15672", "rabbit_user": "guest", "rabbit_pass": "guest", - "publish_port": "9419", - "publish_addr": "", "output_format": "TTY", "ca_file": "ca.pem", "cert_file": "client-cert.pem", diff --git a/config.go b/config.go index 2e8af54..a0511d4 100644 --- a/config.go +++ b/config.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "io/ioutil" "os" "regexp" "strconv" @@ -18,8 +17,6 @@ var ( RabbitUsername: "guest", RabbitPassword: "guest", RabbitConnection: "direct", - PublishPort: "9419", - PublishAddr: "", OutputFormat: "TTY", //JSON CAFile: "ca.pem", CertFile: "client-cert.pem", @@ -45,8 +42,6 @@ type rabbitExporterConfig struct { RabbitUsername string `json:"rabbit_user"` RabbitPassword string `json:"rabbit_pass"` RabbitConnection string `json:"rabbit_connection"` - PublishPort string `json:"publish_port"` - PublishAddr string `json:"publish_addr"` OutputFormat string `json:"output_format"` CAFile string `json:"ca_file"` CertFile string `json:"cert_file"` @@ -131,7 +126,7 @@ func initConfig() { var pass string if len(os.Getenv("RABBIT_USER_FILE")) != 0 { - fileContents, err := ioutil.ReadFile(os.Getenv("RABBIT_USER_FILE")) + fileContents, err := os.ReadFile(os.Getenv("RABBIT_USER_FILE")) if err != nil { panic(err) } @@ -145,7 +140,7 @@ func initConfig() { } if len(os.Getenv("RABBIT_PASSWORD_FILE")) != 0 { - fileContents, err := ioutil.ReadFile(os.Getenv("RABBIT_PASSWORD_FILE")) + fileContents, err := os.ReadFile(os.Getenv("RABBIT_PASSWORD_FILE")) if err != nil { panic(err) } @@ -157,19 +152,6 @@ func initConfig() { config.RabbitPassword = pass } - if port := os.Getenv("PUBLISH_PORT"); port != "" { - if _, err := strconv.Atoi(port); err == nil { - config.PublishPort = port - } else { - panic(fmt.Errorf("the configured port is not a valid number: %v", port)) - } - - } - - if addr := os.Getenv("PUBLISH_ADDR"); addr != "" { - config.PublishAddr = addr - } - if output := os.Getenv("OUTPUT_FORMAT"); output != "" { config.OutputFormat = output } diff --git a/config_test.go b/config_test.go index 12fd575..09e1e16 100644 --- a/config_test.go +++ b/config_test.go @@ -70,26 +70,6 @@ func TestEnvironmentSettingPasswordFile(t *testing.T) { } } -func TestEnvironmentSettingPort(t *testing.T) { - newValue := "9091" - os.Setenv("PUBLISH_PORT", newValue) - defer os.Unsetenv("PUBLISH_PORT") - initConfig() - if config.PublishPort != newValue { - t.Errorf("Expected config.PUBLISH_PORT to be modified. Found=%v, expected=%v", config.PublishPort, newValue) - } -} - -func TestEnvironmentSettingAddr(t *testing.T) { - newValue := "localhost" - os.Setenv("PUBLISH_ADDR", newValue) - defer os.Unsetenv("PUBLISH_ADDR") - initConfig() - if config.PublishAddr != newValue { - t.Errorf("Expected config.PUBLISH_ADDR to be modified. Found=%v, expected=%v", config.PublishAddr, newValue) - } -} - func TestEnvironmentSettingFormat(t *testing.T) { newValue := "json" os.Setenv("OUTPUT_FORMAT", newValue) @@ -100,31 +80,6 @@ func TestEnvironmentSettingFormat(t *testing.T) { } } -func TestConfig_Port(t *testing.T) { - defer func() { - if r := recover(); r == nil { - t.Errorf("initConfig should panic on invalid port config") - } - }() - port := config.PublishPort - os.Setenv("PUBLISH_PORT", "noNumber") - defer os.Unsetenv("PUBLISH_PORT") - initConfig() - if config.PublishPort != port { - t.Errorf("Invalid Portnumber. It should not be set. expected=%v,got=%v", port, config.PublishPort) - } -} - -func TestConfig_Addr(t *testing.T) { - addr := config.PublishAddr - os.Setenv("PUBLISH_ADDR", "") - defer os.Unsetenv("PUBLISH_ADDR") - initConfig() - if config.PublishAddr != addr { - t.Errorf("Invalid Addrress. It should not be set. expected=%v,got=%v", addr, config.PublishAddr) - } -} - func TestConfig_Http_URL(t *testing.T) { defer func() { if r := recover(); r == nil { diff --git a/exporter.go b/exporter.go index 889ee2d..b233e19 100644 --- a/exporter.go +++ b/exporter.go @@ -6,7 +6,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" - log "github.com/sirupsen/logrus" + "log/slog" ) var ( @@ -99,13 +99,15 @@ func (e *exporter) Collect(ch chan<- prometheus.Metric) { allUp := true if err := e.collectWithDuration(e.overviewExporter, "overview", ch); err != nil { - log.WithError(err).Warn("retrieving overview failed") + slog.Warn("retrieving overview failed") + slog.Any("error", err) allUp = false } for name, ex := range e.exporter { if err := e.collectWithDuration(ex, name, ch); err != nil { - log.WithError(err).Warn("retrieving " + name + " failed") + slog.Warn("retrieving " + name + " failed") + slog.Any("error", err) allUp = false } } @@ -125,7 +127,7 @@ func (e *exporter) Collect(ch chan<- prometheus.Metric) { e.upMetric.Collect(ch) e.endpointUpMetric.Collect(ch) e.endpointScrapeDurationMetric.Collect(ch) - log.WithField("duration", time.Since(start)).Info("Metrics updated") + slog.Info("Metrics updated", "duration", time.Since(start)) } diff --git a/exporter_aliveness.go b/exporter_aliveness.go index 3300e02..ef115d8 100644 --- a/exporter_aliveness.go +++ b/exporter_aliveness.go @@ -4,7 +4,7 @@ import ( "context" "github.com/prometheus/client_golang/prometheus" - log "github.com/sirupsen/logrus" + "log/slog" ) func init() { @@ -79,10 +79,10 @@ func (e *exporterAliveness) Collect(ctx context.Context, ch chan<- prometheus.Me } rabbitmqAlivenessMetric.WithLabelValues(e.alivenessInfo.Status, e.alivenessInfo.Error, e.alivenessInfo.Reason).Set(flag) - log.WithField("alivenesswData", rabbitMqAlivenessData).Debug("Aliveness data") + slog.Debug("Aliveness data", "alivenesswData", rabbitMqAlivenessData) for key, gauge := range e.alivenessMetrics { if value, ok := rabbitMqAlivenessData[key]; ok { - log.WithFields(log.Fields{"key": key, "value": value}).Debug("Set aliveness metric for key") + slog.Debug("Set aliveness metric for key", "key", key, "value", value) gauge.WithLabelValues(e.alivenessInfo.Status).Set(value) } } diff --git a/exporter_exchange.go b/exporter_exchange.go index a079b0a..2230b80 100644 --- a/exporter_exchange.go +++ b/exporter_exchange.go @@ -77,7 +77,6 @@ func (e exporterExchange) Collect(ctx context.Context, ch chan<- prometheus.Metr continue } if value, ok := exchange.metrics[key]; ok { - // log.WithFields(log.Fields{"vhost": exchange.vhost, "exchange": exchange.name, "key": key, "value": value}).Debug("Set exchange metric for key") ch <- prometheus.MustNewConstMetric(countvec, prometheus.CounterValue, value, cluster, exchange.labels["vhost"], exchange.labels["name"]) } } diff --git a/exporter_overview.go b/exporter_overview.go index a4468f4..ee00e5f 100644 --- a/exporter_overview.go +++ b/exporter_overview.go @@ -4,7 +4,7 @@ import ( "context" "github.com/prometheus/client_golang/prometheus" - log "github.com/sirupsen/logrus" + "log/slog" ) func init() { @@ -94,10 +94,10 @@ func (e *exporterOverview) Collect(ctx context.Context, ch chan<- prometheus.Met rabbitmqVersionMetric.Reset() rabbitmqVersionMetric.WithLabelValues(e.nodeInfo.RabbitmqVersion, e.nodeInfo.ErlangVersion, e.nodeInfo.Node, e.nodeInfo.ClusterName).Set(1) - log.WithField("overviewData", rabbitMqOverviewData).Debug("Overview data") + slog.Debug("Overview data", "overviewData", rabbitMqOverviewData) for key, gauge := range e.overviewMetrics { if value, ok := rabbitMqOverviewData[key]; ok { - log.WithFields(log.Fields{"key": key, "value": value}).Debug("Set overview metric for key") + slog.Debug("Set overview metric for key", "key", key, "value", value) gauge.Reset() gauge.WithLabelValues(e.nodeInfo.ClusterName).Set(value) } diff --git a/exporter_queue.go b/exporter_queue.go index bc43eaa..9c7388b 100644 --- a/exporter_queue.go +++ b/exporter_queue.go @@ -5,7 +5,7 @@ import ( "errors" "github.com/prometheus/client_golang/prometheus" - log "github.com/sirupsen/logrus" + "log/slog" ) func init() { @@ -140,10 +140,7 @@ func (e exporterQueue) Collect(ctx context.Context, ch chan<- prometheus.Metric) } if totalQueues > config.MaxQueues { - log.WithFields(log.Fields{ - "MaxQueues": config.MaxQueues, - "TotalQueues": totalQueues, - }).Debug("MaxQueues exceeded.") + slog.Debug("MaxQueues exceeded.", "MaxQueues", config.MaxQueues, "TotalQueues", totalQueues) return nil } } @@ -162,7 +159,7 @@ func (e exporterQueue) Collect(ctx context.Context, ch chan<- prometheus.Metric) return err } - log.WithField("queueData", rabbitMqQueueData).Debug("Queue data") + slog.Debug("Queue data", "queueData", rabbitMqQueueData) for _, queue := range rabbitMqQueueData { qname := queue.labels["name"] vname := queue.labels["vhost"] @@ -184,7 +181,6 @@ func (e exporterQueue) Collect(ctx context.Context, ch chan<- prometheus.Metric) for key, gaugevec := range e.queueMetricsGauge { if value, ok := queue.metrics[key]; ok { - // log.WithFields(log.Fields{"vhost": queue.labels["vhost"], "queue": queue.labels["name"], "key": key, "value": value}).Info("Set queue metric for key") gaugevec.WithLabelValues(labelValues...).Set(value) } } @@ -209,7 +205,8 @@ func (e exporterQueue) Collect(ctx context.Context, ch chan<- prometheus.Metric) } e.idleSinceMetric.WithLabelValues(labelValues...).Set(unixSeconds) } else { - log.WithError(err).WithField("idle_since", idleSince).Warn("error parsing idle since time") + slog.Warn("error parsing idle since time", "idle_since", idleSince) + slog.Any("error", err) } } e.stateMetric.WithLabelValues(append(labelValues, state)...).Set(1) diff --git a/exporter_test.go b/exporter_test.go index 7a0719b..94c0888 100644 --- a/exporter_test.go +++ b/exporter_test.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -88,8 +87,8 @@ func TestWholeApp(t *testing.T) { body := w.Body.String() t.Log(body) lines := strings.Split(body, "\n") - if lc := len(lines); lc != 390 { - t.Errorf("expected 390 lines, got %d", lc) + if lc := len(lines); lc != 402 { + t.Errorf("expected 402 lines, got %d", lc) } expectSubstring(t, body, `rabbitmq_up{cluster="my-rabbit@ae74c041248b",node="my-rabbit@ae74c041248b"} 1`) @@ -461,7 +460,7 @@ func TestExporter(t *testing.T) { `rabbitmq_queue_messages_ready{cluster="my-rabbit@ae74c041248b",durable="true",policy="ha-2",queue="myQueue2",self="1",vhost="/"} 25`, }, dontExpect: []string{}, - lines: 419, + lines: 431, }, { name: "Include specific queue", @@ -630,7 +629,7 @@ func TestQueueState(t *testing.T) { func TestQueueLength(t *testing.T) { testdataFile := "testdata/queue-max-length.json" - queuedata, err := ioutil.ReadFile(testdataFile) + queuedata, err := os.ReadFile(testdataFile) if err != nil { t.Fatalf("Error reading %s", testdataFile) } diff --git a/go.mod b/go.mod index 9021719..7ba2423 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,16 @@ module github.com/kbudde/rabbitmq_exporter require ( + github.com/alecthomas/kingpin/v2 v2.4.0 + github.com/hashicorp/vault-client-go v0.4.3 github.com/kbudde/gobert v0.0.0-20220512191144-9767639f5c50 github.com/kylelemons/godebug v1.1.0 github.com/ory/dockertest/v3 v3.11.0 - github.com/prometheus/client_golang v1.19.0 - github.com/sirupsen/logrus v1.9.3 + github.com/prometheus/client_golang v1.20.4 + github.com/prometheus/exporter-toolkit v0.13.1 github.com/streadway/amqp v1.1.0 github.com/tkanos/gonfig v0.0.0-20210106201359-53e13348de2f - golang.org/x/sys v0.21.0 + golang.org/x/sys v0.26.0 ) require ( @@ -16,10 +18,12 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect + github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/containerd/continuity v0.4.3 // indirect + github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/docker/cli v26.1.4+incompatible // indirect github.com/docker/docker v27.1.1+incompatible // indirect github.com/docker/go-connections v0.5.0 // indirect @@ -27,24 +31,43 @@ require ( github.com/ghodss/yaml v1.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/lib/pq v1.10.9 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-hclog v1.2.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.1 // indirect + github.com/hashicorp/go-rootcerts v1.0.2 // indirect + github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect + github.com/jpillora/backoff v1.0.0 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mdlayher/socket v0.4.1 // indirect + github.com/mdlayher/vsock v1.2.1 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/term v0.5.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/opencontainers/runc v1.1.13 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.50.0 // indirect - github.com/prometheus/procfs v0.13.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.60.1 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + github.com/ryanuber/go-glob v1.0.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect - golang.org/x/mod v0.16.0 // indirect - golang.org/x/tools v0.19.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + github.com/xhit/go-str2duration/v2 v2.1.0 // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/text v0.19.0 // indirect + golang.org/x/time v0.5.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 48e5133..ce87482 100644 --- a/go.sum +++ b/go.sum @@ -8,17 +8,22 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= +github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY= +github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -38,18 +43,37 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= +github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= +github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ= +github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9CdjCtrXrXGuOpxEA7Ts= +github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4= +github.com/hashicorp/vault-client-go v0.4.3 h1:zG7STGVgn/VK6rnZc0k8PGbfv2x/sJExRKHSUg3ljWc= +github.com/hashicorp/vault-client-go v0.4.3/go.mod h1:4tDw7Uhq5XOxS1fO+oMtotHL7j4sB9cp0T7U6m4FzDY= +github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/kbudde/gobert v0.0.0-20220512191144-9767639f5c50 h1:zaDz2YfwvX72CdAqsVfv2mKr5EQ3bE7147RIHhoL9D8= github.com/kbudde/gobert v0.0.0-20220512191144-9767639f5c50/go.mod h1:wxNjohCuAvLH8uXUilrMINgVaz2EOfT9x6KlBPIE5dk= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -59,12 +83,30 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U= +github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= +github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ= +github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -81,14 +123,16 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= -github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= -github.com/prometheus/common v0.50.0 h1:YSZE6aa9+luNa2da6/Tik0q0A5AbR+U003TItK57CPQ= -github.com/prometheus/common v0.50.0/go.mod h1:wHFBCEVWVmHMUpg7pYcOm2QUR/ocQdYSJVQJKnHc3xQ= -github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o= -github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= +github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= +github.com/prometheus/exporter-toolkit v0.13.1 h1:Evsh0gWQo2bdOHlnz9+0Nm7/OFfIwhE2Ws4A2jIlR04= +github.com/prometheus/exporter-toolkit v0.13.1/go.mod h1:ujdv2YIOxtdFxxqtloLpbqmxd5J0Le6IITUvIRSWjj0= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= @@ -97,6 +141,7 @@ github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM= github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -109,11 +154,15 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= +github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= +github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= @@ -122,22 +171,31 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +>>>>>>> 5da6bd5 (Add TLS and basic authentication in web interface) golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -153,6 +211,7 @@ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/integration_test.go b/integration_test.go index e138fb6..513945d 100644 --- a/integration_test.go +++ b/integration_test.go @@ -55,7 +55,6 @@ func TestQueueCount(t *testing.T) { r := regexp.MustCompile(`rabbitmq_queues{cluster="rabbit@localtest"} 1`) if s := r.FindString(body); s == "" { - // t.Logf("body: %s", body) t.Fatalf("QueueCount 1 not found ") } }) @@ -66,7 +65,6 @@ func TestQueueCount(t *testing.T) { timestamp := time.Date(2017, 11, 27, 8, 25, 23, 0, time.UTC) env.Rabbit.SendMessageToQ("Test timestamp", queue, ×tamp) time.Sleep(10 * time.Second) // give rabbitmq management plugin a bit of time - // log.Println(testenv.GetOrDie(env.ManagementURL()+"/api/queues", 5*time.Second)) body := testenv.GetOrDie(exporterURL, 5*time.Second) search := fmt.Sprintf(`rabbitmq_queue_head_message_timestamp{cluster="rabbit@localtest",durable="true",policy="",queue="%s",self="1",vhost="/"} %1.9e`, queue, float64(timestamp.Unix())) @@ -124,8 +122,6 @@ func TestQueueCount(t *testing.T) { search := fmt.Sprintf(`rabbitmq_queue_messages{cluster="rabbit@localtest",durable="false",policy="%s",queue="%s",self="1",vhost="/"} 0`, policy, queue) i := strings.Index(body, search) if i == -1 { - // t.Log(env.ManagementURL()) - // t.Log(testenv.GetOrDie(env.ManagementURL()+"/api/queues", 5*time.Second)) t.Log(body, search) t.Fatalf("Queue with policy not found") } diff --git a/jsonmap.go b/jsonmap.go index 81a0c81..5286b6b 100644 --- a/jsonmap.go +++ b/jsonmap.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - log "github.com/sirupsen/logrus" + "log/slog" ) type rabbitJSONReply struct { @@ -25,12 +25,13 @@ func (rep *rabbitJSONReply) MakeStatsInfo(labels []string) []StatsInfo { var jsonArr []map[string]interface{} decoder := json.NewDecoder(bytes.NewBuffer(rep.body)) if decoder == nil { - log.Error("JSON decoder not iniatilized") + slog.Error("JSON decoder not iniatilized") return make([]StatsInfo, 0) } if err := decoder.Decode(&jsonArr); err != nil { - log.WithField("error", err).Error("Error while decoding json") + slog.Error("Error while decoding json") + slog.Any("error", err) return make([]StatsInfo, 0) } @@ -43,7 +44,7 @@ func (rep *rabbitJSONReply) MakeStatsInfo(labels []string) []StatsInfo { field = "id" } if field != "" { - log.WithFields(log.Fields{"element": el, "vhost": el["vhost"], field: el[field]}).Debug("Iterate over array") + slog.Debug("Iterate over array", "element", el, "vhost", el["vhost"], field, el[field]) statsinfo := StatsInfo{} statsinfo.labels = make(map[string]string) @@ -73,12 +74,12 @@ func (rep *rabbitJSONReply) MakeMap() MetricMap { var output map[string]interface{} decoder := json.NewDecoder(bytes.NewBuffer(rep.body)) if decoder == nil { - log.Error("JSON decoder not iniatilized") + slog.Error("JSON decoder not iniatilized") return flMap } if err := decoder.Decode(&output); err != nil { - log.WithField("error", err).Error("Error while decoding json") + slog.Error("Error while decoding json", "error", err) return flMap } @@ -115,7 +116,7 @@ func (rep *rabbitJSONReply) GetString(key string) (string, bool) { keys := make(map[string]interface{}) decoder := json.NewDecoder(bytes.NewBuffer(rep.body)) if decoder == nil { - log.Error("JSON decoder not iniatilized") + slog.Error("JSON decoder not iniatilized") return "", false } err := decoder.Decode(&keys) diff --git a/main.go b/main.go index b2314ff..0439d68 100644 --- a/main.go +++ b/main.go @@ -3,36 +3,46 @@ package main import ( "bytes" "context" - "flag" + "log/slog" "net/http" "os" "strings" "time" + "github.com/alecthomas/kingpin/v2" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus" - log "github.com/sirupsen/logrus" -) -const ( - defaultLogLevel = log.InfoLevel + "github.com/prometheus/exporter-toolkit/web" + webflag "github.com/prometheus/exporter-toolkit/web/kingpinflag" + ) func initLogger() { - log.SetLevel(getLogLevel()) + logHandlerOptions := slog.HandlerOptions{} + envLogLevel := os.Getenv("LOG_LEVEL") + if envLogLevel != "" { + logLevel := slog.Level.Level(slog.LevelInfo) + error := logLevel.UnmarshalText([]byte(envLogLevel)) + if error != nil { + slog.Error("Allowed case-independent log level values: debug, info, warn, error.", "LOG_LEVEL", envLogLevel) + panic(error) + } + logHandlerOptions = slog.HandlerOptions{Level: logLevel} + } if strings.ToUpper(config.OutputFormat) == "JSON" { - log.SetFormatter(&log.JSONFormatter{}) + slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, &logHandlerOptions))) } else { - // The TextFormatter is default, you don't actually have to do this. - log.SetFormatter(&log.TextFormatter{}) + slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &logHandlerOptions))) } } func main() { - var checkURL = flag.String("check-url", "", "Curl url and return exit code (http: 200 => 0, otherwise 1)") - var configFile = flag.String("config-file", "conf/rabbitmq.conf", "path to json config") - flag.Parse() + var checkURL = kingpin.Flag("check-url", "Curl url and return exit code (http: 200 => 0, otherwise 1)").Default("").String() + var configFile = kingpin.Flag("config-file", "path to json config").Default("conf/rabbitmq.conf").String() + webFlags := webflag.AddFlags(kingpin.CommandLine, ":9417") + kingpin.Parse() if *checkURL != "" { // do a single http get request. Used in docker healthckecks as curl is not inside the image curl(*checkURL) @@ -51,42 +61,37 @@ func main() { exporter := newExporter() prometheus.MustRegister(exporter) - log.WithFields(log.Fields{ - "VERSION": Version, - "REVISION": Revision, - "BRANCH": Branch, - "BUILD_DATE": BuildDate, - // "RABBIT_PASSWORD": config.RABBIT_PASSWORD, - }).Info("Starting RabbitMQ exporter") - - log.WithFields(log.Fields{ - "PUBLISH_ADDR": config.PublishAddr, - "PUBLISH_PORT": config.PublishPort, - "RABBIT_URL": config.RabbitURL, - "RABBIT_USER": config.RabbitUsername, - "RABBIT_CONNECTION": config.RabbitConnection, - "OUTPUT_FORMAT": config.OutputFormat, - "RABBIT_CAPABILITIES": formatCapabilities(config.RabbitCapabilities), - "RABBIT_EXPORTERS": config.EnabledExporters, - "CAFILE": config.CAFile, - "CERTFILE": config.CertFile, - "KEYFILE": config.KeyFile, - "SKIPVERIFY": config.InsecureSkipVerify, - "EXCLUDE_METRICS": config.ExcludeMetrics, - "SKIP_EXCHANGES": config.SkipExchanges.String(), - "INCLUDE_EXCHANGES": config.IncludeExchanges.String(), - "SKIP_QUEUES": config.SkipQueues.String(), - "INCLUDE_QUEUES": config.IncludeQueues.String(), - "SKIP_VHOST": config.SkipVHost.String(), - "INCLUDE_VHOST": config.IncludeVHost.String(), - "RABBIT_TIMEOUT": config.Timeout, - "MAX_QUEUES": config.MaxQueues, - // "RABBIT_PASSWORD": config.RABBIT_PASSWORD, - }).Info("Active Configuration") - - handler := http.NewServeMux() - handler.Handle("/metrics", promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{})) - handler.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + slog.Info("Starting RabbitMQ exporter", + "VERSION", Version, + "REVISION", Revision, + "BRANCH", Branch, + "BUILD_DATE", BuildDate) + + slog.Info("Active Configuration", + "RABBIT_URL", config.RabbitURL, + "RABBIT_USER", config.RabbitUsername, + "RABBIT_CONNECTION", config.RabbitConnection, + "OUTPUT_FORMAT", config.OutputFormat, + "RABBIT_CAPABILITIES", formatCapabilities(config.RabbitCapabilities), + "RABBIT_EXPORTERS", config.EnabledExporters, + "CAFILE", config.CAFile, + "CERTFILE", config.CertFile, + "KEYFILE", config.KeyFile, + "SKIPVERIFY", config.InsecureSkipVerify, + "EXCLUDE_METRICS", config.ExcludeMetrics, + "SKIP_EXCHANGES", config.SkipExchanges.String(), + "INCLUDE_EXCHANGES", config.IncludeExchanges.String(), + "SKIP_QUEUES", config.SkipQueues.String(), + "INCLUDE_QUEUES", config.IncludeQueues.String(), + "SKIP_VHOST", config.SkipVHost.String(), + "INCLUDE_VHOST", config.IncludeVHost.String(), + "RABBIT_TIMEOUT", config.Timeout, + "MAX_QUEUES", config.MaxQueues, + + ) + + http.Handle("/metrics", promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{})) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte(`