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
a9a76b90
Commit
a9a76b90
authored
Jul 19, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
annotation redesign is almost done, #608
parent
cf68725c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
77 deletions
+22
-77
src/app/partials/graphite/annotation_editor.html
+2
-2
src/app/services/annotationsSrv.js
+0
-75
src/app/services/graphite/graphiteDatasource.js
+20
-0
No files found.
src/app/partials/graphite/annotation_editor.html
View file @
a9a76b90
<div
class=
"editor-row"
>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Graphite target expression
</label>
<input
type=
"text"
class=
"span10"
ng-model=
'currentAnn
n
otation.target'
placeholder=
""
></input>
<input
type=
"text"
class=
"span10"
ng-model=
'currentAnnotation.target'
placeholder=
""
></input>
</div>
</div>
<div
class=
"editor-row"
>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Graphite event tags
</label>
<input
type=
"text"
ng-model=
'currentAnn
n
otation.tags'
placeholder=
""
></input>
<input
type=
"text"
ng-model=
'currentAnnotation.tags'
placeholder=
""
></input>
</div>
</div>
...
...
src/app/services/annotationsSrv.js
View file @
a9a76b90
...
...
@@ -54,86 +54,11 @@ define([
}
};
this
.
getGraphiteEvents
=
function
(
rangeUnparsed
)
{
var
annotations
=
this
.
getAnnotationsByType
(
'graphite events'
);
if
(
annotations
.
length
===
0
)
{
return
[];
}
var
promises
=
_
.
map
(
annotations
,
function
(
annotation
)
{
return
datasourceSrv
.
default
.
events
({
range
:
rangeUnparsed
,
tags
:
annotation
.
tags
})
.
then
(
function
(
results
)
{
_
.
each
(
results
.
data
,
function
(
event
)
{
addAnnotation
({
annotation
:
annotation
,
time
:
event
.
when
*
1000
,
description
:
event
.
what
,
tags
:
event
.
tags
,
data
:
event
.
data
});
});
})
.
then
(
null
,
errorHandler
);
});
return
promises
;
};
this
.
getAnnotationsByType
=
function
(
type
)
{
return
_
.
where
(
annotationPanel
.
annotations
,
{
type
:
type
,
enable
:
true
});
};
this
.
getGraphiteMetrics
=
function
(
filterSrv
,
rangeUnparsed
)
{
var
annotations
=
this
.
getAnnotationsByType
(
'graphite metric'
);
if
(
annotations
.
length
===
0
)
{
return
[];
}
var
promises
=
_
.
map
(
annotations
,
function
(
annotation
)
{
var
graphiteQuery
=
{
range
:
rangeUnparsed
,
targets
:
[{
target
:
annotation
.
target
}],
format
:
'json'
,
maxDataPoints
:
100
};
var
receiveFunc
=
_
.
partial
(
receiveGraphiteMetrics
,
annotation
);
return
datasourceSrv
.
default
.
query
(
filterSrv
,
graphiteQuery
)
.
then
(
receiveFunc
)
.
then
(
null
,
errorHandler
);
});
return
promises
;
};
function
errorHandler
(
err
)
{
console
.
log
(
'Annotation error: '
,
err
);
alertSrv
.
set
(
'Annotations'
,
'Could not fetch annotations'
,
'error'
);
}
function
receiveGraphiteMetrics
(
annotation
,
results
)
{
for
(
var
i
=
0
;
i
<
results
.
data
.
length
;
i
++
)
{
var
target
=
results
.
data
[
i
];
for
(
var
y
=
0
;
y
<
target
.
datapoints
.
length
;
y
++
)
{
var
datapoint
=
target
.
datapoints
[
y
];
if
(
datapoint
[
0
])
{
addAnnotation
({
annotation
:
annotation
,
time
:
datapoint
[
1
]
*
1000
,
description
:
target
.
target
});
}
}
}
}
function
addAnnotation
(
options
)
{
var
tooltip
=
"<small><b>"
+
options
.
title
+
"</b><br/>"
;
if
(
options
.
tags
)
{
...
...
src/app/services/graphite/graphiteDatasource.js
View file @
a9a76b90
...
...
@@ -58,6 +58,8 @@ function (angular, _, $, config, kbn, moment) {
};
GraphiteDatasource
.
prototype
.
annotationQuery
=
function
(
annotation
,
filterSrv
,
rangeUnparsed
)
{
// Graphite metric as annotation
if
(
annotation
.
target
)
{
var
graphiteQuery
=
{
range
:
rangeUnparsed
,
targets
:
[{
target
:
annotation
.
target
}],
...
...
@@ -86,6 +88,24 @@ function (angular, _, $, config, kbn, moment) {
return
list
;
});
}
// Graphite event as annotation
else
if
(
annotation
.
tags
)
{
return
this
.
events
({
range
:
rangeUnparsed
,
tags
:
annotation
.
tags
})
.
then
(
function
(
results
)
{
var
list
=
[];
for
(
var
i
=
0
;
i
<
results
.
data
;
i
++
)
{
list
.
push
({
annotation
:
annotation
,
time
:
event
.
when
*
1000
,
title
:
event
.
what
,
tags
:
event
.
tags
,
text
:
event
.
data
});
}
return
list
;
});
}
};
GraphiteDatasource
.
prototype
.
events
=
function
(
options
)
{
...
...
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