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
9eb9bd84
Commit
9eb9bd84
authored
Jul 14, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved annotations graphite query to graphite datasource
parent
7d6eafb2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
3 deletions
+54
-3
src/app/services/annotationsSrv.js
+23
-3
src/app/services/graphite/graphiteDatasource.js
+31
-0
No files found.
src/app/services/annotationsSrv.js
View file @
9eb9bd84
...
@@ -31,10 +31,16 @@ define([
...
@@ -31,10 +31,16 @@ define([
return
promiseCached
;
return
promiseCached
;
}
}
var
graphiteMetrics
=
this
.
getGraphiteMetrics
(
filterSrv
,
rangeUnparsed
);
var
annotations
=
_
.
where
(
annotationPanel
.
annotations
,
{
enable
:
true
});
var
graphiteEvents
=
this
.
getGraphiteEvents
(
rangeUnparsed
);
promiseCached
=
$q
.
all
(
graphiteMetrics
.
concat
(
graphiteEvents
))
var
promises
=
_
.
map
(
annotations
,
function
(
annotation
)
{
var
datasource
=
datasourceSrv
.
get
(
annotation
.
datasource
);
return
datasource
.
annotationQuery
(
annotation
,
filterSrv
,
rangeUnparsed
)
.
then
(
this
.
receiveAnnotationResults
)
.
then
(
null
,
errorHandler
);
},
this
);
promiseCached
=
$q
.
all
(
promises
)
.
then
(
function
()
{
.
then
(
function
()
{
return
list
;
return
list
;
});
});
...
@@ -42,6 +48,20 @@ define([
...
@@ -42,6 +48,20 @@ define([
return
promiseCached
;
return
promiseCached
;
};
};
this
.
receiveAnnotationResults
=
function
(
results
)
{
console
.
log
(
'Annotation result!'
,
results
);
for
(
var
i
=
0
;
i
<
results
.
length
;
i
++
)
{
var
data
=
results
[
i
];
addAnnotation
({
annotation
:
data
.
annotation
,
time
:
data
.
time
,
description
:
data
.
description
,
tags
:
data
.
tags
,
data
:
data
.
text
});
}
};
this
.
getGraphiteEvents
=
function
(
rangeUnparsed
)
{
this
.
getGraphiteEvents
=
function
(
rangeUnparsed
)
{
var
annotations
=
this
.
getAnnotationsByType
(
'graphite events'
);
var
annotations
=
this
.
getAnnotationsByType
(
'graphite events'
);
if
(
annotations
.
length
===
0
)
{
if
(
annotations
.
length
===
0
)
{
...
...
src/app/services/graphite/graphiteDatasource.js
View file @
9eb9bd84
...
@@ -57,6 +57,37 @@ function (angular, _, $, config, kbn, moment) {
...
@@ -57,6 +57,37 @@ function (angular, _, $, config, kbn, moment) {
}
}
};
};
GraphiteDatasource
.
prototype
.
annotationQuery
=
function
(
annotation
,
filterSrv
,
rangeUnparsed
)
{
var
graphiteQuery
=
{
range
:
rangeUnparsed
,
targets
:
[{
target
:
annotation
.
target
}],
format
:
'json'
,
maxDataPoints
:
100
};
return
this
.
query
(
filterSrv
,
graphiteQuery
)
.
then
(
function
(
result
)
{
var
list
=
[];
for
(
var
i
=
0
;
i
<
result
.
data
.
length
;
i
++
)
{
var
target
=
result
.
data
[
i
];
for
(
var
y
=
0
;
y
<
target
.
datapoints
.
length
;
y
++
)
{
var
datapoint
=
target
.
datapoints
[
y
];
if
(
!
datapoint
[
0
])
{
continue
;
}
list
.
push
({
annotation
:
annotation
,
time
:
datapoint
[
1
]
*
1000
,
description
:
target
.
target
});
}
}
return
list
;
});
};
GraphiteDatasource
.
prototype
.
events
=
function
(
options
)
{
GraphiteDatasource
.
prototype
.
events
=
function
(
options
)
{
try
{
try
{
var
tags
=
''
;
var
tags
=
''
;
...
...
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