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

Query Problems and Change requests tables in servicenow #4

Closed baffonso closed 6 years ago

baffonso commented 6 years ago

Hi,

Would it be possible to add something to query the Problems and Change requests table. We would like to list the Change and Problem ticket status.

Thank you.

cinek810 commented 6 years ago

For sure it's possible, however, Idon't have access to those tables in environment I use. Are you aware of any public snow instance I can use for development?

cinek810 commented 6 years ago

@baffonso an update for you - I have access to developer instance from service-now.com and I think I'll be able to rewritte the service to support table of user choice.

baffonso commented 6 years ago

Thank you. I don't know of a public snow instance.

cinek810 commented 6 years ago

@baffonso Are you able to check the code available under newVersion branch? I'd call it beta release, it doesn't have proper documentation but it's quite obvious how to use it. I'll add some docs in a few days.

baffonso commented 6 years ago

Thank you. I will give it a try later today and give feedback.

cinek810 commented 6 years ago

@baffonso did you have a chance to check ?

baffonso commented 6 years ago

No, not yet. Will test sometime this weekend. Thank you.

On Sat, Jul 21, 2018 at 5:08 AM, Marcin notifications@github.com wrote:

@baffonso https://github.com/baffonso did you have a chance to check ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cinek810/snow-grafana-proxy/issues/4#issuecomment-406782639, or mute the thread https://github.com/notifications/unsubscribe-auth/ANNWvANG9HKNwPeTBHvR9nMc8dmkyVn8ks5uIu-ZgaJpZM4VPYjo .

baffonso commented 6 years ago

./snow-grafana-proxy.py Starting in daemon mode... Traceback (most recent call last): File "./snow-grafana-proxy.py", line 214, in with daemon.DaemonContext(signal_map={ signal.SIGTERM: shutdown, signal.SIGTSTP: shutdown }): AttributeError: 'module' object has no attribute 'DaemonContext'

cinek810 commented 6 years ago

Do you have python-daemon installed, pip install python-daemon ?

baffonso commented 6 years ago

thanks I installed python-daemon and scripts runs but nothing shows up in grafana (get 'no data to show'). Data source setup is fine.

cinek810 commented 6 years ago

anything in snow-grafana-proxy log file?

baffonso commented 6 years ago

nothing significant:

INFO:root:My loglevel is:info INFO:root:Starting grafana simple json to snow proxy server INFO:root:My loglevel is:info INFO:root:Starting grafana simple json to snow proxy server INFO:root:My loglevel is:info INFO:root:My loglevel is:info

cinek810 commented 6 years ago

can you try to run it with -d option and check if anything shows up in stdout ?

baffonso commented 6 years ago

INFO:root:My loglevel is:info INFO:root:Starting grafana simple json to snow proxy server INFO:root:POST/search DEBUG:root:Client send: { "target": "" } DEBUG:root:Service reply is:["get_my_incidents", "get_my_sctasks"] INFO:root:POST/search DEBUG:root:Client send: { "target": "" } DEBUG:root:Service reply is:["get_my_incidents", "get_my_sctasks"] INFO:root:POST/query DEBUG:root:Client send: { "interval": "10s", "scopedVars": { "interval": { "text": "10s", "value": "10s" }, "interval_ms": { "text": 10000, "value": 10000 } }, "range": { "to": "2018-07-23T14:59:52.077Z", "from": "2018-07-23T08:59:52.077Z", "raw": { "to": "now", "from": "now-6h" } }, "rangeRaw": { "to": "now", "from": "now-6h" }, "intervalMs": 10000, "panelId": 58, "dashboardId": 10, "timezone": "browser", "adhocFilters": [], "targets": [ { "type": "timeserie", "target": "get_my_sctasks", "refId": "A" } ], "maxDataPoints": 1920 } DEBUG:root:My query target is:{'cacheTime': 60, 'table': 'sc_task', 'snowFilter': 'sysparm_query=assignment_group=GROUP_SYS_ID^active=true', 'attributes': [{'interpreter': 'object_attr_by_link', 'displayName': 'Assigned to', 'name': 'assigned_to', 'interpreterParams': {'default': 'FailedToGetName', 'linkAttribute': 'name'}}, {'interpreter': 'none', 'displayName': 'Number', 'name': 'num ber'}]} DEBUG:root:My snow filter is:sysparm_query=assignment_group=GROUP_SYS_ID^active=true INFO:root:Starting request to service-now, to https://myserver.service-now.com//api/now/table/sc_task params=sysparm_query=assignment_group=GROUP_SYS_ID^active=true DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myserver.service-now.com:443 DEBUG:urllib3.connectionpool:https://myserver.service-now.com:443 "GET //api/now/table/sc_task?sysparm_query=assignment_group=GROUP_SYS_ID%5Eactive=true HTTP/1.1" 200 None DEBUG:root:Service-now returned 200 message in json format:{ "result": [] } DEBUG:root:Reply to grafana:[{"rows": [], "type": "table", "columns": [{"text": "Assigned to", "type": "string"}, {"text": "Number", "type": "string"}]}] INFO:root:POST/search DEBUG:root:Client send: { "target": "" } DEBUG:root:Service reply is:["get_my_incidents", "get_my_sctasks"] INFO:root:POST/query DEBUG:root:Client send: { "interval": "10s", "scopedVars": { "interval": { "text": "10s", "value": "10s" }, "interval_ms": { "text": 10000, "value": 10000 } }, "range": { "to": "2018-07-23T15:00:04.249Z", "from": "2018-07-23T09:00:04.249Z", "raw": { "to": "now", "from": "now-6h" } }, "rangeRaw": { "to": "now", "from": "now-6h" }, "intervalMs": 10000, "panelId": 58, "dashboardId": 10, "timezone": "browser", "adhocFilters": [], "targets": [ { "type": "timeserie", "target": "get_my_incidents", "refId": "A" } ], "maxDataPoints": 1920 } DEBUG:root:My query target is:{'cacheTime': 60, 'table': 'incident', 'snowFilter': 'sysparm_query=assignment_group=GROUP_SYS_ID^active=true^incident_stateNOT IN 6,7,8', 'attributes': [{'interpre ter': 'object_attr_by_link', 'displayName': 'Assigned to', 'name': 'assigned_to', 'interpreterParams': {'default': 'FailedToGetName', 'linkAttribute': 'name'}}, {'interpreter': 'none', 'displayN ame': 'Number', 'name': 'number'}, {'interpreter': 'map', 'displayName': 'State', 'name': 'state', 'map': {'1': 'Unknown', '3': 'Assigned', '2': 'Onhold', '7': 'Inprogres'}}]} DEBUG:root:My snow filter is:sysparm_query=assignment_group=GROUP_SYS_ID^active=true^incident_stateNOT IN 6,7,8 INFO:root:Starting request to service-now, to https://myserver.service-now.com//api/now/table/incident params=sysparm_query=assignment_group=GROUP_SYS_ID^active=true^incident_stateNOT IN 6,7,8 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myserver.service-now.com:443 DEBUG:urllib3.connectionpool:https://myserver.service-now.com:443 "GET //api/now/table/incident?sysparm_query=assignment_group=GROUP_SYS_ID%5Eactive=true%5Eincident_stateNOT%20IN%206,7,8 HTTP/1.1 " 200 None DEBUG:root:Service-now returned 200 message in json format:{ "result": [] } DEBUG:root:Reply to grafana:[{"rows": [], "type": "table", "columns": [{"text": "Assigned to", "type": "string"}, {"text": "Number", "type": "string"}, {"text": "State", "type": "string"}]}] INFO:root:POST/search DEBUG:root:Client send: { "target": "" } DEBUG:root:Service reply is:["get_my_incidents", "get_my_sctasks"]

cinek810 commented 6 years ago

It looks like you didn't adjust the configuration to reflect your service now instance/user/filter (assignemnt group?)

baffonso commented 6 years ago

thanks...appears to be working now. I just read your latest blog post which clarifies everything. I will let you know if I run into issues setting up other tables.

cinek810 commented 6 years ago

I'm glad it worked out!