I am trying to build a plugin for the curren ga version of Kibana (5.5.2) . To get me started I'm following Tim Roes' tutorial: https://www.timroes.de/2016/02/17/writing-kibana-4-plugins-field-formatters/
Perhaps due to version issues I have trouble getting this up and running.
I used aos and the kibana-plugin-template to make the initial setup.
I added a simple field_formatter copied mostly from Tim's tutorial, but some name changes, this is most of my code:
// file cluster-lookup/index.js
import exampleRoute from './server/routes/example';
export default function (kibana) {
return new kibana.Plugin({
require: ['elasticsearch'],
name: 'cluster-lookup',
uiExports: {
fieldFormats: [
'plugins/cluster-lookup/clustername'
]
},
config(Joi) {
return Joi.object({
enabled: Joi.boolean().default(true),
}).default();
},
init(server, options) {
// Add server routes and initialize the plugin here
exampleRoute(server);
}
});
};
// file cluster-lookup/public/clustername.js
function ClusterNameProvider(Private) {
var _ = require('lodash');
var FieldFormat = Private(require('ui/index_patterns/_field_format/field_format'));
// I had to change the path in the line above from 'ui/index_patterns/_field_format/FieldFormat'
// Create a new FieldFormat type and inherit FieldFormat
_.class(ClusterName).inherits(FieldFormat);
function ClusterName(params) {
ClusterName.Super.call(this, params);
}
ClusterName.id = 'clustername';
ClusterName.title = 'Cluster naam';
ClusterName.fieldType = ['string'];
ClusterName.prototype._convert = {
text: function(value) {
return 'kijk: ' + value;
},
html: function(value) {
var html = value + ' ';
if (value.length > 5) {
html += '<span style="color:#419E63">↗</span>';
} else if (value.length < 20) {
html += '<span style="color:#A92E26">↘</span>';
} else {
html += '<span style="color:#797979">=</span>'
}
return html;
}
};
return ClusterName;
}
require('ui/registry/field_formats').register(ClusterNameProvider);
When I run the code, the kibana server starts up, announces that the plugin is initialized, but when visiting localhost:5601 the following error is displayed as soon as Kibana has started up:
TypeError: __webpack_require__(562).register is not a function. (In '__webpack_require__(562).register(ClusterNameProvider)', '__webpack_require__(562).register' is undefined) (https://localhost:5601/pgc/bundles/kibana.bundle.js?v=8467:323785)
Version: 5.5.2
Build: 8467
Error: TypeError: __webpack_require__(562).register is not a function. (In '__webpack_require__(562).register(ClusterNameProvider)', '__webpack_require__(562).register' is undefined) (https://localhost:5601/pgc/bundles/kibana.bundle.js?v=8467:323785)
onerror@https://localhost:5601/pgc/bundles/commons.bundle.js?v=8467:76925:26