Google Cloud SDK to manage Stackdriver

36 views
Skip to first unread message

Alan Wells

unread,
Jan 28, 2020, 9:25:49 PM1/28/20
to Google Apps Script Community
If you use Apps Script, then you may be logging information or errors to Stackdriver.  But how can you do something like delete logs that you no longer care about?  Well, you can do that with the Google Cloud SDK command line tool.  The Cloud SDK can also access and manage other Google Cloud Services.  The Google Cloud SDK runs from your computer.  It requires Python.  It's free.  When looking at the documentation, you may see statements that you must enable a Cloud Billing Account.  For use with Apps Script, I don't have a Cloud Billing Account.  I have a GCP project associated with my Apps Script project in order to publish an add-on, and I have never enabled a Cloud Billing Account.

Just for fun, I downloaded the Google Cloud SDK and deleted all the Stackdriver logs of a specific LOG_NAME.  Now all my Stackdriver log entries are gone.  Of course, I will continue to get new ones when there are code failures.

I'm using a windows machine, so I decided to try using the Windows Power Shell for the installation, rather than downloading the file.  It worked well.

It took me a long time to figure out what the LOG_NAME setting was.  It's a URL that I found in the data of an individual error log.

There are lots of Google Cloud SDK commands because it covers multiple products in the Google Cloud Platform.  I used the gcloud logging commands.


I didn't need to delete those logs, and I don't have billing enabled, so I'm not going to get billed, but having some experience with the Google Cloud SDK might be something good to know.  I just hate the thought of all that log data being stored for no reason.  I'm not going to use it.  I look at the most recent logs once, and then never again.


Google Cloud SDK setup.png

Cloud SDK has been installed.JPG

Google Cloud SDK authorize.JPG

Google Cloud SDK success.JPG


Dimu Designs

unread,
Jan 28, 2020, 10:47:49 PM1/28/20
to Google Apps Script Community
That's the thing with Apps Script, stick with it long enough and after awhile you'll find yourself tinkering with all manner of GCP tools, services and APIs.

Pro Tip: You can run the gcloud cli directly in your browser using Cloud Shell (via Google Cloud Console), no need to install it locally. Go to your cloud console and click the unix-prompt looking icon in the toolbar to the upper-right to activate it.

There are some pretty awesome APIs and services under GCP, and you can find the full list of them using Google's API Explorer

Alex

unread,
Jan 28, 2020, 11:50:34 PM1/28/20
to Google Apps Script Community
Can't switch my mind to Cloud Shell for this. Perhaps gcloud is the second program that installs after my desktop OS. Obsessive habit.

Alan Wells

unread,
Jan 29, 2020, 10:01:11 AM1/29/20
to Google Apps Script Community
That is a very good tip.  Thank you.

Activate Cloud Shell from GCP.

Cloud Shell Activate.png


Cloud Shell Welcome

Cloud Shell Welcome.png

Reply all
Reply to author
Forward
0 new messages