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
f813b4c5
Commit
f813b4c5
authored
Jan 09, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(plugins): converted graphite plugin to new format
parent
c5635f9c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
68 deletions
+69
-68
public/app/plugins/datasource/elasticsearch/datasource.js
+1
-0
public/app/plugins/datasource/graphite/datasource.d.ts
+3
-0
public/app/plugins/datasource/graphite/datasource.js
+56
-64
public/app/plugins/datasource/graphite/specs/datasource_specs.ts
+9
-4
No files found.
public/app/plugins/datasource/elasticsearch/datasource.js
View file @
f813b4c5
...
...
@@ -12,6 +12,7 @@ define([
function
(
angular
,
_
,
moment
,
kbn
,
ElasticQueryBuilder
,
IndexPattern
,
ElasticResponse
)
{
'use strict'
;
/** @ngInject */
function
ElasticDatasource
(
instanceSettings
,
$q
,
backendSrv
,
templateSrv
,
timeSrv
)
{
this
.
basicAuth
=
instanceSettings
.
basicAuth
;
this
.
withCredentials
=
instanceSettings
.
withCredentials
;
...
...
public/app/plugins/datasource/graphite/datasource.d.ts
0 → 100644
View file @
f813b4c5
declare
var
Datasource
:
any
;
export
{
Datasource
};
public/app/plugins/datasource/graphite/datasource.js
View file @
f813b4c5
...
...
@@ -12,20 +12,16 @@ define([
function
(
angular
,
_
,
$
,
config
,
dateMath
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.services'
);
module
.
factory
(
'GraphiteDatasource'
,
function
(
$q
,
backendSrv
,
templateSrv
)
{
function
GraphiteDatasource
(
datasource
)
{
this
.
basicAuth
=
datasource
.
basicAuth
;
this
.
url
=
datasource
.
url
;
this
.
name
=
datasource
.
name
;
this
.
cacheTimeout
=
datasource
.
cacheTimeout
;
this
.
withCredentials
=
datasource
.
withCredentials
;
this
.
render_method
=
datasource
.
render_method
||
'POST'
;
}
GraphiteDatasource
.
prototype
.
query
=
function
(
options
)
{
/** @ngInject */
function
GraphiteDatasource
(
instanceSettings
,
$q
,
backendSrv
,
templateSrv
)
{
this
.
basicAuth
=
instanceSettings
.
basicAuth
;
this
.
url
=
instanceSettings
.
url
;
this
.
name
=
instanceSettings
.
name
;
this
.
cacheTimeout
=
instanceSettings
.
cacheTimeout
;
this
.
withCredentials
=
instanceSettings
.
withCredentials
;
this
.
render_method
=
instanceSettings
.
render_method
||
'POST'
;
this
.
query
=
function
(
options
)
{
try
{
var
graphOptions
=
{
from
:
this
.
translateTime
(
options
.
rangeRaw
.
from
,
false
),
...
...
@@ -62,7 +58,7 @@ function (angular, _, $, config, dateMath) {
}
};
GraphiteDatasource
.
prototype
.
convertDataPointsToMs
=
function
(
result
)
{
this
.
convertDataPointsToMs
=
function
(
result
)
{
if
(
!
result
||
!
result
.
data
)
{
return
[];
}
for
(
var
i
=
0
;
i
<
result
.
data
.
length
;
i
++
)
{
var
series
=
result
.
data
[
i
];
...
...
@@ -73,7 +69,7 @@ function (angular, _, $, config, dateMath) {
return
result
;
};
GraphiteDatasource
.
prototype
.
annotationQuery
=
function
(
options
)
{
this
.
annotationQuery
=
function
(
options
)
{
// Graphite metric as annotation
if
(
options
.
annotation
.
target
)
{
var
target
=
templateSrv
.
replace
(
options
.
annotation
.
target
);
...
...
@@ -85,50 +81,49 @@ function (angular, _, $, config, dateMath) {
};
return
this
.
query
(
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
:
options
.
annotation
,
time
:
datapoint
[
1
],
title
:
target
.
target
});
}
}
.
then
(
function
(
result
)
{
var
list
=
[];
return
list
;
});
}
// Graphite event as annotation
else
{
var
tags
=
templateSrv
.
replace
(
options
.
annotation
.
tags
);
return
this
.
events
({
range
:
options
.
rangeRaw
,
tags
:
tags
})
.
then
(
function
(
results
)
{
var
list
=
[];
for
(
var
i
=
0
;
i
<
results
.
data
.
length
;
i
++
)
{
var
e
=
results
.
data
[
i
];
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
:
options
.
annotation
,
time
:
e
.
when
*
1000
,
title
:
e
.
what
,
tags
:
e
.
tags
,
text
:
e
.
data
time
:
datapoint
[
1
],
title
:
target
.
target
});
}
return
list
;
});
}
return
list
;
});
}
// Graphite event as annotation
else
{
var
tags
=
templateSrv
.
replace
(
options
.
annotation
.
tags
);
return
this
.
events
({
range
:
options
.
rangeRaw
,
tags
:
tags
}).
then
(
function
(
results
)
{
var
list
=
[];
for
(
var
i
=
0
;
i
<
results
.
data
.
length
;
i
++
)
{
var
e
=
results
.
data
[
i
];
list
.
push
({
annotation
:
options
.
annotation
,
time
:
e
.
when
*
1000
,
title
:
e
.
what
,
tags
:
e
.
tags
,
text
:
e
.
data
});
}
return
list
;
});
}
};
GraphiteDatasource
.
prototype
.
events
=
function
(
options
)
{
this
.
events
=
function
(
options
)
{
try
{
var
tags
=
''
;
if
(
options
.
tags
)
{
...
...
@@ -146,7 +141,7 @@ function (angular, _, $, config, dateMath) {
}
};
GraphiteDatasource
.
prototype
.
translateTime
=
function
(
date
,
roundUp
)
{
this
.
translateTime
=
function
(
date
,
roundUp
)
{
if
(
_
.
isString
(
date
))
{
if
(
date
===
'now'
)
{
return
'now'
;
...
...
@@ -178,7 +173,7 @@ function (angular, _, $, config, dateMath) {
return
date
.
unix
();
};
GraphiteDatasource
.
prototype
.
metricFindQuery
=
function
(
query
)
{
this
.
metricFindQuery
=
function
(
query
)
{
var
interpolated
;
try
{
interpolated
=
encodeURIComponent
(
templateSrv
.
replace
(
query
));
...
...
@@ -198,24 +193,24 @@ function (angular, _, $, config, dateMath) {
});
};
GraphiteDatasource
.
prototype
.
testDatasource
=
function
()
{
this
.
testDatasource
=
function
()
{
return
this
.
metricFindQuery
(
'*'
).
then
(
function
()
{
return
{
status
:
"success"
,
message
:
"Data source is working"
,
title
:
"Success"
};
});
};
GraphiteDatasource
.
prototype
.
listDashboards
=
function
(
query
)
{
this
.
listDashboards
=
function
(
query
)
{
return
this
.
doGraphiteRequest
({
method
:
'GET'
,
url
:
'/dashboard/find/'
,
params
:
{
query
:
query
||
''
}
})
.
then
(
function
(
results
)
{
return
results
.
data
.
dashboards
;
});
};
GraphiteDatasource
.
prototype
.
loadDashboard
=
function
(
dashName
)
{
this
.
loadDashboard
=
function
(
dashName
)
{
return
this
.
doGraphiteRequest
({
method
:
'GET'
,
url
:
'/dashboard/load/'
+
encodeURIComponent
(
dashName
)
});
};
GraphiteDatasource
.
prototype
.
doGraphiteRequest
=
function
(
options
)
{
this
.
doGraphiteRequest
=
function
(
options
)
{
if
(
this
.
basicAuth
||
this
.
withCredentials
)
{
options
.
withCredentials
=
true
;
}
...
...
@@ -230,9 +225,9 @@ function (angular, _, $, config, dateMath) {
return
backendSrv
.
datasourceRequest
(
options
);
};
GraphiteDatasource
.
prototype
.
_seriesRefLetters
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
this
.
_seriesRefLetters
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
GraphiteDatasource
.
prototype
.
buildGraphiteParams
=
function
(
options
,
scopedVars
)
{
this
.
buildGraphiteParams
=
function
(
options
,
scopedVars
)
{
var
graphite_options
=
[
'from'
,
'until'
,
'rawData'
,
'format'
,
'maxDataPoints'
,
'cacheTimeout'
];
var
clean_options
=
[],
targets
=
{};
var
target
,
targetValue
,
i
;
...
...
@@ -296,12 +291,9 @@ function (angular, _, $, config, dateMath) {
return
clean_options
;
};
return
GraphiteDatasource
;
});
}
return
{
serviceName
:
"GraphiteDatasource"
Datasource
:
GraphiteDatasource
};
});
public/app/plugins/datasource/graphite/specs/datasource_specs.ts
View file @
f813b4c5
import
"../datasource"
;
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
helpers
from
'test/specs/helpers'
;
import
{
Datasource
}
from
"../datasource"
;
describe
(
'graphiteDatasource'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
var
instanceSettings
:
any
=
{
url
:[
''
]};
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'backendSrv'
]));
beforeEach
(
ctx
.
createService
(
'GraphiteDatasource'
));
beforeEach
(
angularMocks
.
inject
(
function
(
$q
,
$rootScope
,
$httpBackend
,
$injector
)
{
ctx
.
$q
=
$q
;
ctx
.
$httpBackend
=
$httpBackend
;
ctx
.
$rootScope
=
$rootScope
;
ctx
.
$injector
=
$injector
;
}));
beforeEach
(
function
()
{
ctx
.
ds
=
new
ctx
.
service
({
url
:
[
''
]
});
ctx
.
ds
=
ctx
.
$injector
.
instantiate
(
Datasource
,
{
instanceSettings
:
instanceSettings
});
});
describe
(
'When querying influxdb with one target using query editor target spec'
,
function
()
{
...
...
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