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
a56a2b00
Commit
a56a2b00
authored
Jan 31, 2014
by
oroce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic authentication added for elasticsearch
parent
89224401
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
17 deletions
+40
-17
src/app/components/settings.js
+12
-9
src/app/controllers/dash.js
+1
-1
src/app/controllers/metricKeys.js
+9
-3
src/app/services/dashboard.js
+11
-3
src/vendor/elasticjs/elastic-angular-client.js
+7
-1
No files found.
src/app/components/settings.js
View file @
a56a2b00
...
...
@@ -28,16 +28,19 @@ function (_, crypto) {
settings
[
key
]
=
typeof
options
[
key
]
!==
'undefined'
?
options
[
key
]
:
defaults
[
key
];
});
var
url
=
settings
.
graphiteUrl
;
var
passwordAt
=
url
.
indexOf
(
'@'
);
if
(
passwordAt
>
0
)
{
var
userStart
=
url
.
indexOf
(
'//'
)
+
2
;
var
userAndPassword
=
url
.
substring
(
userStart
,
passwordAt
);
var
bytes
=
crypto
.
charenc
.
Binary
.
stringToBytes
(
userAndPassword
);
var
base64
=
crypto
.
util
.
bytesToBase64
(
bytes
);
settings
.
graphiteBasicAuth
=
base64
;
}
var
basicAuth
=
function
(
url
)
{
var
passwordAt
=
url
.
indexOf
(
'@'
);
if
(
passwordAt
>
0
)
{
var
userStart
=
url
.
indexOf
(
'//'
)
+
2
;
var
userAndPassword
=
url
.
substring
(
userStart
,
passwordAt
);
var
bytes
=
crypto
.
charenc
.
Binary
.
stringToBytes
(
userAndPassword
);
var
base64
=
crypto
.
util
.
bytesToBase64
(
bytes
);
return
base64
;
}
};
settings
.
graphiteBasicAuth
=
basicAuth
(
settings
.
graphiteUrl
);
settings
.
elasticsearchBasicAuth
=
basicAuth
(
settings
.
elasticsearch
);
return
settings
;
};
});
src/app/controllers/dash.js
View file @
a56a2b00
...
...
@@ -58,7 +58,7 @@ function (angular, $, config, _) {
$scope
.
reset_row
();
$scope
.
ejs
=
ejsResource
(
config
.
elasticsearch
);
$scope
.
ejs
=
ejsResource
(
config
.
elasticsearch
,
config
.
elasticsearchBasicAuth
);
$scope
.
bindKeyboardShortcuts
();
};
...
...
src/app/controllers/metricKeys.js
View file @
a56a2b00
...
...
@@ -10,7 +10,13 @@ function (angular, _, config) {
module
.
controller
(
'MetricKeysCtrl'
,
function
(
$scope
,
$http
,
$q
)
{
var
elasticSearchUrlForMetricIndex
=
config
.
elasticsearch
+
'/'
+
config
.
grafana_metrics_index
+
'/'
;
var
httpOptions
=
{};
if
(
config
.
elasticsearchBasicAuth
)
{
options
.
withCredentials
=
true
;
options
.
headers
=
{
"Authorization"
:
"Basic "
+
config
.
elasticsearchBasicAuth
};
}
$scope
.
init
=
function
()
{
$scope
.
metricPath
=
"prod.apps.api.boobarella.*"
;
$scope
.
metricCounter
=
0
;
...
...
@@ -77,7 +83,7 @@ function (angular, _, config) {
function
deleteIndex
()
{
var
deferred
=
$q
.
defer
();
$http
.
delete
(
elasticSearchUrlForMetricIndex
)
$http
.
delete
(
elasticSearchUrlForMetricIndex
,
httpOptions
)
.
success
(
function
()
{
deferred
.
resolve
(
'ok'
);
})
...
...
@@ -124,7 +130,7 @@ function (angular, _, config) {
}
}
}
});
}
,
httpOptions
);
}
function
receiveMetric
(
result
)
{
...
...
src/app/services/dashboard.js
View file @
a56a2b00
...
...
@@ -47,7 +47,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
};
// An elasticJS client to use
var
ejs
=
ejsResource
(
config
.
elasticsearch
);
var
ejs
=
ejsResource
(
config
.
elasticsearch
,
config
.
elasticsearchBasicAuth
);
var
gist_pattern
=
/
(
^
\d{5,}
$
)
|
(
^
[
a-z0-9
]{10,}
$
)
|
(
gist.github.com
(\/
*.*
)\/[
a-z0-9
]{5,}\/
*$
)
/
;
// Store a reference to this
...
...
@@ -286,13 +286,21 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
};
this
.
elasticsearch_load
=
function
(
type
,
id
)
{
return
$http
(
{
var
options
=
{
url
:
config
.
elasticsearch
+
"/"
+
config
.
grafana_index
+
"/"
+
type
+
"/"
+
id
+
'?'
+
new
Date
().
getTime
(),
method
:
"GET"
,
transformResponse
:
function
(
response
)
{
return
renderTemplate
(
angular
.
fromJson
(
response
).
_source
.
dashboard
,
$routeParams
);
}
}).
error
(
function
(
data
,
status
)
{
};
if
(
config
.
elasticsearchBasicAuth
)
{
options
.
withCredentials
=
true
;
options
.
headers
=
{
"Authorization"
:
"Basic "
+
config
.
elasticsearchBasicAuth
};
}
return
$http
(
options
)
.
error
(
function
(
data
,
status
)
{
if
(
status
===
0
)
{
alertSrv
.
set
(
'Error'
,
"Could not contact Elasticsearch at "
+
config
.
elasticsearch
+
". Please ensure that Elasticsearch is reachable from your system."
,
'error'
);
...
...
src/vendor/elasticjs/elastic-angular-client.js
View file @
a56a2b00
...
...
@@ -13,7 +13,7 @@ be injected into your angular controllers.
angular
.
module
(
'elasticjs.service'
,
[])
.
factory
(
'ejsResource'
,
[
'$http'
,
function
(
$http
)
{
return
function
(
config
)
{
return
function
(
config
,
basicAuth
)
{
var
...
...
@@ -43,6 +43,12 @@ angular.module('elasticjs.service', [])
config
.
server
=
''
;
}
// set authentication header
if
(
basicAuth
||
config
.
basicAuth
)
{
config
.
headers
=
angular
.
extend
(
config
.
headers
||
{},
{
"Authorization"
:
"Basic "
+
(
basicAuth
||
config
.
basicAuth
)
});
}
/* implement the elastic.js client interface for angular */
ejs
.
client
=
{
server
:
function
(
s
)
{
...
...
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