sensu / sensu-go

Simple. Scalable. Multi-cloud monitoring.
https://sensu.io
MIT License
1.03k stars 175 forks source link

Use the sensuctl logger for the rest client output #3605

Closed portertech closed 4 years ago

portertech commented 4 years ago

Use the sensuctl logger for the rest client output.

Feature Suggestion

Use the sensuctl logger for the rest client output. This will give the user control over the output and provide a consistent logging experience.

Possible Implementation

Go resty allows you to set the client logger, see: https://pkg.go.dev/github.com/go-resty/resty/v2?tab=doc#Client.SetLogger

Context

Sensu Go 5.18 users are experiencing sensuctl output like:

[vagrant@backend ~]$ sensuctl asset outdated
INFO[0000] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/betorvs/sensu-opsgenie-handler"
INFO[0000] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/jkerry/sensu-go-elasticsearch"
INFO[0001] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/nixwiz/sensu-go-fatigue-check-filter"
INFO[0002] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/nixwiz/sensu-go-graphite-handler"
INFO[0002] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/nixwiz/sensu-go-pushover-handler"
INFO[0003] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/portertech/sensu-severity-filter"
INFO[0003] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/sensu-plugins/sensu-plugins-cpu-checks"
INFO[0004] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/sensu-plugins/sensu-plugins-dns"
INFO[0004] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/sensu-plugins/sensu-plugins-http"
INFO[0005] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/sensu/monitoring-plugins"
INFO[0005] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/sensu/sensu-influxdb-handler"
INFO[0006] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/sensu/sensu-ruby-runtime"
INFO[0007] sending request to bonsai                     component=bonsai-client request="https://bonsai.sensu.io/api/v1/assets/sensu/system-profile-linux"
                Asset Name                              Bonsai Asset                Current Version   Latest Version
 ──────────────────────────────────────── ──────────────────────────────────────── ───────────────── ────────────────
  betorvs/sensu-opsgenie-handler           betorvs/sensu-opsgenie-handler           0.0.9             0.0.10
  nixwiz/sensu-go-fatigue-check-filter     nixwiz/sensu-go-fatigue-check-filter     0.4.0             0.5.0
  sensu-plugins/sensu-plugins-cpu-checks   sensu-plugins/sensu-plugins-cpu-checks   4.0.0             4.1.0
  sensu-plugins/sensu-plugins-http         sensu-plugins/sensu-plugins-http         5.1.1             6.0.0
calebhailey commented 4 years ago

It seems that https://github.com/sensu/sensu-go/pull/3623 fixed the inadvertent Resty output in the bonsai client, but not elsewhere in sensuctl. For example, I'm still seeing resty output when connecting to a Sensu backend with sensuctl configure.

$ sensuctl configure -n --url http://127.0.0.1:8080 \
  --username admin \
  --password "P@ssw0rd!" \
  --namespace default
WARN[0000] Using Basic Auth in HTTP mode is not secure, use HTTPS  component=cli-client

Should we reopen this issue to get this fixed, or open a new issue?