flow-pipeline icon indicating copy to clipboard operation
flow-pipeline copied to clipboard

SamplingRate is zero in some devices

Open amichalu opened this issue 4 years ago • 14 comments

In Mikrotik hEX PoE router SamplingRate is 0 so new dashboards are not showing traffic. In this case SamplingRate is simple 1.

amichalu avatar Apr 02 '20 10:04 amichalu

Hey @amichalu, Thank you for the report. Can you confirm that you/Mikrotik is using NetFlow v9?

lspgn avatar Apr 05 '20 00:04 lspgn

Yes, I confirm.

Screenshot 2020-04-05 at 22 30 04

amichalu avatar Apr 05 '20 20:04 amichalu

Is there anything that references Option Templates anywhere? Can you configure manually the sampling? Will look into adding a CLI option in GoFlow that defines a fixed Sampling Rate.

In the meantime, I suggest you set the sampling at query time (are you using Clickhouse/Postgres or other?).

lspgn avatar Apr 05 '20 22:04 lspgn

Yes, thanks exactly what I did, added in query.

Src ip and dst ip addresses presented on grafana NetFlow Clickhouse dashboard are all from public range, none of them from my private network, is it ok ? Netflow is set on ether interface with NAT.

W dniu pon., 6.04.2020 o 00:24 lspgn [email protected] napisał(a):

Is there anything that references Option Templates anywhere? Can you configure manually the sampling? Will look into adding a CLI option in GoFlow https://github.com/cloudflare/goflow that defines a fixed Sampling Rate.

In the meantime, I suggest you set the sampling at query time (are you using Clickhouse/Postgres or other?).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cloudflare/flow-pipeline/issues/12#issuecomment-609494607, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARFBKFO5LPEJCOTG4E5TRDRLEAJZANCNFSM4L2HLELA .

-- Pozdrawiam, Adam Michalunio

amichalu avatar Apr 06 '20 05:04 amichalu

I'm assuming it's expected but I don't know enough how Mikrotik samples (actioned before DNAT on ingress and after SNAT on egress). Could you check with a packet capture?

lspgn avatar Apr 06 '20 15:04 lspgn

I have the same problem with my Mikrotik hap ac2 and use IPFIX. SamplingRate is 0 for every sample. Also there is problem with SQL queries i think(I'm not sure) because IPv4 addresses is inverted(Example: 3.25.168.192 instead of 192.168.25.3), because of that you can think that there is no private IP's. I intercepted traffic on docker bridge and in netflow packets IPv4 addresses is fine. Screenshot_20200408_013156

NiXuB86 avatar Apr 07 '20 22:04 NiXuB86

Thanks a lot, I have not noticed inverted addresses !

amichalu avatar Apr 08 '20 09:04 amichalu

@amichalu Do you know the best way how to invert it back?

NiXuB86 avatar Apr 08 '20 09:04 NiXuB86

So does it look that inverted addresses regard only Mikrotik ? Dont know how to deal with it now.

amichalu avatar Apr 08 '20 09:04 amichalu

No, that not regard only mikrotik, because as i said before, i captured traffic on docker bridge, and in IPFIX packets IP addresses is fine.

NiXuB86 avatar Apr 08 '20 22:04 NiXuB86

I just tried to use netflow v9 instead of IPFIX, no difference in ClickHouse i have only inverted addresses and normal in netflow packets. Also with this query i have c0a8:1903:: instead of something like that 101:a8c0:: Screenshot_20200409_022834 And also IPv6 addresses are fine

NiXuB86 avatar Apr 08 '20 23:04 NiXuB86

I finally found a problem! It's caused by this function in query reinterpretAsUInt32(), it converts data to UInt32 and little endian from big endian, and IPv4NumToString() function expects UInt32 big endian. Because of that address is inverted. I didn't find any function to convert from little endian to big endian in ClickHouse docs. Screenshot_20200409_034716

NiXuB86 avatar Apr 09 '20 01:04 NiXuB86

So I finally fixed it with this query: Screenshot_20200409_102417 Normal IPv4: IPv4NumToString(reinterpretAsUInt32(substring(reverse(SrcAddr), 13, 4))) Inverted: IPv4NumToString(reinterpretAsUInt32(reverse(SrcAddr)))

And now I have the same problem with SamplingRate=0

NiXuB86 avatar Apr 09 '20 07:04 NiXuB86

@NiXuB86 Thanks for quick solution to inverted addresses !

amichalu avatar Apr 09 '20 20:04 amichalu