This article explains plugin functions which enable scouter's extensibility.
With the plugin function of Scouter collector sever, data collected by scouter can be pre-handled and can be shared to other softwares.
With agent plugin, certain types of data can be modified and other business-meaningful data can be added data to XLog or profile.
Scouter plugins enable Scouter to collaborate with other open sources.
Scouter has 2 type of plugins - server plugin and an agent plugin.
server plug-in is for to collector server
and agent Plugin is for to Java agent.
Server plugin has 2 type plugins including script-type plugin, built-in-type plugin.
Below are the list of official plugins from scouter project and from contributors.
-
Sample
- scouter-plugin-server-null : sample plugin prints out data collected
-
Alert
- scouter-plugin-server-email : emails alters from Scouter
- scouter-plugin-server-telegram : transfer altert from Scouter to telegram
- scouter-plugin-server-slack : transfer altert from Scouter to slack
- scouter-plugin-server-line : transfer altert from Scouter to line
- scouter-plugin-server-dingtalk : transfer altert from Scouter to dingtalk
-
Counter
- scouter-plugin-server-influxdb : transfer performance data from Scouter to influxDB(time series DB)
- TBD
A scripting plugin is called right before xlog data is stored in a repository. You can add simple script for manipulate some data on the plugin files which are located in the directory [server_running_dir]/plugin by default.
Scouter distribution has the samples and the file name can not be modified.
Currently 6 types of scripting plugins are supported.
- alert.plug - for pre-handling alert
- counter.plug - for pre-handling performance metrics(counters)
- object.plug - for pre-handling monitoring objects(instances)
- summary.plug - for pre-handling performance summary data
- xlog.plug - for pre-handling xlog data
- xlogprofile.plug - for pre-handling xlog profile
refer to the link for details. refer to Scripting plugin Server API.
Builing scripting plugin is very simple and can be dynamically loaded on runtime environment.
On the other hand if you need the function permanently, it's too easy to fragile.
So scouter provides another plugin type which allow you can attach pre-built compiled plugin and it's called as Built-in Plugin.
Scouter load the plugins on startup, if the plugins are located in scouter server's library directory.(default:[server_running_dir]/lib)
- scouter.common
<dependency> <groupId>io.github.scouter-project</groupId> <artifactId>scouter-common</artifactId> <version>1.7.0</version> </dependency>
- scouter.server
<dependency> <groupId>io.github.scouter-project</groupId> <artifactId>scouter-server</artifactId> <version>1.7.0</version> </dependency>
scouter.lang.plugin.annotation.ServerPlugin
- Example
package scouter.plugin.server.none;
public class NullPlugin {
Configure conf = Configure.getInstance();
@ServerPlugin(PluginConstants.PLUGIN_SERVER_ALERT)
public void alert(AlertPack pack){
if(conf.getBoolean("ext_plugin_null_alert_enabled", true)) {
println("[NullPlugin-alert] " + pack);
}
}
- Check it.
- The file is located sub package of scouter.plugin.server because annotation scan scope is from scouter.plugin.server package.
- The plugin can use scouter server's configuration and the option name must start with ext_plugin_xxx.
-
ServerPlugin
annotationsPLUGIN_SERVER_COUNTER
PLUGIN_SERVER_ALERT
PLUGIN_SERVER_OBJECT
PLUGIN_SERVER_SUMMARY
PLUGIN_SERVER_XLOG
PLUGIN_SERVER_PROFILE
Provided sample plugin that just prints the data collected.
- Sample plugin : https://github.com/scouter-project/scouter-plugin-server-null
- Download : scouter-plugin-server-null.jar
We can build our own alarm rules by handling alert scripting plugins which are able to compose various performance metrics.
Scripting plugin can be loaded dynamically on runtime so it is used for debugging also
It's very useful to print some method's parameters or stacktrace on specific point and also can add additional (user-defined) profile information to the xlog or xlog profile.
The scripting plugin is invoked at some important points and the default location of the plugin file is ./plugin.
Scouter distribution includes sample plugin files and the file name can not be modified.
filename | desc |
---|---|
httpservice.plug | Invoked at begin and end of http service. |
service.plug | Invoked at begin and end of user defined service. (The services are set by hook_service_patterns option) |
httpcall.plug | Invoked at calling to another service using httpclients library |
capture.plug | Invoked at init, start, end of methods that are set by options hook_method_patterns or hook_constructor_patterns |
jdbcpoolplug | Invoked at calling DB connection URL |
Refer to the link for details Scripting plugin java agent API