I'm attempting to calculate the sum of disk space used by specific log types and present them in a metric element in Canvas. For example, Winlogbeat: 3.8 TB, DNS: 2.8 TB, etc.
I've written a SQL query that returns the expected result in dev tools:
POST _xpack/sql
{
"query":"SELECT ROUND(SUM(index_stats.total.store.size_in_bytes)/1073741824) AS storage FROM ".monitoring-es-6*" WHERE index_stats.index LIKE '%winlogbeat%' AND type = 'index_stats' AND timestamp > NOW() - INTERVAL 9 SECOND AND timestamp < NOW()"
}
This returns the result I expect:
{"columns":[{"name":"storage","type":"long"}],"rows":[[2896.0]]}
I'm trying to get this number to display in a metric element in Canvas. If I choose "Elasticsearch SQL" as my data source and use the exact same query (below), and choose to display the value of "storage," Canvas displays a zero.
SELECT ROUND(SUM(index_stats.total.store.size_in_bytes)/1073741824) AS storage FROM ".monitoring-es-6*" WHERE index_stats.index LIKE '%winlogbeat%' AND type = 'index_stats' AND timestamp > NOW() - INTERVAL 9 SECOND AND timestamp < NOW()
If I change the settings to display a count, it shows a one (so I believe a result was returned). I don't understand why I'm seeing a zero and not ~2896. Here's the expression being used for the purpose of reproducing:
filters
| essql
query="SELECT ROUND(SUM(index_stats.total.store.size_in_bytes)/1073741824) AS storage FROM \".monitoring-es-6*\" WHERE index_stats.index LIKE '%winlogbeat%' AND type = 'index_stats' AND timestamp > NOW() - INTERVAL 9 SECOND AND timestamp < NOW()"
| math "storage"
| metric "Used Disk Space"
metricFont={font size=48 family="'Open Sans', Helvetica, Arial, sans-serif" color="#000000" align="center" lHeight=48}
labelFont={font size=14 family="'Open Sans', Helvetica, Arial, sans-serif" color="#000000" align="center"}
| render
Obviously I'm new to both ES SQL and Canvas, so entirely possible the issue is due to my own ignorance.