Skip to content
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

[Input plugin] - [gNMI - tag_only] Assert string fails and crashes collection #11007

Closed
cprecup opened this issue Apr 20, 2022 · 1 comment · Fixed by #11010
Closed

[Input plugin] - [gNMI - tag_only] Assert string fails and crashes collection #11007

cprecup opened this issue Apr 20, 2022 · 1 comment · Fixed by #11010

Comments

@cprecup
Copy link

cprecup commented Apr 20, 2022

Regarding:

tags[subscriptionName+"/"+k] = v.(string)

Telegraf crashes with similar errors when assert string fails:

2022-04-20T15:13:59Z I! Using config file: /etc/telegraf/telegraf.conf
2022-04-20T15:13:59Z I! Starting Telegraf 1.22.1
2022-04-20T15:13:59Z I! Loaded inputs: gnmi
2022-04-20T15:13:59Z I! Loaded aggregators:
2022-04-20T15:13:59Z I! Loaded processors:
2022-04-20T15:13:59Z I! Loaded outputs: influxdb
2022-04-20T15:13:59Z I! Tags enabled: host=90365323743d
2022-04-20T15:13:59Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"90365323743d", Flush Interval:10s
2022-04-20T15:13:59Z D! [agent] Initializing plugins
2022-04-20T15:13:59Z D! [agent] Connecting outputs
2022-04-20T15:13:59Z D! [agent] Attempting connection to [outputs.influxdb]
2022-04-20T15:13:59Z D! [agent] Successfully connected to outputs.influxdb
2022-04-20T15:13:59Z D! [agent] Starting service inputs
2022-04-20T15:13:59Z D! [inputs.gnmi] Connection to gNMI device A.B.C.D:55555 established
2022-04-20T15:13:59Z D! [inputs.gnmi] Connection to gNMI device A.B.C.D:55555 closed
panic: interface conversion: interface {} is uint64, not string

goroutine 16 [running]:
github.com/influxdata/telegraf/plugins/inputs/gnmi.(*GNMI).handleSubscribeResponseUpdate(0xc00041b380, {0xc000a70ea1, 0x12}, 0xc000130b58)
	/go/src/github.com/influxdata/telegraf/plugins/inputs/gnmi/gnmi.go:329 +0xf79
github.com/influxdata/telegraf/plugins/inputs/gnmi.(*GNMI).handleSubscribeResponse(0xc00052e670, {0xc000a70ea1, 0xc00046a510}, 0xc000071720)
	/go/src/github.com/influxdata/telegraf/plugins/inputs/gnmi/gnmi.go:264 +0x4e
github.com/influxdata/telegraf/plugins/inputs/gnmi.(*GNMI).subscribeGNMI(0xc00041b380, {0x5e68590, 0xc00046a510}, {0xc000a70ea1, 0x12}, 0x0, 0x0)
[github_test_npu_gnmi_tags.conf.txt](https://github.com/influxdata/telegraf/files/8522927/github_test_npu_gnmi_tags.conf.txt)

	/go/src/github.com/influxdata/telegraf/plugins/inputs/gnmi/gnmi.go:256 +0x536
github.com/influxdata/telegraf/plugins/inputs/gnmi.(*GNMI).Start.func1({0xc000a70ea1, 0x12})
	/go/src/github.com/influxdata/telegraf/plugins/inputs/gnmi/gnmi.go:158 +0x125
created by github.com/influxdata/telegraf/plugins/inputs/gnmi.(*GNMI).Start
	/go/src/github.com/influxdata/telegraf/plugins/inputs/gnmi/gnmi.go:155 +0x9d3

Telegraf configuration:
github_test_npu_gnmi_tags.conf.txt

@fcuiller

@cprecup cprecup changed the title Assert string fails and crashes collection [gNMI - tag_only] Assert string fails and crashes collection Apr 20, 2022
@cprecup cprecup changed the title [gNMI - tag_only] Assert string fails and crashes collection [Input plugin] - [gNMI - tag_only] Assert string fails and crashes collection Apr 20, 2022
@bewing
Copy link
Contributor

bewing commented Apr 20, 2022

This looks like me mis-understanding golang interfaces. I thought it would be able to convert most types to string automatically.

I'll switch it to use fmt.Sprint(v) instead of v.(string)

bewing added a commit to bewing/telegraf that referenced this issue Apr 20, 2022
When writing gNMI `tag_only` tags, use fmt.Sprint to convert the
value interface to a string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants