0
0
GCPcloud~10 mins

Metrics and dashboards in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a metric descriptor for a custom metric in Google Cloud Monitoring.

GCP
metric_descriptor = monitoring_v3.MetricDescriptor()
metric_descriptor.type = "custom.googleapis.com/[1]"
metric_descriptor.metric_kind = monitoring_v3.MetricDescriptor.MetricKind.GAUGE
metric_descriptor.value_type = monitoring_v3.MetricDescriptor.ValueType.DOUBLE
Drag options to blanks, or click blank then click option'
Amemory_usage
Bnetwork_latency
Cdisk_io
Dcpu_usage
Attempts:
3 left
💡 Hint
Common Mistakes
Using a metric name without the 'custom.googleapis.com/' prefix.
Choosing a metric name that is not descriptive.
2fill in blank
medium

Complete the code to create a dashboard widget that shows a line chart of CPU utilization.

GCP
widget = {
  "xyChart": {
    "dataSets": [{
      "timeSeriesQuery": {
        "timeSeriesFilter": {
          "filter": "metric.type = \"compute.googleapis.com/instance/cpu/utilization\"",
          "aggregation": {
            "perSeriesAligner": monitoring_v3.Aggregation.Aligner.[1]
          }
        }
      }
    }]
  }
}
Drag options to blanks, or click blank then click option'
AALIGN_MAX
BALIGN_MEAN
CALIGN_MIN
DALIGN_SUM
Attempts:
3 left
💡 Hint
Common Mistakes
Using ALIGN_SUM which sums values and may not represent average usage.
Using ALIGN_MAX or ALIGN_MIN which show extremes, not average.
3fill in blank
hard

Fix the error in the alerting policy condition filter to monitor high memory usage.

GCP
condition = {
  "conditionThreshold": {
    "filter": "metric.type = \"compute.googleapis.com/instance/memory/usage_bytes\" AND resource.type = [1]",
    "comparison": monitoring_v3.ComparisonType.COMPARISON_GT,
    "thresholdValue": 8000000000,
    "duration": "300s"
  }
}
Drag options to blanks, or click blank then click option'
A"compute_instance"
B"gce-vm"
C"gce_instance"
D"vm_instance"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect resource type strings that cause the filter to fail.
Omitting quotes around the resource type.
4fill in blank
hard

Fill both blanks to create a dashboard widget that displays a stacked bar chart of network traffic by direction.

GCP
widget = {
  "xyChart": {
    "chartOptions": {
      "mode": monitoring_v3.XyChart.ChartOptions.Mode.[1],
      "chartType": monitoring_v3.XyChart.ChartType.[2]
    },
    "dataSets": [{
      "timeSeriesQuery": {
        "timeSeriesFilter": {
          "filter": "metric.type = \"compute.googleapis.com/instance/network/received_bytes_count\" OR metric.type = \"compute.googleapis.com/instance/network/sent_bytes_count\"",
          "aggregation": {
            "perSeriesAligner": monitoring_v3.Aggregation.Aligner.ALIGN_SUM
          }
        }
      }
    }]
  }
}
Drag options to blanks, or click blank then click option'
ASTACKED
BGROUPED
CLINE
DBAR
Attempts:
3 left
💡 Hint
Common Mistakes
Using LINE mode or chart type which shows lines, not bars.
Using GROUPED mode which shows bars side by side, not stacked.
5fill in blank
hard

Fill all three blanks to define an alerting policy that triggers when average CPU utilization exceeds 70% for 5 minutes.

GCP
alert_policy = {
  "conditions": [{
    "conditionThreshold": {
      "filter": "metric.type = \"compute.googleapis.com/instance/cpu/utilization\" AND resource.type = \"[1]\"",
      "comparison": monitoring_v3.ComparisonType.[2],
      "thresholdValue": [3],
      "duration": "300s"
    }
  }]
}
Drag options to blanks, or click blank then click option'
Agce_instance
BCOMPARISON_GT
C0.7
DCOMPARISON_LT
Attempts:
3 left
💡 Hint
Common Mistakes
Using COMPARISON_LT which triggers below threshold.
Using incorrect resource type strings.
Setting threshold value as 70 instead of 0.7.