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

SamplingRate is zero in some devices #12

Open
amichalu opened this issue Apr 2, 2020 · 14 comments
Open

SamplingRate is zero in some devices #12

amichalu opened this issue Apr 2, 2020 · 14 comments

Comments

@amichalu
Copy link

amichalu commented Apr 2, 2020

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

@amichalu amichalu changed the title SamplingRate in zero in some devices SamplingRate is zero in some devices Apr 2, 2020
@lspgn
Copy link
Contributor

lspgn commented Apr 5, 2020

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

@amichalu
Copy link
Author

amichalu commented Apr 5, 2020

Yes, I confirm.

Screenshot 2020-04-05 at 22 30 04

@lspgn
Copy link
Contributor

lspgn commented Apr 5, 2020

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?).

@amichalu
Copy link
Author

amichalu commented Apr 6, 2020 via email

@lspgn
Copy link
Contributor

lspgn commented Apr 6, 2020

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?

@NiXuB86
Copy link

NiXuB86 commented Apr 7, 2020

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

@amichalu
Copy link
Author

amichalu commented Apr 8, 2020

Thanks a lot, I have not noticed inverted addresses !

@NiXuB86
Copy link

NiXuB86 commented Apr 8, 2020

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

@amichalu
Copy link
Author

amichalu commented Apr 8, 2020

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

@NiXuB86
Copy link

NiXuB86 commented Apr 8, 2020

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
Copy link

NiXuB86 commented Apr 8, 2020

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
Copy link

NiXuB86 commented Apr 9, 2020

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
Copy link

NiXuB86 commented Apr 9, 2020

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

@amichalu
Copy link
Author

amichalu commented Apr 9, 2020

@NiXuB86 Thanks for quick solution to inverted addresses !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants