-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External Processor Plugins Loaded But Not Available #7162
Comments
@ssoroka FYI |
Hey @kadaan, I tested it locally and I was able to build and run an external processor in 1.13.4 and against master. Can you share your code for the processor? If anything's sensitive/private, feel free to strip that part out. |
@ssoroka Here is example code that reproduces my issue: https://github.com/kadaan/telegraf-plugin-test Pull that into your gopath and then run ./build.sh. It will:
|
Looks like I can replicate this in go 1.14, but not earlier versions of go |
I updated my repo (https://github.com/kadaan/telegraf-plugin-test) with a docker container which sets everything up with go 1.13. I can still repo the issue with:
|
Might be helpful to check out #7027, we were recently able to get this working with an input plugin. |
So I managed to get to the bottom of this. The example uses This raises the question "what do you do if you want to manage plugin dependencies with dep"? To that I'd say two things:
TL;DR: don't vendor the Telegraf dependency. |
I did a bit more digging and this is easier to manage with go modules. Go modules has a go.mod replace directive that lets you say "Don't use the module you downloaded, use the package in my path instead", eg:
where $GO_PATH is the path to your go folder. eg, /Users/me/go. This way even if you're running a custom build of Telegraf, you can get the library versions to match exactly, and avoid the above issue (also the "plugin was built with a different version of package" issue). |
@ssoroka @danielnelson Thanks again for all the help. |
Relevant telegraf.conf:
System info:
Telegraf: 1.13.4
OS: Ubuntu 18.04
Go: go version go1.14 linux/amd64
Steps to reproduce:
CGO_ENABLED=1 go build -o /home/kadaan/plugins/telegraf-plugins.so -buildmode=plugin .
CGO_ENABLED=1 go build -tags goplugin -o /home/kadaan/telegraf -ldflags /home/kadaan/go/src/github.com/influxdata/telegraf/cmd/telegraf/telegraf.go
/home/kadaan/telegraf --config /home/kadaan/telegraf.comf --plugin-directory /home/kadaan/plugins --test
Expected behavior:
External plugin should load and be available for use
Actual behavior:
External plugin loads, but cannot be used
Additional info:
Added some logging to telegraf and the external plugin to identify the issue.
In Telegraf I added :
plugins/processors/registry.go#Add
log.Printf("I! [processors] Processors (%v): Adding %s", reflect.ValueOf(Processors).Pointer(), name)
internal/config/config.go#LoadConfig
In my external plugins I added
log.Printf("I! [processors.expression] Processors (%v): ", reflect.ValueOf(processors.Processors).Pointer())
to theinit
function.The output of this is:
Referred to #7027 to work through getting the plugins to load
The text was updated successfully, but these errors were encountered: