Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
3cc69112
Commit
3cc69112
authored
Oct 01, 2015
by
Julius Volz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix "Link to Prometheus" button for proxied Prometheus sources.
parent
228aac2d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
12 deletions
+14
-12
pkg/api/frontendsettings.go
+5
-0
pkg/models/datasource.go
+1
-0
public/app/plugins/datasource/prometheus/datasource.js
+2
-6
public/app/plugins/datasource/prometheus/queryCtrl.js
+1
-1
public/app/plugins/datasource/prometheus/specs/datasource_specs.ts
+5
-5
No files found.
pkg/api/frontendsettings.go
View file @
3cc69112
...
@@ -81,6 +81,11 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
...
@@ -81,6 +81,11 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
dsMap
[
"index"
]
=
ds
.
Database
dsMap
[
"index"
]
=
ds
.
Database
}
}
if
ds
.
Type
==
m
.
DS_PROMETHEUS
{
// add unproxied server URL for link to Prometheus web UI
dsMap
[
"directUrl"
]
=
ds
.
Url
}
datasources
[
ds
.
Name
]
=
dsMap
datasources
[
ds
.
Name
]
=
dsMap
}
}
...
...
pkg/models/datasource.go
View file @
3cc69112
...
@@ -12,6 +12,7 @@ const (
...
@@ -12,6 +12,7 @@ const (
DS_ES
=
"elasticsearch"
DS_ES
=
"elasticsearch"
DS_OPENTSDB
=
"opentsdb"
DS_OPENTSDB
=
"opentsdb"
DS_CLOUDWATCH
=
"cloudwatch"
DS_CLOUDWATCH
=
"cloudwatch"
DS_PROMETHEUS
=
"prometheus"
DS_ACCESS_DIRECT
=
"direct"
DS_ACCESS_DIRECT
=
"direct"
DS_ACCESS_PROXY
=
"proxy"
DS_ACCESS_PROXY
=
"proxy"
)
)
...
...
public/app/plugins/datasource/prometheus/datasource.js
View file @
3cc69112
...
@@ -21,12 +21,8 @@ function (angular, _, moment, dateMath) {
...
@@ -21,12 +21,8 @@ function (angular, _, moment, dateMath) {
this
.
name
=
datasource
.
name
;
this
.
name
=
datasource
.
name
;
this
.
supportMetrics
=
true
;
this
.
supportMetrics
=
true
;
var
url
=
datasource
.
url
;
this
.
url
=
datasource
.
url
.
replace
(
/
\/
$/g
,
''
);
if
(
url
[
url
.
length
-
1
]
===
'/'
)
{
this
.
directUrl
=
datasource
.
directUrl
.
replace
(
/
\/
$/g
,
''
);
// remove trailing slash
url
=
url
.
substr
(
0
,
url
.
length
-
1
);
}
this
.
url
=
url
;
this
.
basicAuth
=
datasource
.
basicAuth
;
this
.
basicAuth
=
datasource
.
basicAuth
;
this
.
lastErrors
=
{};
this
.
lastErrors
=
{};
}
}
...
...
public/app/plugins/datasource/prometheus/queryCtrl.js
View file @
3cc69112
...
@@ -111,7 +111,7 @@ function (angular, _, kbn, dateMath) {
...
@@ -111,7 +111,7 @@ function (angular, _, kbn, dateMath) {
};
};
var
hash
=
encodeURIComponent
(
JSON
.
stringify
([
expr
]));
var
hash
=
encodeURIComponent
(
JSON
.
stringify
([
expr
]));
return
$scope
.
datasource
.
u
rl
+
'/graph#'
+
hash
;
return
$scope
.
datasource
.
directU
rl
+
'/graph#'
+
hash
;
};
};
$scope
.
calculateInterval
=
function
()
{
$scope
.
calculateInterval
=
function
()
{
...
...
public/app/plugins/datasource/prometheus/specs/datasource_specs.ts
View file @
3cc69112
...
@@ -10,11 +10,11 @@ describe('PrometheusDatasource', function() {
...
@@ -10,11 +10,11 @@ describe('PrometheusDatasource', function() {
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
ctx
.
createService
(
'PrometheusDatasource'
));
beforeEach
(
ctx
.
createService
(
'PrometheusDatasource'
));
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
ds
=
new
ctx
.
service
({
url
:
''
,
user
:
'test'
,
password
:
'mupp'
});
ctx
.
ds
=
new
ctx
.
service
({
url
:
'
proxied'
,
directUrl
:
'direct
'
,
user
:
'test'
,
password
:
'mupp'
});
});
});
describe
(
'When querying prometheus with one target using query editor target spec'
,
function
()
{
describe
(
'When querying prometheus with one target using query editor target spec'
,
function
()
{
var
results
;
var
results
;
var
urlExpected
=
'/api/v1/query_range?query='
+
var
urlExpected
=
'
proxied
/api/v1/query_range?query='
+
encodeURIComponent
(
'test{job="testjob"}'
)
+
encodeURIComponent
(
'test{job="testjob"}'
)
+
'&start=1443438675&end=1443460275&step=60s'
;
'&start=1443438675&end=1443460275&step=60s'
;
var
query
=
{
var
query
=
{
...
@@ -53,7 +53,7 @@ describe('PrometheusDatasource', function() {
...
@@ -53,7 +53,7 @@ describe('PrometheusDatasource', function() {
status
:
"success"
,
status
:
"success"
,
data
:
[
"value1"
,
"value2"
,
"value3"
]
data
:
[
"value1"
,
"value2"
,
"value3"
]
};
};
ctx
.
$httpBackend
.
expect
(
'GET'
,
'/api/v1/label/resource/values'
).
respond
(
response
);
ctx
.
$httpBackend
.
expect
(
'GET'
,
'
proxied
/api/v1/label/resource/values'
).
respond
(
response
);
ctx
.
ds
.
metricFindQuery
(
'label_values(resource)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
ds
.
metricFindQuery
(
'label_values(resource)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
ctx
.
$httpBackend
.
flush
();
ctx
.
$rootScope
.
$apply
();
ctx
.
$rootScope
.
$apply
();
...
@@ -71,7 +71,7 @@ describe('PrometheusDatasource', function() {
...
@@ -71,7 +71,7 @@ describe('PrometheusDatasource', function() {
]
]
}
}
};
};
ctx
.
$httpBackend
.
expect
(
'GET'
,
/
\/
api
\/
v1
\/
query
\?
query=count
\(
metric
\)
%20by%20
\(
resource
\)
&time=.*/
).
respond
(
response
);
ctx
.
$httpBackend
.
expect
(
'GET'
,
/
proxied
\/
api
\/
v1
\/
query
\?
query=count
\(
metric
\)
%20by%20
\(
resource
\)
&time=.*/
).
respond
(
response
);
ctx
.
ds
.
metricFindQuery
(
'label_values(metric, resource)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
ds
.
metricFindQuery
(
'label_values(metric, resource)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
ctx
.
$httpBackend
.
flush
();
ctx
.
$rootScope
.
$apply
();
ctx
.
$rootScope
.
$apply
();
...
@@ -82,7 +82,7 @@ describe('PrometheusDatasource', function() {
...
@@ -82,7 +82,7 @@ describe('PrometheusDatasource', function() {
status
:
"success"
,
status
:
"success"
,
data
:
[
"metric1"
,
"metric2"
,
"metric3"
,
"nomatch"
]
data
:
[
"metric1"
,
"metric2"
,
"metric3"
,
"nomatch"
]
};
};
ctx
.
$httpBackend
.
expect
(
'GET'
,
'/api/v1/label/__name__/values'
).
respond
(
response
);
ctx
.
$httpBackend
.
expect
(
'GET'
,
'
proxied
/api/v1/label/__name__/values'
).
respond
(
response
);
ctx
.
ds
.
metricFindQuery
(
'metrics(metric.*)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
ds
.
metricFindQuery
(
'metrics(metric.*)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
ctx
.
$httpBackend
.
flush
();
ctx
.
$rootScope
.
$apply
();
ctx
.
$rootScope
.
$apply
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment