Giter VIP home page Giter VIP logo

snow-grafana-proxy's Introduction

Coverity Scan Build Status

snow-grafana-proxy

Connections schema

This is a proxy-like service translating grafana simplejson data source calls into calls to ServiceNow REST API getting the items from incident table. Effectively allowing allowing integration of grafana dashboard with ServiceNow.

Configuration file is preatty self-explanatory. You just have to give the details like your ServiceNow instance URL, user and password allowed to access ServiceNow API and configure queries you'd like to make available for grafana. If you want you can find some "explanation" of those options on my blog post: https://funinit.wordpress.com/2018/07/20/integration-for-servicenow-table-api-and-grafana/

If you'd like to learn more about 1st version of snow-grafana-proxy you can check my blog post: https://funinit.wordpress.com/2018/02/20/simple-integration-of-servicenow-and-grafana/

Runtime options

snow-grafana-proxy.py accepts two options, as explained by help:

usage: snow-grafana-proxy.py [-h] [-c CONFIGFILE] [-d]

Simple JSON data source for grafana retreving data from service-now

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIGFILE, --configFile CONFIGFILE
                        Configuration file to use
  -d, --debug           Start in foreground and print all logs to stdout

Commercial support and feature development

Snow grafana proxy is distributed under MIT license, however, if anyone is interested in getting a commercial support model or sponsoring a certain feature development for ServiceNow and grafana integration proxy please contact Snow-grafana-proxy support

Configuration file

Current configuration file schema is in YAML format with two basic dictionaries: "service" and "service-now". In service dictionary you define parameters of your snow-grafana-proxy service like address to bind, port, log level and file to log output. In "service-now" section we have basic parameters like service-now instance address, api user and password for simple authntication and queries dictionary.

Queries configuration

Each query will appear as separate option available under metrics configuration in grafana(remember to pick table time, not timeseries from the first list). Query will use service-now table API to get the information from configured table, using value of a snowFilter option as an argument allowing to filter results on snow side. snow-grafana-proxy will forward to grafana only parameters listed in attributes list. For some attributes to make them more meaningful there is a need to use an interpreter, currently supported interpreters are:

none

Simply return value of attribute specified in "name" argumnet.

map

Use map dictionary defined and send corresponding values assuming that service-now returned value is a key for map dictionary,

object_attr_by_link

Assumes that for this attribute service-now API returns value/link pair. In this case additional lookup to link is required to get really meaningful data. This interpreter requires additional parameters specified in interpreterParameters dictionary, for instance: interpreterParams: { linkAttribute: "name", default: "FailedToGetName"} will get the value of name returned from the link from previous call in case of failure returning the value "FailedToGetName". Default value is important since sometimes the value is realy undefined - like assignemnt group for unassigned incident.

Changelog

22-02-2019 First contributor joined the project with merge request. Thanks to @vasekch for:

  • Making the code compliant with PEP8
  • Adding verifySSL option to configuration file (instead of ignoring SSL by default)

22-08-2018 Merge of aws-lambda "subproject"

17-07-2018 beta release of second version commited. It allows much more flexible configuration, getting data from any service-now table and arbitrary set of attributes.

15-03-2018 Use logging instead of dirty print.

20-02-2018 Initial working version.

snow-grafana-proxy's People

Contributors

cinek810 avatar vasekch-arm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

snow-grafana-proxy's Issues

Support for Python 3

Hi, initially thank you for the great solution.
It would be great to implement this for Python 3 as well.

First issue when executed with Python 3 is BaseHTPServer -> http.server difference:

Traceback (most recent call last):
  File "./snow-grafana-proxy.py", line 9, in <module>
    from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
ImportError: No module named 'BaseHTTPServer'

Spacing between columns

Hi,

I am not sure if this is a Grafana issue or a code issue but spacing between columns is not equal when displaying multiple tables.

image

Support for row count in Singlestat panel

It would be great if one can use snow-grafana-proxy with singlestat panel to display number of rows in the result.

Currently it's showing one value from the chosen column.

image

I know this may be actually requirement for the simple-json plugin, but things seem quite complicated in that area.

If we can make this plugin to return one column called count and one row with value, it would be easy.

Perhaps miss-use a bit query type timeserie? What do you think?

KeyError: 'logfile'

./snow-grafana-proxy.py

Traceback (most recent call last):
File "./snow-grafana-proxy.py", line 137, in
logging.basicConfig(filename=config['service']['logfile'],level=getattr(logging,config['service']['loglevel'].upper()))
File "/usr/lib/python2.7/site-packages/backports/configparser/init.py", line 1279, in getitem
raise KeyError(key)
KeyError: 'logfile'

NameError: global name 'slef' is not defined

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

TypeError: string indices must be integers

./snow-grafana-proxy.py
127.0.0.1 - - [25/May/2018 12:58:09] "POST /query HTTP/1.1" 200 -
/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)

Exception happened during processing of request from ('127.0.0.1', 55578)
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 104, in do_POST
self.knownUsers[incident["assigned_to"]["value"]]=self._get_person_by_link(incident["assigned_to"]["link"])["last_name"]
TypeError: string indices must be integers

snow-grafana-proxy.log:

"assigned_to": "",
"assignment_group": {
"link": "https://test.service-now.com/api/now/table/sys_user_group/d627dceec0a8016710a232a0f7904d06",
"value": "d627dceec0a8016710a232a0f7904d06"
},

or

"assigned_to": {
"link": "https://test.service-now.com/api/now/table/sys_user/eb53354d371e67109d6b13b853890e78",
"value": "eb53354d371e67109d6b13b853890e78"
},
"assignment_group": {
"link": "https://test.service-now.com/api/now/table/sys_user_group/d627dceec0a8016710a232a0f7904d06",
"value": "d627dceec0a8016710a232a0f7904d06"
},

Verify SSL by default and add configuration option

Please make verified SSL request default option, change following line to True:

snow.verify=False

Introduce new config parameter do disable SSL verification for those, who need it.

New etc/snow-grafana-proxy.conf:

...
service-now:
        instance:
                url: https://instance.service-now.com
                user: api-user
                password: password
                # verifySSL: no
...

I think that yaml parser would allow even values like 'yes', 'no', 1, 0, 'true' and 'false' on top of Python classic 'True', 'False', but needs testing

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.