How can I show a ratio between two timeseries

  • What Grafana version and what operating system are you using?
    9.4.7 on linux

  • What are you trying to achieve?
    Ultimately I want to create an alert when consumed container memory is above 90% of allocated container memory. Both allocated and consumed memory are available as time series

  • How are you trying to achieve it?

  • What happened?
    The expression E shows ‘no data’ as soon as I start combining $C and $D (by themselves C and D show data

  • What did you expect to happen?
    E should be a time series of the ratio, fluctuating between 0 and 1 depending on the amount of used memory

  • Can you copy/paste the configuration(s) that you are having problems with?
    Everything is in the screenshot

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    There are no errors on screen, I have no access to the logs

  • Did you follow any online instructions? If so, what is the URL?
    Documentation -
    Write expression queries | Grafana documentation

DUH, looks like I can simplify this by calculating the ratio directly in the prometheus query:

container_memory_usage_bytes{marathon_app_id=~".*$service_name.*"} / container_spec_memory_limit_bytes{marathon_app_id=~".*$service_name.*"}

(will need to experiment a bit to prevent division by zero when some values are not avialable)