Closed joseluisgonzalezca closed 1 month ago
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.
@borjam please test the binary in PR #16009, available as soon as CI finished the tests, and let me know if this fixes the issue.
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 src_port
and dst_port
for the TCP layer. Variables have layers.TCPPort
type but they should be converted to uint16
to be properly added to metrics:
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):https://github.com/influxdata/telegraf/blob/640eda0ca699a97704602076116c520ec5f425a0/metric/metric.go#L55
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:https://github.com/influxdata/telegraf/blob/640eda0ca699a97704602076116c520ec5f425a0/plugins/inputs/netflow/sflow_v5.go#L372 https://github.com/influxdata/telegraf/blob/640eda0ca699a97704602076116c520ec5f425a0/plugins/inputs/netflow/sflow_v5.go#L373
Hope this helps. Thanks for your work!