GoogleCloudPlatform / gcpdiag

gcpdiag is a command-line diagnostics tool for GCP customers.
https://gcpdiag.dev/
Apache License 2.0
284 stars 63 forks source link

Optimize for automated use #27

Open lauraseidler opened 2 years ago

lauraseidler commented 2 years ago

Hi everyone,

I'm really liking gcpdiag, and it has uncovered a few issues with our infrastructure already that we were able to fix, so a big thanks for making it available :)

As it proved to be really useful to us, I wanted to go one step further and automate running it, meaning:

  1. run it automatically in a given interval (e.g. every day or every week)
  2. run it on all projects matching a given filter (e.g. all projects in a specific folder)
  3. get notified if any issue is found

While I was somewhat successful in that (running a cronjob in a GKE cluster with a custom python script that fetches all projects, runs gcpdiag on all of them and then sends an alert via a webhook in case there's any errors) I uncovered a few challenges along the way, so I wanted to share some thoughts and get your opinions on whether these are things you would consider implementing or be open to contributions:

Happy to hear your thoughts! :)

schweikert commented 2 years ago

Thanks a lot Laura for the feedback!

I agree that running gcpdiag automatically for example every day could be very useful. In fact I was also speaking about why this would be a good idea to some colleagues :-) What makes it particularly useful is that we plan to release new gcpdiag versions with new rules often, so running gcpdiag regularly would make you notice if anything new is detected by those rules (besides making sure that everything stays good with the existing rules as well).

In order to better support that use case, we have implemented config files which allow you to specify configuration variables on a per-project level (such as for example excluding some rules that you don't care about for certain projects), and also we have implemented support for CSV and JSON output (thanks to @dawidmalina). The CSV+JSON output will be released with the next version.

Cheers David