0
  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":{
      "total":3981710268690,
      "mean":43876078,
      "50th":916913,
      "90th":2217744,
      "95th":5162430,
      "99th":60233348,
      "max":60000209373,
      "min":43652

},
   "@version":"1",
   "latest":"2020-03-05T16:14:44.23387091Z",
   "path":"test23.json",
   "duration":61163899322,
   "wait":552109,
   "status_codes":{
      "0":90624,
      "200":125

},
   "earliest":"2020-03-05T16:13:43.069971588Z",
   "rate":1483.702004057131,
   "throughput":2.0436707446156577,
   "@timestamp":"2020-03-05T16:14:44.453Z",
   "errors":[
      "Post http://www: dial tcp 0.0.0.0:0->10.133.9.87:8688: socket: too many open files",
      "Post http://www: dial tcp: lookup internal-netty-load-balancer-937469711.us-east-1.elb.amazonaws.com on 10.20.30.30: dial udp 10.20.30:45: socket: too many open files"

],
   "bytes_in":{
      "mean":70.90298515686123,
      "total":6434375

},
   "requests":90749,
   "Report_Title":"test23",
   "host":"ABS",
   "success":0.0013774256465635985,
   "end":"2020-03-05T16:14:44.234423019Z",
   "bytes_out":{
      "mean":70.90298515686123,
      "total":6434375

}
}

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

Visualization section

Can someone help me

2 Answers2

0

This is a fairly easy task. You just need to use either of the 'Singlestat Math' or 'Metaqueries' plugin for that. What you need to do is, use the count metric in two queries in the same panel, one for getting the count of successful status codes, and other for unsuccessful status codes. Then you can use either of the plugin to subtract the value of result of query one query from another.

https://grafana.com/grafana/plugins/blackmirror1-singlestat-math-panel https://grafana.com/grafana/plugins/goshposh-metaqueries-datasource

I suggest you go with the singlestat math plugin, it would be easier to work with, from my experience. Note: The calculation (A-B) is done in the visualization section and not in query section, in the singlestat math plugin.

P.S. singlestat-math plugin actually adds a new panel in the visualization section. It's a different panel than the default singlestat panel.

yash
  • 356
  • 3
  • 8
  • - Thanks you your reply. I tried above steps, but still i couldn't resolve my issue. I updated original post with the plugin screenshots – user2491134 Mar 10 '20 at 04:06
  • @user2491134 You are using the singlestat panel. I mentioned to use the singlestat math panel plugin. – yash Mar 10 '20 at 19:23
0

Finally I found the the solution as follow,

solution

Thanks everyone.