At the time of writing this post, official documentation has not been released yet. What you are about to read was done by reading through some plugin classes of graylog2 and I’m not totally sure how the plugin works in graylog2. Graylog2 is written in Java so plugin will have to write in Java.
There are six different types of plugin.
I tried to write an XMPP plugin (which is already exists in current version of graylog2 – I didn’t know that) which is derived from twili0 SMS plugin
Before starting write any plugin, you will need to include graylog2 plugin interface in your java application.
My plugin is Transport plugin
which I don’t know how it works, lol, but what I thought is it would send some alarm to to my plugin, However, I haven’t manage to get it working because my alarm configuration is not working (I’ve used to get it working in 0.96/7 but not in 0.10.0). I believe if you want Graylog2 to send an alarm to your plugin, you have to implement the AlarmCallback interface. which is a way how alarm is sent to receiver (Receiver is a user under graylog2’s alarm configuration)
Anyway, my plugin has one class named XMPPTransport which implements Transport interface which you have to override five methods.
- initialize: initialize plugin
- getRequestedConfiguration: return plugin configuration which graylog2 will create a configuration page for you automatically
- transportAlarm : will be triggered when alarm occurs
- getName : return Plugin Name to Graylog2 (XMPP client)
- getUserFieldName: not sure what this is
Please see example code here
after finished all the coding you have to pack everything into a jar and rename it to something like this packagename.classname_gl2plugin.jar for example “graylog2.plugin.xmpp.XMPPTransport_gl2plugin.jar”
and then put the jar to graylog2_installation_folder/plugin/transports for example “/usr/share/graylog2-server/plugin/transports”
However, if you’re implementing some other different type of plugin you have to put it under a different sub-folder filters,outputs,alarm_callbacks or initializers
After that just restart the graylog2 server and everything will be loaded into graylog2 automatically.
Output from System page
Configuration page of custom plugin