Grafana to use substraction of two fields in Elasticsearch data source

  1. I have two fields, called 'status_codes' and requests
  2. I want to get number of failed requests.
  3. My equation is [requests - no of success requests]
  4. In the script i wrote something like this _value - doc['@status_codes.200'].value

BUT the value return in the graph is 'N/A'

I'm using elasticsearch(7.6.0) and Grafana(6.6.2).

Following is the out file which i'm sending to elasticsearch

{   "latencies":{


      "Post http://www: dial tcp> socket: too many open files",
      "Post http://www: dial tcp: lookup on dial udp 10.20.30:45: socket: too many open files"




Also I have used Singlestat plugin as @yash mentioned, but still i could resolve the issue. Query section

Visualization section

Can someone help me