Skip to content

Commit 5cb4cfc

Browse files
committed
Closes #265, Graphite errors are now easier to troubleshoot with the new inspector!
1 parent 58ef61a commit 5cb4cfc

File tree

7 files changed

+85
-30
lines changed

7 files changed

+85
-30
lines changed

Diff for: src/app/controllers/inspectCtrl.js

+26-13
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,39 @@ function (angular) {
77
var module = angular.module('kibana.controllers');
88

99
module.controller('InspectCtrl', function($scope) {
10+
var model = $scope.inspector;
11+
12+
function getParametersFromQueryString(queryString) {
13+
var result = [];
14+
var parameters = queryString.split("&");
15+
for (var i = 0; i < parameters.length; i++) {
16+
var keyValue = parameters[i].split("=");
17+
if (keyValue[1].length > 0) {
18+
result.push({ key: keyValue[0], value: window.unescape(keyValue[1]) });
19+
}
20+
}
21+
return result;
22+
}
1023

1124
$scope.init = function () {
25+
$scope.editor = { index: 0 };
1226

13-
if ($scope.inspector_info) {
14-
$scope.init_model($scope.inspector_info);
27+
if (!model.error) {
28+
return;
1529
}
1630

17-
};
31+
if (model.error.stack) {
32+
$scope.editor.index = 2;
33+
$scope.stack_trace = model.error.stack;
34+
$scope.message = model.error.message;
35+
}
36+
else if (model.error.config && model.error.config.data) {
37+
$scope.editor.index = 1;
1838

19-
$scope.init_model = function(info) {
20-
if (info.error) {
21-
console.log(info.error);
22-
if (info.error.config && info.error.config.data) {
23-
$scope.request_parameters = info.error.config.data.split('&');
24-
}
39+
$scope.request_parameters = getParametersFromQueryString(model.error.config.data);
2540

26-
if (info.error.data) {
27-
if (info.error.data.indexOf('DOCTYPE') !== -1) {
28-
$scope.response_html = info.error.data;
29-
}
41+
if (model.error.data.indexOf('DOCTYPE') !== -1) {
42+
$scope.response_html = model.error.data;
3043
}
3144
}
3245
};

Diff for: src/app/directives/kibanaPanel.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function (angular, $, _) {
1616
var panelHeader =
1717
'<div class="panel-header">'+
1818
'<div class="row-fluid">' +
19-
'<div class="span12 alert-error panel-error small" ng-if="panel.error">' +
19+
'<div class="span12 alert-error panel-error small" ng-show="panel.error">' +
2020
'<a class="close" ng-click="panel.error=false">&times;</a>' +
2121
'<span><i class="icon-exclamation-sign"></i> <strong>Oops!</strong> {{panel.error}} </span>' +
2222
'<span class="pointer panel-error-inspector-link" config-modal="app/partials/inspector.html">View details</span>' +
@@ -223,6 +223,7 @@ function (angular, $, _) {
223223
}
224224
];
225225

226+
scope.inspector = {};
226227
scope.panelMeta.menu = _.where(menu, { condition: true });
227228
};
228229
}

Diff for: src/app/panels/graphite/module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
262262
.then($scope.dataHandler)
263263
.then(null, function(err) {
264264
$scope.panelMeta.loading = false;
265-
$scope.inspector_info = { error: err };
266265
$scope.panel.error = err.message || "Graphite HTTP Request Error";
266+
$scope.inspector.error = err;
267267
$scope.render([]);
268268
});
269269
};

Diff for: src/app/partials/inspector.html

+36-13
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,67 @@
22
<div class="pull-right editor-title">Inspector</div>
33

44
<div ng-model="editor.index" bs-tabs>
5-
<div ng-repeat="tab in ['Request','Response']" data-title="{{tab}}">
5+
<div ng-repeat="tab in ['Request', 'Response', 'JS Error']" data-title="{{tab}}">
66
</div>
77
</div>
88

9-
<div class="editor-row" ng-if="editor.index == 0">
10-
11-
<table class="table table-striped">
9+
<div ng-if="editor.index == 0">
10+
<h5>Request details</h5>
11+
<table class="table table-striped small inspector-request-table">
1212
<tr>
1313
<td>Url</td>
14-
<td>{{inspector_info.error.config.url}}</td>
14+
<td>{{inspector.error.config.url}}</td>
1515
</tr>
1616
<tr>
1717
<td>Method</td>
18-
<td>{{inspector_info.error.config.method}}</td>
18+
<td>{{inspector.error.config.method}}</td>
1919
</tr>
20-
<tr ng-repeat="(key, value) in inspector_info.error.config.headers">
20+
<tr ng-repeat="(key, value) in inspector.error.config.headers">
2121
<td>
2222
{{key}}
2323
</td>
2424
<td>
2525
{{value}}
2626
</td>
2727
</tr>
28-
<tr>
29-
<td>Data</td>
30-
<td>{{inspector_info.error.config.data}}</td>
31-
</tr>
3228
</table>
3329

30+
<h5>Request parameters</h5>
31+
<table class="table table-striped small inspector-request-table">
32+
<tr ng-repeat="param in request_parameters">
33+
<td>
34+
{{param.key}}
35+
</td>
36+
<td>
37+
{{param.value}}
38+
</td>
39+
</tr>
40+
</table>
3441
</div>
3542

36-
<div class="editor-row" ng-if="editor.index == 1">
43+
<div ng-if="editor.index == 1">
44+
3745
<div ng-if="response_html">
3846
<div iframe-content="response_html"></div>
3947
</div>
48+
49+
</div>
50+
51+
<div ng-if="editor.index == 2">
52+
53+
<label>Message:</label>
54+
<pre>
55+
{{message}}
56+
</pre>
57+
58+
<label>Stack trace:</label>
59+
<pre>
60+
{{stack_trace}}
61+
</pre>
62+
4063
</div>
4164

4265
</div>
4366
<div class="modal-footer">
44-
<button type="button" class="btn btn-success" ng-click="dismiss()">Close</button>
67+
<button type="button" class="btn btn-info" ng-click="dismiss()">Close</button>
4568
</div>

Diff for: src/css/bootstrap.dark.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/css/bootstrap.light.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/css/less/overrides.less

+18
Original file line numberDiff line numberDiff line change
@@ -588,3 +588,21 @@ div.flot-text {
588588
.save-dashboard-dropdown-save-form {
589589
margin-bottom: 5px;
590590
}
591+
592+
593+
// inspector
594+
.inspector-request-table {
595+
td {
596+
padding: 5px;
597+
}
598+
599+
td:first-child {
600+
white-space: nowrap;
601+
}
602+
}
603+
604+
// pre
605+
code, pre {
606+
background-color: @kibanaPanelBackground;
607+
color: @textColor;
608+
}

0 commit comments

Comments
 (0)