Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-21 15:06:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-21 15:06:14 +0300
commit664c4c7b49c6056136299817eb79e9f1de83e567 (patch)
treeff9e4f53481d42284f82664722278e05f5bbbcbd /lib/grafana
parent6791eefead979110cc773720daee6e58c56483d9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/grafana')
-rw-r--r--lib/grafana/client.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/grafana/client.rb b/lib/grafana/client.rb
index 0765630f9bb..b419f79bace 100644
--- a/lib/grafana/client.rb
+++ b/lib/grafana/client.rb
@@ -11,6 +11,18 @@ module Grafana
@token = token
end
+ # @param uid [String] Unique identifier for a Grafana dashboard
+ def get_dashboard(uid:)
+ http_get("#{@api_url}/api/dashboards/uid/#{uid}")
+ end
+
+ # @param name [String] Unique identifier for a Grafana datasource
+ def get_datasource(name:)
+ # CGI#escape formats strings such that the Grafana endpoint
+ # will not recognize the dashboard name. Preferring URI#escape.
+ http_get("#{@api_url}/api/datasources/name/#{URI.escape(name)}") # rubocop:disable Lint/UriEscapeUnescape
+ end
+
# @param datasource_id [String] Grafana ID for the datasource
# @param proxy_path [String] Path to proxy - ex) 'api/v1/query_range'
def proxy_datasource(datasource_id:, proxy_path:, query: {})
@@ -57,7 +69,7 @@ module Grafana
def handle_response(response)
return response if response.code == 200
- raise_error "Grafana response status code: #{response.code}"
+ raise_error "Grafana response status code: #{response.code}, Message: #{response.body}"
end
def raise_error(message)