How to make a percentile calculation using MQL

Problem

How can you make a percentile calculation using MQL over a data type that is not a distribution type?

Environment

  • Metrics Explorer

Solution

  1. Use MQL to create a distribution value prior to invoking the percentile_from function.
    fetch gce_instance
    | metric 'compute.googleapis.com/instance/cpu/usage_time'
    | align rate(1m)
    | every 1m
    | distribution(fixed_width(0.2).num_buckets(5) )
    | percentile_from (90)