Open questions about Grafana dashboards with Elasticsearch (Grafana 7.3.1)

Hello communiy, I am new to Grafana and I have asked couple of questions here in community, but unfortunately they were left unanswered.
I will sum-up all the questions here and hope for a response from anyone from community. Thanks in advanced.

  1. Query in Variables to change the time-range of the data in comeplete dashboard:
    I want the change time ranges of the data at the dashboard level using query grafana(using variable). I tried using this query but it doesnt funtion as expected ( {​​​"find": “terms”, “field”: “qrCodeSensor.keyword”, “query”: “importTime:now-1y to now”}​​​).
    Is it possible to do something like this? If Yes, then what would be the example query.

  2. Grafana returning wrong values with ES as datasource:
    Hello everyone,
    This is the JSON format which I get from Elasticsearch for TRUE value:
    “mailAlerting”: {
    “boolValue”: true,
    “codeNumber”: 1,
    },

And this is the format for FALSE value:
“mailAlerting”: {
“boolValue”: false,
“codeNumber”: 0,
},

But unfortunately, the raw display for FALSE shows “00” instead of “0” in the AUTO Cell display mode.
The attached screenshot also shows that it shows correct values in JSON Cell value display mode.
Please let me know if this is a BUG from Grafana side or am I missing something.

Thanks in advanced.

Screenshot 2021-05-31 120507
Screenshot 2021-05-31 120544

  1. I want the Variables in dashboard to show only the last value, not all the values.

In relation to the question (How to get the latest value from range, based on time) asked by @lilach long back which was answered by you @mefraimsson. Please if possible also have a look into my qestion. This is the 4 time I have asked and unfortunately didnt get any response.

As you can see in the image, there are 2 values being displayed, but I just want to know only the last value which has come.

It would be great help if any of you can help me solve any of the above queries. Thanks in advance.

Hi @mirzafaraz1101

Re question 1:
Have you tried using global variables to dynamically select the timerange for a dashboard?

question 2:
What version of Grafana are you using?

question 3:
although your variable query returns multiple values, you should be able to limit what you display based on the visualization you choose. Many panel editors allow you to choose the latest value. Or perhaps I am not understanding you.

If you wanted to write an Elastic query that only returns the most recent value, then you might have more luck asking that in the Elastic forum, where you will find many more experts on that datasource:

I hope this helps!