iLogtail as the plugin part of Logtail AlibabaCloud can run independently or work with the iLogtail-C. For most cases, the standalone mode is sufficient to verify. If you are familiar with Logtail AlibabaCloud , you can also use cgo mode to verify on Alibaba Cloud.
You can verify your case with the following 3 steps on standalone mode:
- Run make plugin_main to compile, and the binary program will be located in output/ilogtail.
- Prepare to test the demo.json file.
- Run ./output/ilogtail --plugin=./demo.json to start the program,
The following parts will introduce how the input and processor plugins perform local manual testing with standalone mode.
For input plugins, there may be external dependencies in most cases, so we recommend using E2E to run it, such as E2E nginx. Of course, if you have prepared the dependent environment locally, you can also run it locally. The following example shows the collection of nginx status, and IntervalMs indicates that the acquisition frequency is 1s once. You cloud test the running state with ** TEST_SCOPE=input_nginx TEST_DEBUG=true make e2e** command in the project root path. For the local startup, the collected output is saved in the logtail_plugin.LOG file, that is also cloud be printed to the stdout with ./output/ilogtail --plugin=./demo.json --logger-console=true --logger-retain=false command.
{
"inputs": [
{
"type": "metric_nginx_status",
"detail": {
"IntervalMs": 1000,
"Urls": [
"http://nginx/nginx_status"
]
}
}
],
"flushers": [
{
"type": "flusher_stdout",
"detail": {
}
}
]
}
For the processor plugin, you can use metric_mock or service_mock to mock the collection input. The following example is to verify and test the processor_add_fields plugin function, and metric_mock simulates the collection of input Key/Value data is 1111:2222 pair, the final output contains 3 fields after processor_add_fields processing. For the local startup, the collected output is saved in the logtail_plugin.LOG file, that is also cloud be printed to the stdout with * ./output/ilogtail --plugin=./demo.json --logger-console=true --logger-retain=false* command.
{
"inputs": [
{
"type": "metric_mock",
"detail": {
"Fields": {
"1111": "2222"
}
}
}
],
"processors": [
{
"type": "processor_add_fields",
"detail": {
"Fields": {
"aaa2": "value2",
"aaa3": "value3"
}
}
}
],
"flushers": [
{
"type": "flusher_stdout",
"detail": {
"OnlyStdout": true
}
}
]
}
For ilogtail-GO (this code repository), it can run standalone or work together with ilogtail-C to make Logtail AlibabaCloud. If you are using Logtail AlibabaCloud, the repository can be compiled as an so library to work on the AlibabaCloud. And you cloud use the SLS observable platform to config the settings or view the collect data. The following will introduce how to use AlibabaCloud to run the plugin program written by yourself.
Run Logtail AlibabaCloud on ECS
- Run
make plugin
to compile so library, and the compiled program isoutput/libPluginBase.so
. - Login the ECS host.
- Execute
cd /usr/local/ilogtail/
, and stop the [Logtail AlibabaCloud] program withREADME
guides. - Replace the compiled
libPluginBase.so
program with the compiledlibPluginBase.so
program. - Restart the [Logtail AlibabaCloud] program with
README
guides.
Run Logtail AlibabaCloud on container
- Run
make docker
to compile Logtail AlibabaCloud docker images namedaliyun/ilogtail:2.0.0
. - Rename
aliyun/ilogtail:2.0.0
to a custom name and push to the remotes, such asregistry.cn-beijing.aliyuncs.com/aliyun/ilogtail:2.0.0
. - Replace the mirror of
logtail-ds
of ACK or your self platform and restart.