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
abac12d2
Commit
abac12d2
authored
Jan 02, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved error handling for targets and templates
parent
5d002e72
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
29 deletions
+53
-29
src/app/controllers/graphiteTarget.js
+23
-11
src/app/services/graphite/graphiteSrv.js
+30
-18
src/css/bootstrap.dark.min.css
+0
-0
No files found.
src/app/controllers/graphiteTarget.js
View file @
abac12d2
...
@@ -98,7 +98,7 @@ function (angular, _, config, graphiteFuncs, Parser) {
...
@@ -98,7 +98,7 @@ function (angular, _, config, graphiteFuncs, Parser) {
}
}
}
}
function
getSegmentPathUpTo
(
index
,
interpolateTemplate
)
{
function
getSegmentPathUpTo
(
index
)
{
var
arr
=
$scope
.
segments
.
slice
(
0
,
index
);
var
arr
=
$scope
.
segments
.
slice
(
0
,
index
);
return
_
.
reduce
(
arr
,
function
(
result
,
segment
)
{
return
_
.
reduce
(
arr
,
function
(
result
,
segment
)
{
...
@@ -112,7 +112,7 @@ function (angular, _, config, graphiteFuncs, Parser) {
...
@@ -112,7 +112,7 @@ function (angular, _, config, graphiteFuncs, Parser) {
return
;
return
;
}
}
var
path
=
getSegmentPathUpTo
(
fromIndex
+
1
,
true
);
var
path
=
getSegmentPathUpTo
(
fromIndex
+
1
);
return
graphiteSrv
.
metricFindQuery
(
path
)
return
graphiteSrv
.
metricFindQuery
(
path
)
.
then
(
function
(
segments
)
{
.
then
(
function
(
segments
)
{
if
(
segments
.
length
===
0
)
{
if
(
segments
.
length
===
0
)
{
...
@@ -128,6 +128,9 @@ function (angular, _, config, graphiteFuncs, Parser) {
...
@@ -128,6 +128,9 @@ function (angular, _, config, graphiteFuncs, Parser) {
return
checkOtherSegments
(
fromIndex
+
1
);
return
checkOtherSegments
(
fromIndex
+
1
);
}
}
}
}
})
.
then
(
null
,
function
(
err
)
{
$scope
.
parserError
=
err
.
message
||
'Failed to issue metric query'
;
});
});
}
}
...
@@ -157,21 +160,30 @@ function (angular, _, config, graphiteFuncs, Parser) {
...
@@ -157,21 +160,30 @@ function (angular, _, config, graphiteFuncs, Parser) {
'*'
:
getSegmentPathUpTo
(
index
)
+
'.*'
;
'*'
:
getSegmentPathUpTo
(
index
)
+
'.*'
;
return
graphiteSrv
.
metricFindQuery
(
query
)
return
graphiteSrv
.
metricFindQuery
(
query
)
.
then
(
function
(
result
)
{
.
then
(
function
(
segments
)
{
var
altSegments
=
_
.
map
(
result
.
data
,
function
(
altSegment
)
{
_
.
each
(
segments
,
function
(
segment
)
{
return
{
segment
.
html
=
segment
.
val
=
segment
.
text
;
val
:
altSegment
.
text
,
});
html
:
altSegment
.
text
,
expandable
:
altSegment
.
expandable
_
.
each
(
filterSrv
.
list
,
function
(
filter
)
{
};
segments
.
unshift
({
type
:
'template'
,
html
:
'[['
+
filter
.
name
+
']]'
,
val
:
'[['
+
filter
.
name
+
']]'
});
});
});
altSegments
.
unshift
({
val
:
'*'
,
html
:
'<i class="icon-asterisk"></i>'
});
segments
.
unshift
({
val
:
'*'
,
html
:
'<i class="icon-asterisk"></i>'
});
$scope
.
altSegments
=
altSegments
;
$scope
.
altSegments
=
segments
;
})
.
then
(
null
,
function
(
err
)
{
$scope
.
parserError
=
err
.
message
||
'Failed to issue metric query'
;
});
});
};
};
$scope
.
setSegment
=
function
(
altIndex
,
segmentIndex
)
{
$scope
.
setSegment
=
function
(
altIndex
,
segmentIndex
)
{
delete
$scope
.
parserError
;
$scope
.
segments
[
segmentIndex
].
val
=
$scope
.
altSegments
[
altIndex
].
val
;
$scope
.
segments
[
segmentIndex
].
val
=
$scope
.
altSegments
[
altIndex
].
val
;
$scope
.
segments
[
segmentIndex
].
html
=
$scope
.
altSegments
[
altIndex
].
html
;
$scope
.
segments
[
segmentIndex
].
html
=
$scope
.
altSegments
[
altIndex
].
html
;
...
...
src/app/services/graphite/graphiteSrv.js
View file @
abac12d2
...
@@ -9,25 +9,29 @@ function (angular, _, $, config) {
...
@@ -9,25 +9,29 @@ function (angular, _, $, config) {
var
module
=
angular
.
module
(
'kibana.services'
);
var
module
=
angular
.
module
(
'kibana.services'
);
module
.
service
(
'graphiteSrv'
,
function
(
$http
,
filterSrv
)
{
module
.
service
(
'graphiteSrv'
,
function
(
$http
,
$q
,
filterSrv
)
{
this
.
query
=
function
(
options
)
{
this
.
query
=
function
(
options
)
{
var
graphOptions
=
{
try
{
from
:
$
.
plot
.
formatDate
(
options
.
range
.
from
,
'%H%:%M_%Y%m%d'
),
var
graphOptions
=
{
until
:
$
.
plot
.
formatDate
(
options
.
range
.
to
,
'%H%:%M_%Y%m%d'
),
from
:
$
.
plot
.
formatDate
(
options
.
range
.
from
,
'%H%:%M_%Y%m%d'
),
targets
:
options
.
targets
,
until
:
$
.
plot
.
formatDate
(
options
.
range
.
to
,
'%H%:%M_%Y%m%d'
),
maxDataPoints
:
options
.
maxDataPoints
targets
:
options
.
targets
,
};
maxDataPoints
:
options
.
maxDataPoints
};
var
params
=
buildGraphitePostParams
(
graphOptions
);
var
params
=
buildGraphitePostParams
(
graphOptions
);
var
url
=
config
.
graphiteUrl
+
'/render/'
;
return
$http
({
return
$http
({
method
:
'POST'
,
method
:
'POST'
,
url
:
url
,
url
:
config
.
graphiteUrl
+
'/render/'
,
data
:
params
.
join
(
'&'
),
data
:
params
.
join
(
'&'
),
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
}
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
}
});
});
}
catch
(
err
)
{
return
$q
.
reject
(
err
);
}
};
};
this
.
match
=
function
(
targets
,
graphiteTargetStr
)
{
this
.
match
=
function
(
targets
,
graphiteTargetStr
)
{
...
@@ -47,7 +51,15 @@ function (angular, _, $, config) {
...
@@ -47,7 +51,15 @@ function (angular, _, $, config) {
};
};
this
.
metricFindQuery
=
function
(
query
)
{
this
.
metricFindQuery
=
function
(
query
)
{
var
url
=
config
.
graphiteUrl
+
'/metrics/find/?query='
+
query
;
var
interpolated
;
try
{
interpolated
=
filterSrv
.
applyFilterToTarget
(
query
);
}
catch
(
err
)
{
return
$q
.
reject
(
err
);
}
var
url
=
config
.
graphiteUrl
+
'/metrics/find/?query='
+
interpolated
;
return
$http
.
get
(
url
)
return
$http
.
get
(
url
)
.
then
(
function
(
results
)
{
.
then
(
function
(
results
)
{
return
_
.
map
(
results
.
data
,
function
(
metric
)
{
return
_
.
map
(
results
.
data
,
function
(
metric
)
{
...
...
src/css/bootstrap.dark.min.css
View file @
abac12d2
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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