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
Which metric type prefix is valid for a user-defined custom metric?
- user.googleapis.com/
- custom.googleapis.com/
- metrics.googleapis.com/
- 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.
Which statements about user-defined log-based metrics are correct?
- A counter counts log entries matching the filter
- A distribution groups extracted numeric values into histogram buckets
- They only use entries received after the metric exists
- They backfill counts from logs written last month
- 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.
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.
