Stackdriver driver provides monitoring, logging, error reporting, tracing and debugging services. Currently known as Google Cloud’s operations suite.

  • Integrated monitoring, logging and diagnostics.
  • Working in different platforms
    • AWS and GCP
    • Discover GCP with smart defaults.
    • Open Source agents and inegrations.
  • Analytics

Features and components.

Google Image Monitoring

Monitoring

  • Dynamically configured when the resource is created.
  • Workspace holds monitoring, config information in one place.
  • One workspace an monitor multiple projects in GCP and AWS accounts.
  • Also GCP projects /AWS Accounts can be monitored by mutliple workspaces.
  • Workspace contain custom dashboards, alerting policies, uptime checks etc.
  • Charts for CPU util, network monitoring (drop packets etc).
  • Alerting
  • Uptime checks.
  • Monitor symptoms. Ex: monitor failing queries of a database and then identify whether the database is down.
  • Monitoring agent is required for better information about the VM.
  • Custom metrics for better user defined monitoring.
    • A set of data points.
    • Metric-type information, which tells you what the data points represent.
    • Monitored-resource information, which tells you where the data points originated.

Google Image Troubleshooting

Cloud Logging

  • Allows to store, search, analyze logs on GCP and AWS.
    • Log API
    • 30 day retention.
  • Log search/filter
  • Metrics
  • Monitoring alerts
  • Data can be exported to Cloud Storage/BigQuery/PubSub for more analysis.
    • BigQuery can help visualize logs.
    • Also can use datastudio.
  • We can stream logs directly to pub/sub which can then feed to other services for real-time processing.

Error Reporting

  • Realtime exception monitoring ande alerting.
  • Error reporting
  • Supports Go, Java, Python, PHP, Ruby, .net, Node.js
  • Also for App Engine, Cloud Functions, Compute Engine etc.

Cloud Trace - Tracing

  • Distributed tracing for everyone
    • Cloud Trace is a distributed tracing system that collects latency data from your applications and displays it in the Google Cloud Console.
    • You can track how requests propagate through your application and receive detailed near real-time performance insights.
  • Find performace bottlenecks
  • Issue detection

Waterfall View

Cloud Debugger - Debugging

  • Debug without stopping on slowing it down.
  • Adds less than 10ms to the request latency.
  • Debug live environments in production.
  • Snapshot runing application to analyze further.
  • Debug logpoints.
    • Inject loggin without stopping it.
  • Works for Go, Java, Python, Ruby, Node.js

Creating an Application - Error Reporting.

We will create an app and introduce an error and check for the error reporting.

  1. In the Cloud Console, launch Cloud Shell by clicking Activate Cloud Shell
mkdir appengine-hello
cd appengine-hello
gsutil cp gs://cloud-training/archinfra/gae-hello/* .
dev_appserver.py $(pwd)
  1. We can preview the application.
  2. Deploy the application.
Use “gcloud config set project [PROJECT_ID]” to change to a different project.
student_00_0716e38c9a69@cloudshell:~ (qwiklabs-gcp-00-0c5500428450)$ mkdir appengine-hello
student_00_0716e38c9a69@cloudshell:~ (qwiklabs-gcp-00-0c5500428450)$ cd appengine-hello/
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ gsutil ls gs://cloud-training/archinfra/gae-hello/
gs://cloud-training/archinfra/gae-hello/app.yaml
gs://cloud-training/archinfra/gae-hello/main.py
gs://cloud-training/archinfra/gae-hello/main.pyc
gs://cloud-training/archinfra/gae-hello/main_test.py
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ gsutil cp  gs://cloud-training/archinfra/gae-hello/ .
Omitting prefix "gs://cloud-training/archinfra/gae-hello/". (Did you mean to do cp -r?)
CommandException: No URLs matched. Do the files you're operating on exist?
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ gsutil cp  gs://cloud-training/archinfra/gae-hello/* .
Copying gs://cloud-training/archinfra/gae-hello/app.yaml...
Copying gs://cloud-training/archinfra/gae-hello/main.py...
Copying gs://cloud-training/archinfra/gae-hello/main.pyc...
Copying gs://cloud-training/archinfra/gae-hello/main_test.py...
\ [4 files][  2.5 KiB/  2.5 KiB]
Operation completed over 4 objects/2.5 KiB.
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ ls
app.yaml  main.py  main.pyc  main_test.py
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ dev
dev_appserver.py  devlink
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ dev_appserver.py $(pwd)
********************************************************************************
Python 2 is deprecated. Upgrade to Python 3 as soon as possible.
See https://cloud.google.com/python/docs/python2-sunset

To suppress this warning, create an empty ~/.cloudshell/no-python-warning file.
The command will automatically proceed in  seconds or on any key.
********************************************************************************
INFO     2021-03-12 07:52:23,003 devappserver2.py:289] Skipping SDK update check.
WARNING  2021-03-12 07:52:23,236 simple_search_stub.py:1198] Could not read search indexes from /tmp/appengine.None.student_00_0716e38c9a69/search_indexes
INFO     2021-03-12 07:52:23,238 api_server.py:282] Starting API server at: http://localhost:43067
INFO     2021-03-12 07:52:23,243 dispatcher.py:267] Starting module "default" running at: http://localhost:8080
INFO     2021-03-12 07:52:23,244 admin_server.py:150] Starting admin server at: http://localhost:8000
INFO     2021-03-12 07:52:26,256 instance.py:294] Instance PID: 1172
INFO     2021-03-12 07:52:47,357 module.py:865] default: "GET /?authuser=0 HTTP/1.1" 200 13
INFO     2021-03-12 07:52:47,404 module.py:865] default: "GET /favicon.ico HTTP/1.1" 404 154
^CINFO     2021-03-12 07:52:52,961 shutdown.py:50] Shutting down.
INFO     2021-03-12 07:52:52,961 stub_util.py:377] Applying all pending transactions and saving the datastore
INFO     2021-03-12 07:52:52,961 stub_util.py:380] Saving search indexes
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ ls
app.yaml  main.py  main.pyc  main_test.py
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ gcloud app deploy app.yaml
You are creating an app for project [qwiklabs-gcp-00-0c5500428450].
WARNING: Creating an App Engine application for a project is irreversible and the region
cannot be changed. More information about regions is at
<https://cloud.google.com/appengine/docs/locations>.

Please choose the region where you want your App Engine application
located:

 [1] asia-east2    (supports standard and flexible and search_api)
 [2] asia-northeast1 (supports standard and flexible and search_api)
 [3] asia-northeast2 (supports standard and flexible and search_api)
 [4] asia-northeast3 (supports standard and flexible and search_api)
 [5] asia-south1   (supports standard and flexible and search_api)
 [6] asia-southeast2 (supports standard and flexible and search_api)
 [7] australia-southeast1 (supports standard and flexible and search_api)
 [8] europe-west   (supports standard and flexible and search_api)
 [9] europe-west2  (supports standard and flexible and search_api)
 [10] europe-west3  (supports standard and flexible and search_api)
 [11] europe-west6  (supports standard and flexible and search_api)
 [12] northamerica-northeast1 (supports standard and flexible and search_api)
 [13] southamerica-east1 (supports standard and flexible and search_api)
 [14] us-central    (supports standard and flexible and search_api)
 [15] us-east1      (supports standard and flexible and search_api)
 [16] us-east4      (supports standard and flexible and search_api)
 [17] us-west2      (supports standard and flexible and search_api)
 [18] us-west3      (supports standard and flexible and search_api)
 [19] us-west4      (supports standard and flexible and search_api)
 [20] cancel
Please enter your numeric choice:  8

Creating App Engine application in project [qwiklabs-gcp-00-0c5500428450] and region [europe-west]....done.
Services to deploy:

descriptor:      [/home/student_00_0716e38c9a69/appengine-hello/app.yaml]
source:          [/home/student_00_0716e38c9a69/appengine-hello]
target project:  [qwiklabs-gcp-00-0c5500428450]
target service:  [default]
target version:  [20210312t075418]
target url:      [https://qwiklabs-gcp-00-0c5500428450.ew.r.appspot.com]


Do you want to continue (Y/n)?  y

Beginning deployment of service [default]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 3 files to Google Cloud Storage                ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...done.
Setting traffic split for service [default]...done.
Deployed service [default] to [https://qwiklabs-gcp-00-0c5500428450.ew.r.appspot.com]

You can stream logs from the command line by running:
  $ gcloud app logs tail -s default

To view your application in the web browser run:
  $ gcloud app browse
  
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ gcloud app browse
Did not detect your browser. Go to this link to view your app:
https://qwiklabs-gcp-00-0c5500428450.ew.r.appspot.com
  1. Adding an error in the application.
sed -i -e 's/webapp2/webapp22/' main.py
  1. Deploy the app.
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ gcloud app deploy app.yaml --quiet
Services to deploy:

descriptor:      [/home/student_00_0716e38c9a69/appengine-hello/app.yaml]
source:          [/home/student_00_0716e38c9a69/appengine-hello]
target project:  [qwiklabs-gcp-00-0c5500428450]
target service:  [default]
target version:  [20210312t080043]
target url:      [https://qwiklabs-gcp-00-0c5500428450.ew.r.appspot.com]


Beginning deployment of service [default]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 1 file to Google Cloud Storage                 ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...done.
Setting traffic split for service [default]...done.
Deployed service [default] to [https://qwiklabs-gcp-00-0c5500428450.ew.r.appspot.com]

You can stream logs from the command line by running:
  $ gcloud app logs tail -s default

To view your application in the web browser run:
  $ gcloud app browse
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$ gcloud app browse
Did not detect your browser. Go to this link to view your app:
https://qwiklabs-gcp-00-0c5500428450.ew.r.appspot.com
student_00_0716e38c9a69@cloudshell:~/appengine-hello (qwiklabs-gcp-00-0c5500428450)$
  1. We can see the error on the browser.
Error: Server Error
The server encountered an error and could not complete your request.

Please try again in 30 seconds.
  1. Explore Cloud Error Reporting

Navigate to Error Reporting.

ImportError: No module named webapp22

More details .

ImportError: No module named webapp22
	at <module> (/base/data/home/apps/e~qwiklabs-gcp-00-0c5500428450/20210312t080043.433667159418270314/main.py:15)
	at LoadObject (/base/alloc/tmpfs/dynamic_runtimes/python27g/c3f07127243d7faf/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:83)
	at _LoadHandler (/base/alloc/tmpfs/dynamic_runtimes/python27g/c3f07127243d7faf/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:309)
	at Handle (/base/alloc/tmpfs/dynamic_runtimes/python27g/c3f07127243d7faf/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:238)

Raw.

Traceback (most recent call last):
  File "/base/alloc/tmpfs/dynamic_runtimes/python27g/c3f07127243d7faf/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 238, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/alloc/tmpfs/dynamic_runtimes/python27g/c3f07127243d7faf/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 309, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/alloc/tmpfs/dynamic_runtimes/python27g/c3f07127243d7faf/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 83, in LoadObject
    obj = __import__(path[0])
  File "/base/data/home/apps/e~qwiklabs-gcp-00-0c5500428450/20210312t080043.433667159418270314/main.py", line 15, in <module>
    import webapp22
ImportError: No module named webapp22

Help