Bitzu

Associate Cloud Engineer ยท Monitoring and alerting

Custom and log-based metrics

Creating custom metrics from applications (OpenTelemetry, client library) and log-based metrics (counter, distribution), metric descriptors.

Key points

  • Custom metrics are written by your code (OpenTelemetry is the recommended route, or the Monitoring API client libraries) under prefixes such as custom.googleapis.com/ or workload.googleapis.com/.
  • Log-based metrics are created in Cloud Logging from matching log entries as a counter or a distribution, and count only entries received after creation.

Source: https://docs.cloud.google.com/monitoring/custom-metrics

Practice questions

Single choice

Which metric type prefix is valid for a user-defined custom metric?

  1. user.googleapis.com/
  2. custom.googleapis.com/
  3. metrics.googleapis.com/
  4. compute.googleapis.com/custom/
Show answer

Answer: B. custom.googleapis.com/

custom.googleapis.com/ is one of the allowed prefixes. The others are not valid custom-metric namespaces.

Select all that apply

Which statements about user-defined log-based metrics are correct?

  1. A counter counts log entries matching the filter
  2. A distribution groups extracted numeric values into histogram buckets
  3. They only use entries received after the metric exists
  4. They backfill counts from logs written last month
  5. You can choose a boolean type for them
Show answer

Answer: A. A counter counts log entries matching the filter, B. A distribution groups extracted numeric values into histogram buckets, C. They only use entries received after the metric exists

They are counters or distributions, and they only reflect entries received after creation. They do not backfill, and boolean is not a user-defined choice.

True or false

After you create a log-based metric, it automatically includes counts from log entries written before its creation.

Show answer

Answer: False

False. User-defined log-based metrics use only entries received after the metric is created.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More Associate Cloud Engineer topics in this module