forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
132 lines (121 loc) · 4.83 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
elasticsearch: URL to your elasticsearch server. You almost certainly don't
want 'http://localhost:9200' here. Even if Kibana and ES are on
the same host
kibana_index: The default ES index to use for storing Kibana specific object
such as stored dashboards
modules: Panel modules to load. In the future these will be inferred
from your initial dashboard, though if you share dashboards you
will probably need to list them all here
If you need to configure the default dashboard, please see dashboards/default
*/
var config = new Settings(
{
// By default this will attempt to reach ES at the same host you have
// elasticsearch installed on. You probably want to set it to the FQDN of your
// elasticsearch host
elasticsearch: "es",
types: ['log'],
// elasticsearch: 'http://localhost:9200',
kibana_index: "kibana-int",
modules: ['histogram','map','pie','table','stringquery','sort',
'timepicker','text','fields','hits','dashcontrol',
'column','derivequeries','trends'],
formatValue: doFormatValue
});
function doFormatValue(source, key, obj) {
if (key == 'exception') {
return obj.map(formatStackLine).join('\n');
} else if (key == 'timestamp' && source == 'table') {
return reformatDate(obj);
} else if(typeof obj == 'object' ) {
if(_.isArray(obj)) {
if(obj.length > 0 && typeof obj[0] === 'object') {
var strval = '';
for (var objidx = 0, objlen = obj.length; objidx < objlen; objidx++) {
if (objidx > 0) {
strval = strval + ', ';
}
strval = strval + JSON.stringify(obj[objidx]);
}
return strval;
} else if(obj.length === 1 && _.isNumber(obj[0])) {
return parseFloat(obj[0]);
} else {
return typeof obj === 'undefined' ? null : obj.join(',');
}
} else {
obj = sortObj(obj);
var strval = '';
for (var key in obj) {
if (key.substring(0, 2) != '$$') {
if (strval != '') {
strval = strval + '\n';
}
strval = strval + key + ": " + JSON.stringify(obj[key]);
}
}
return strval;
}
} else {
return typeof obj === 'undefined' ? null : obj.toString();
}
}
var _dateRegex = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;
// 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
var numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ];
function reformatDate(date) {
var timestamp, struct, minutesOffset = 0;
if ((struct = _dateRegex.exec(date))) {
// avoid NaN timestamps caused by “undefined” values being passed to Date.UTC
for (var i = 0, k; (k = numericKeys[i]); ++i) {
struct[k] = +struct[k] || 0;
}
// allow undefined days and months
struct[2] = (+struct[2] || 1) - 1;
struct[3] = +struct[3] || 1;
if (struct[8] !== 'Z' && struct[9] !== undefined) {
minutesOffset = struct[10] * 60 + struct[11];
if (struct[9] === '+') {
minutesOffset = 0 - minutesOffset;
}
}
timestamp = moment(Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]));
if (timestamp.year() == moment().year()) {
if (timestamp.month() == moment().month() && timestamp.date() == moment().date()) {
return timestamp.format('HH:mm:ss');
} else {
return timestamp.format('MM/DD HH:mm:ss');
}
} else {
return timestamp.format('YYYY/MM/DD HH:mm:ss');
}
}
else {
return date;
}
}
var _stackRegex = /\s*at\s+([\w\.$_]+(\.([\w$_]+))*)\((.*)?:(\d+)\).*\[(.*)\]/;
function formatStackLine(line) {
var match = _stackRegex.exec(line);
if (match && match.length > 6) {
var classAndMethod = match[1];
var fileName = match[4];
var line = match[5];
var mvnCoords = match[6];
// we can ignore line if its not present...
if (classAndMethod && fileName && mvnCoords) {
var className = classAndMethod;
var idx = classAndMethod.lastIndexOf('.');
if (idx > 0) {
className = classAndMethod.substring(0, idx);
}
var link = "../hawtio/index.html#/source/view/" + mvnCoords + "/class/" + className + "/" + fileName;
if (angular.isDefined(line)) {
link += "?line=" + line;
}
return "\tat <a href='" + link + "'>" + classAndMethod + "</a>(<span class='fileName'>" + fileName + "</span>:<span class='lineNumber'>" + line + "</span>)";
}
}
return line;
}