Method: Grafana::Grafana#test_connection
- Defined in:
- lib/grafana/grafana.rb
#test_connection ⇒ String
Used to test a connection to the grafana instance.
Running this function also determines, if the API configured here has Admin or NON-Admin privileges, or even fails on connecting to grafana.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/grafana/grafana.rb', line 59 def test_connection @logger.warn('Reporter disabled the SSL verification for grafana. This is a potential security risk.') if @ssl_disable_verify if prepare_request({ relative_url: '/api/datasources' }).execute.is_a?(Net::HTTPOK) # we have admin rights @logger.warn('Reporter is running with Admin privileges on grafana. This is a potential security risk.') return 'Admin' end # check if we have lower rights or an SSL error occurs case prepare_request({ relative_url: '/api/dashboards/home' }).execute(nil, true) when Net::HTTPOK when OpenSSL::SSL::SSLError return 'SSLError' else return 'Failed' end @logger.info('Reporter is running with NON-Admin privileges on grafana.') 'NON-Admin' end |