cinek810 / snow-grafana-proxy

Connector for grafana simple-json data source and ServiceNow incidents retieved over ServiceNow API
MIT License
23 stars 5 forks source link

NameError: global name 'slef' is not defined #2

Closed srnlfk closed 6 years ago

srnlfk commented 6 years ago

Exception happened during processing of request from ('127.0.0.1', 36509) Traceback (most recent call last): File "/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock self.process_request(request, client_address) File "/usr/lib64/python2.7/SocketServer.py", line 321, in process_request self.finish_request(request, client_address) File "/usr/lib64/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "./snow-grafana-proxy.py", line 21, in init super(SnowRequestsHandler, self).init(*args,**kwargs) File "/usr/lib64/python2.7/SocketServer.py", line 649, in init self.handle() File "/usr/lib64/python2.7/BaseHTTPServer.py", line 340, in handle self.handle_one_request() File "/usr/lib64/python2.7/BaseHTTPServer.py", line 328, in handle_one_request method() File "./snow-grafana-proxy.py", line 39, in do_GET logging.info("GET"+slef.path) NameError: global name 'slef' is not defined

cinek810 commented 6 years ago

Sorry.. it looks like i have not commited some last fixes. I'll check it tomorrow but the one you've pasted above should be fixed now

srnlfk commented 6 years ago

Hi, thanks for your great work. It's fixed. Still, I get nothing displayed.

INFO:root:Starting grafana simple json to snow proxy server INFO:root:POST/query DEBUG:root:Client send: { "interval": "12h", "range": { "to": "2018-05-22T10:48:47.199Z", "from": "2013-05-22T10:48:47.199Z", "raw": { "to": "now", "from": "now-5y" } }, "rangeRaw": { "to": "now", "from": "now-5y" }, "intervalMs": 43200000, "panelId": 2, "scopedVars": { "interval": { "text": "12h", "value": "12h" }, "interval_ms": { "text": 43200000, "value": 43200000 } }, "timezone": "browser", "targets": [ { "type": "table", "target": "SELECT incident_number,assigned_to_last_name FROM incidents where incident_state not in 6,7,8", "refId": "A" } ], "maxDataPoints": 1896 } DEBUG:root:My snow filter is:sysparm_query=assignment_group=1st-Level^active=true^incident_stateNOT IN 6,7,8 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): test.service-now.com DEBUG:urllib3.connectionpool:https://test.service-now.com:443 "GET //api/now/table/incident?sysparm_query=assignment_group=1st-Level%5Eactive=true%5Eincident_stateNOT%20IN%206,7,8 HTTP/1.1" 200 None DEBUG:root:Results from service-now in json format:[] DEBUG:root:Reply to grafana:[{"rows": [], "type": "table", "columns": [{"text": "Number", "type": "string"}, {"text": "Assigned to", "type": "string"}, {"text": "Incident state", "type": "string"}]}]

cinek810 commented 6 years ago

There are a few things I'd check. 1st is if the filter is correct for your environment in my case it means that incident is active - state numbers, another question is assignment_group is correct. It looks like you get HTTP 200 which means that everything is fine, but the JSON is empty so maybe nothing is matching the filter - did you try to reconfigure ? Maybe leave assignment_group=1st-Level only?

srnlfk commented 6 years ago

I tried with assignment_group=1st-Level only (and other groups too), but still nothing displayed. The curl example request from your blog post is working.

cinek810 commented 6 years ago

you mean this one: #curl -G --data-urlencode "active=true" --header "Accpet: application/json" --user user:pass https://instance.service-now.com/api/now/table/incident It doesn't have filtering by assignemnt_group, so maybe this is the issue - try to remove assignment_group=...%5E from your filter and check what's returned

srnlfk commented 6 years ago

I had to change the filter from assignment_group to assignment_group_selfservice. Now I do get the tickets in the log, but still the table can't show any data and I get this error:

Exception happened during processing of request from ('127.0.0.1', 35335) Traceback (most recent call last): File "/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock self.process_request(request, client_address) File "/usr/lib64/python2.7/SocketServer.py", line 321, in process_request self.finish_request(request, client_address) File "/usr/lib64/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "./snow-grafana-proxy.py", line 21, in init super(SnowRequestsHandler, self).init(*args,**kwargs) File "/usr/lib64/python2.7/SocketServer.py", line 649, in init self.handle() File "/usr/lib64/python2.7/BaseHTTPServer.py", line 340, in handle self.handle_one_request() File "/usr/lib64/python2.7/BaseHTTPServer.py", line 328, in handle_one_request method() File "./snow-grafana-proxy.py", line 106, in do_POST queryReply[0]["rows"].append([ incident["number"], self.knownUsers[incident["assigned_to"]["value"]], incidents_description[incident["incident_state"]]]) KeyError: u'9'

Thanks for your help!

cinek810 commented 6 years ago

Sorry for late reply. It looks like a separate issue. Could you please attach not only this error but also a few additional lines logged by the service before the error and add add it as a new issue. Looks like the original one was resolved, so I'm closing this one.