-
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
inputs.netflow
: Source MAC address and Destination MAC address are not being included in metrics when using sFlow v5 decoder
#15918
Comments
Thanks @joseluisgonzalezca for your report. Will look into this as soon as time permits. |
Just a quick note. In order to avoid confusion with Netflow, please check whether there are "source MAC address" and "destination MAC address" fields without any in or out reference. The "in_src_mac", "out_src_mac", "in_dst_mac" and "out_dst_mac" Netflow fields make sense when dealing with Netflow (IP) traffic going through a router but not when dealing with Ethernet frames. |
I have run a little test using the new binaries and the sFlow traffic example that I provided. Everything is working as expected. Thank you for making the fix in such short time. This issue can be closed if the fix is merged to the main branch. |
Thanks for testing the PR so quickly @joseluisgonzalezca! The issue will automatically be closed as soon as the PR is merged... |
I have a found similar issue with https://github.com/influxdata/telegraf/blob/master/plugins/inputs/netflow/sflow_v5.go#L414 https://github.com/influxdata/telegraf/blob/master/plugins/inputs/netflow/sflow_v5.go#L415 I see that UDP case is already being covered. |
@joseluisgonzalezca could you please open a new issue for that so we can keep track of it? Mention me there and I will take a look. |
Relevant telegraf.conf
Logs from Telegraf
System info
Telegraf v1.32.0 running on Docker, Debian 12 as base OS
Docker
Docker compose for testing environment:
Steps to reproduce
I have captured some sFlow traffic using tcpdump. You can use this trace as reference:
telegraf-sflow.pcap.zip
Because I'm using default Netflow port (2055/UDP) for sFlow traffic, Wireshark may not be able to dissect it. You can tune Wireshark analyzer to decode traffic as sFlow:
I have taken one of this packets and copied its content directly from Wireshark to a binary file. The final step requires to run Telegraf locally (or with Docker) with the provided configuration and send the sFlow message stored in the file by using Netcat:
sflow-packet.bin.zip
Expected behavior
Source MAC address and destination MAC address must be present in Telegraf metrics.
Actual behavior
Fields are being decoded by
goflow2
dissector but are not being properly included in TelegrafMetric
struct.Additional info
I have made some tests with a dummy function to try to identity the underlying problem. I'm certain that the problem comes from the type of the decoded
SrcMAC
andDstMAC
variables. If you execute this code in local, you can see that the type isnet.HardwareAddr
:However, when the fields are included in the metric, Telegraf checks that the type is a known one (check
convertField
function which is called when a new Telegraf metric is created):telegraf/metric/metric.go
Line 55 in 640eda0
I think the fix is quite straightforward. It's only necessary to modify the lines where MAC addresses are included to the fields map and convert them to string by using
String()
function:telegraf/plugins/inputs/netflow/sflow_v5.go
Line 372 in 640eda0
telegraf/plugins/inputs/netflow/sflow_v5.go
Line 373 in 640eda0
Hope this helps. Thanks for your work!
The text was updated successfully, but these errors were encountered: