Git Product home page Git Product logo

Comments (4)

schaefer01 avatar schaefer01 commented on September 25, 2024

More info. I repeated the test on ubuntu, 18.04.03
Got the same GrafanaDatastoreServer.py, summarized exception: key_error 'target'
The grafana console info, since it was a service, was caught by the journalctl command:

Sep 27 14:14:37 quasar grafana-server[4099]: 2019/09/27 14:14:37 http: proxy error: dial tcp: lookup grafana_redis_source on 127.0.0.53:53: server misbehaving
Sep 27 14:14:37 quasar grafana-server[4099]: t=2019-09-27T14:14:37-0400 lvl=info msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=GET path=/api/datasources/proxy/1/ status=502 remote
Sep 27 14:14:43 quasar grafana-server[4099]: 2019/09/27 14:14:43 http: proxy error: dial tcp: lookup grafana_redis_source on 127.0.0.53:53: server misbehaving
Sep 27 14:14:43 quasar grafana-server[4099]: t=2019-09-27T14:14:43-0400 lvl=info msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=GET path=/api/datasources/proxy/1/ status=502 remote
Sep 27 14:16:21 quasar grafana-server[4099]: t=2019-09-27T14:16:21-0400 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/datasources/proxy/1/query status=500
lines 29-51/51 (END)

from grafana-redistimeseries.

schaefer01 avatar schaefer01 commented on September 25, 2024

Hi, I got further.
The statement that exceptions is not syntactically correct. Was this ever tested?
-> targets = process_targets([t['target'] for t in request['targets']], redis_client)

I recoded for what was most likely intended:

targets = process_targets(request['targets'], redis_client)

and then the code exceptioned further down, at this line:

redis_resp = redis_client.execute_command(*args)

'args' is a list, with the 2nd element the 'target', which is a dictionary
the exception indicates that a dictionary isn't the right type, an int or string is expected.

Here's the dump:
File "/usr/local/lib/python3.7/site-packages/redis/client.py", line 838, in execute_command
conn.send_command(*args)
File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 685, in send_command
self.send_packed_command(self.pack_command(*args),
File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 736, in pack_command
for arg in imap(self.encoder.encode, args):
File "/usr/local/lib/python3.7/site-packages/redis/connection.py", line 117, in encode
"byte, string or number first." % typename)
redis.exceptions.DataError: Invalid input of type: 'list'. Convert to a byte, string or number first.

My guess is the target dictionary needs to be json'd before calling.

I'll try that and update my report. Again, was this ever tested?

One more note: the exception occurs immediately, before I try selecting the variable of interest, which makes me think the entire redis key set is dumped on connect. Is this the intent?

from grafana-redistimeseries.

schaefer01 avatar schaefer01 commented on September 25, 2024

Ok, I'm getting there. Someone (grafana?) is generating messages that should be ignored.
What the grafana-redis interface code should do, is if ['target'] doesn't exist in the "response" ['targets'] variable, is instead of exceptioning with 'target' key error, is to skip (an not call execute() with the 'targets' dictinonary anyway which is what I mistakenly did.
However, when ['target'] does exist, pass the value, ['target'] is the key of interest.
This again is a guess. I have to code it up and test.

from grafana-redistimeseries.

schaefer01 avatar schaefer01 commented on September 25, 2024

got it. I'm thinking the only way the original code could have worked was if the interface was started AFTER grafana so it wouldn't see the responses that should be ignored.
The fix is to check for existence of the key 'target' before processing.

Here is my reworking, right after the statement that contains redis_client = redis.Redis,

note: the editor might ruin the necessary indenting

t = {'target' :[]}
targets_in = []
for t in request['targets']:   
  if ('target' in t.keys()):
    targets_in = targets_in + [ t['target'] ]  
try:
  targets_out = process_targets(targets_in, redis_client)
  #targets = process_targets([t['target'] for t in request['targets']], redis_client)
except Exception as eobj:
  print("Exception in processing flask data")  # diagnostic
  print("request=")
  print(request)

for target in targets_out:
    args = ['ts.range', target, int(stime), int(etime)]
    if 'intervalMs' in request and request['intervalMs'] > 0:
        args += ['avg', int(request['intervalMs'])]
    print("args=",args)  # diagnostic
    redis_resp = redis_client.execute_command(*args)  

    datapoints = [(float(x2.decode("ascii")), x1) for x1, x2 in redis_resp]
    response.append(dict(target=target, datapoints=datapoints))
return jsonify(response)

from grafana-redistimeseries.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.