PromQL expression with multiple subqueries doesn't work as expected

I have a PromQL query (taken from Node Exporter dashboard, so pretty standard), this query works in Prometheus, but not in NewRelic:

avg(node_load15) / count(count(node_cpu_seconds_total) by (cpu)) * 100

In NewRelic, both parts of the query work when issued independently from one another, eg:

  1. avg(node_load15)
  2. count(count(node_cpu_seconds_total) by (cpu)) * 100

Even this one works ( "count(count(node_cpu_seconds_total) by (cpu)) " is 2 in my case).

avg(node_load15) / 2 * 100

PromQL queries are translated to the following NWQL query:

SELECT ((average(node_load15) / cardinality(__result_0)) * 100) FROM (SELECT cardinality(node_cpu_seconds_total) AS __result_0 FROM Metric FACET cpu LIMIT 100 TIMESERIES 30000) SINCE 60 MINUTES AGO UNTIL NOW TIMESERIES 30000

What can it be, is this a bug? If now, what is the solution?

UPD: fixed formatting

Hello @oleksandr1 -

I know it’s been a while since you posted, but I wanted to follow up and see if you had figured this out. One thing I noticed is that you are using the count function. This is handled differently in NRQL and PROMQL. We have some notes on this in our documentation for translating PromQL to NRQL. Perhaps there is an issue there?