Convert a prometheus query to influxdb query? (get value now-60s)

Hello,

My goal is to avoid to manage multiple services for the ‘same’ objective (monitoring).

I want to extract “Available Downtime before SST Required” chart (prometheus) from grafana-dashboards/dashboards/PXC_Galera_Graphs.json at pmm-1.x · percona/grafana-dashboards · GitHub & convert it to influxdb query.

  • Prometheus query:

“expr”: “mysql_galera_gcache_size_bytes{instance=~"$host"} /\n(rate(mysql_global_status_wsrep_replicated_bytes{instance=~"$host"}[1h])+rate(mysql_global_status_wsrep_received_bytes{instance=~"$host"}[1h]))”,

  • Human query:
    128/(wsrep_received_bytes(last) – wsrep_received_bytes(-60s)) + (second wsrep_replicated_bytes(last) – wsrep_replicated_bytes(-60s))

  • Influxdb query (I want something like if possible…):

SELECT 128/(last((“wsrep_received_bytes”)-(-60s(“wsrep_received_bytes”)))+(last(“wsrep_replicated_bytes”)-(-60s(“wsrep_replicated_bytes”)))) FROM “mysql” WHERE (“host” =~ /^$cluster_node/) AND $timeFilter GROUP BY time($__interval), “host” fill(none)

My issue is that I don’t know how to get the last not null data 60 sec before.

Do you have an idea?

Best regards,

I think this is the equivalent to prometheus rate [1h]. Can you check if they result similar?

 non_negative_derivative(mean(your_field), 1s) group by time(1h)

Thank you @mert!

I do it like (to have the downtime before SST by minute in the last 30 min):
SELECT 128/((difference(last(“wsrep_received_bytes”))/1024/1024)+(difference(last(“wsrep_replicated_bytes”))/1024/1024)) FROM “mysql” WHERE (“host” =~ /^$cluster_name/) AND time > now() - 30m GROUP BY time(1m), “host” fill(none)

After check, I have the same result that with manual calculation.

Best regards,