0
0
GCPcloud~5 mins

Operational excellence in GCP - Commands & Configuration

Choose your learning style9 modes available
Introduction
Operational excellence helps you run your cloud systems smoothly and safely. It focuses on making sure your services work well, fix problems quickly, and improve over time.
When you want to monitor your cloud applications to catch issues early.
When you need to automate responses to common problems to reduce downtime.
When you want to keep your cloud resources organized and secure.
When you want to learn from incidents and improve your system's reliability.
When you want to set up alerts to notify your team about important events.
Commands
This command creates a logging sink that exports logs from your App Engine application to a Cloud Storage bucket. It helps you keep logs for analysis and troubleshooting.
Terminal
gcloud logging sinks create my-sink storage.googleapis.com/my-bucket --log-filter="resource.type=gae_app"
Expected OutputExpected
Created sink [my-sink].
--log-filter - Filters logs to only include those from App Engine applications.
This command creates an alerting policy that notifies you when a Compute Engine instance's CPU usage goes above 80% for more than 60 seconds. It helps you react quickly to performance issues.
Terminal
gcloud monitoring policies create --notification-channels=projects/my-project/notificationChannels/1234567890 --condition-display-name="High CPU Usage" --condition-filter="metric.type=compute.googleapis.com/instance/cpu/utilization AND resource.type=gce_instance" --condition-threshold-value=0.8 --condition-comparison=COMPARISON_GT --condition-duration=60s
Expected OutputExpected
Created alerting policy [projects/my-project/alertPolicies/9876543210].
--notification-channels - Specifies where alerts are sent, like email or SMS.
--condition-filter - Defines which metric and resource to monitor.
This command deploys infrastructure using a Deployment Manager configuration file. It helps you manage resources consistently and track changes.
Terminal
gcloud deployment-manager deployments create my-deployment --config deployment.yaml
Expected OutputExpected
Create operation operation-1234567890-abcdef started. NAME TYPE STATE ERRORS my-deployment deploymentmanager.v2beta.type RUNNING []
--config - Specifies the configuration file describing the resources.
This command shows details about your deployment, including status and any errors. It helps you verify that your infrastructure is set up correctly.
Terminal
gcloud deployment-manager deployments describe my-deployment
Expected OutputExpected
name: my-deployment operation: status: DONE error: null operationType: insert targetLink: https://www.googleapis.com/deploymentmanager/v2/projects/my-project/global/deployments/my-deployment user: user@example.com
Key Concept

If you remember nothing else from this pattern, remember: monitoring, alerting, and managing resources help keep your cloud systems reliable and easy to fix.

Common Mistakes
Not setting up log sinks or alerting policies after deploying applications.
Without logs and alerts, you won't know when problems happen or how to fix them quickly.
Always create log sinks and alerting policies to monitor your applications and get notified of issues.
Using overly broad log filters that collect too much data.
This can cause high storage costs and make it hard to find important information.
Use specific filters to collect only the logs you need for troubleshooting.
Ignoring deployment status and errors after running deployment commands.
You might miss failed resource creations or misconfigurations that cause downtime.
Always check deployment status and fix any errors reported.
Summary
Create log sinks to export and keep important logs for troubleshooting.
Set up alerting policies to get notified about critical issues like high CPU usage.
Use deployment tools to manage cloud resources consistently and check deployment status.