How Make Select Case When from ElasticSearch

Hello,

I have an integration between Grafana and SQL Server, but I want to change to ElasticSearch, but I need to know how to do this query in Grafana with for ElasticSeacrh:

"SELECT
dbo.access.time,
case when dbo.access.time> 45000 or dbo.access.cod_status = 500 then 0 else 100 end as 'Uptime'
From
dbo.access
WHERE
$ __ timeFilter (dbo.access.time) "

How I do it so that it works for me in ElasticSearch assuming it has the same fields.

Please your help.

This could help: https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-functions-conditional.html

If you use then https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate.html you can see what is generated behind the scene.

1 Like