FRnOG #36: Akvorado

Vincent Bernat

Here are the slides I pre­sented for FRnOG #36 in Sep­tem­ber 2022. They are about Akvo­rado, a tool to col­lect net­work flows and vi­su­al­ize them. It was de­vel­oped by Free. I didn’t have time to pub­lish a blog post yet, but it should hap­pen soon!

The pre­sen­ta­tion, in French, was recorded. I have added Eng­lish subtitles.

Up­date (2024-01)

Akvo­rado was also pre­sented at LACNOG 2023 by Say­mon Araújo, and at SwiNOG#38 by Will van Gulik.

Transcript#

Akvorado: a Flow Collector and Visualizer

Hello. I will show you a new tool called Akvo­rado. It col­lects net­work flows and dis­plays them.

Commercial solution: Kentik

There are sev­eral ex­ist­ing so­lu­tions for this. For ex­am­ple, a com­mer­cial so­lu­tion is Ken­tik. It is easy to setup and it is bun­dled with a lot of fea­tures. It’s hosted in the cloud. It’s ex­pen­sive and it’s not open source at all.

Commercial solution: Elastiflow

An­other com­mer­cial so­lu­tion is Elas­ti­flow. Pre­vi­ously, it was open source, but not any­more. This time, you need to host it your­self. There is a free ver­sion that can han­dle up to 4000 flows/second. You need to pay if you want more.

DIY solution with open source

And there are so­lu­tions you can build your­self us­ing open-source com­po­nents. pmacct with RabbitMQ and data stored in­side Elas­tic­search. You can browse the re­sults with Kibana. You can also use GoFlow2, ex­port the data to Kafka, and store them in Click­House. You can lever­age Grafana to dis­play the re­sults. An­other com­bi­na­tion is vflow, Kafka, Apache Pinot, which is an­other an­a­lyt­ics data­base, and Apache Su­per­set to dis­play flows.

It’s free (as in beer and speech). It’s quite flex­i­ble. You can cus­tom­ize to your needs, as long as you have the right skills. You need to host the re­sult your­self. You have to do some re­search. You need to as­sem­ble ev­ery­thing, choose the com­po­nents, fix the bugs, un­der­stand how ev­ery­thing fits… You need some time to do all that.

New player: Akvorado

At Free, we have built our own tool, called Akvo­rado, which means “wa­ter wheel” in Es­peranto. If you type that in Google, you are pretty sure to find us. It’s a NetFlow/sFlow col­lec­tor. It adds more in­for­ma­tion with GeoIP, clas­si­fi­ca­tion rules, in­ter­face names, and se­ri­al­ize to Pro­to­buf. Kafka is used as a buf­fer. Then, data is stored in a Click­House data­base. There is a web in­ter­face to dis­play the results.

Selling points

It’s free (beer and speech). It’s quite per­for­mant. Ev­ery­thing is bun­dled: it is easy to de­ploy. It is not as flex­i­ble as your own cus­tom so­lu­tion, where you can choose each com­po­nent. The whole thing is im­posed on you, but it al­lows you to get some­thing quickly. Again, there is a web in­ter­face. It’s a big pro com­pared to other so­lu­tions where you need Grafana or Kibana. You have to host it your­self. De­pend­ing on how you see things, this can be an ad­van­tage or not.

Free

It’s free (speech and beer). It’s pub­lished with the AGPLv3 li­cense. It is an in­ter­nal tool we use at Free. We have no plan to sell it or sell ser­vices around it. It should stay free quite some time.

Performant

About the per­for­mances, I was quite sur­prised. This is quite per­for­mant, be­cause, to­day, we are still run­ning it on a sin­gle VM with 1TB of stor­age, 64 GB of mem­ory, and 24 vCPU. We are han­dling 30,000 flows/second, but look­ing at the stats, we should be able to go up to 100,000 flows/s on this sin­gle VM, while keep­ing 5 year worth of data.

When data are get­ting older, they are ag­gre­gated over 1 minute, 5 min­utes and 1 hour. IP and ports are also lost. Not keep­ing the IP ad­dresses for too long is a good thing, none­the­less. This is con­fig­urable. With our setup, we should be able to keep data for 5 years. As the project is still young, we will see if that’s true.

No assembly required

One way to de­ploy is to use Docker. You can down­load the project, run docker-compose and get some­thing work­ing. No need to know Kafka or Click­House, but this can help. There is a very spe­cial at­ten­tion that has been paid to the op­er­a­tions. There are logs and met­rics. We try to not break user con­fig­u­ra­tion dur­ing up­grade, even if this does not al­ways work. Click­House mi­gra­tions are au­to­mated. There is a doc­u­men­ta­tion you can look up.

Shipped with a web frontend

A big pro is the web in­ter­face. We are quite happy about it. You can test it on demo.akvorado.net.

Homepage
Dark mode

Here is the home page with some wid­gets, a dark mode which makes it apart from the com­petition.

Visualize

The “vi­su­al­iza­tion” tab is the most in­ter­est­ing. You can check your data. It looks like Ken­tik. Dunno why.

Documentation

The doc­u­men­ta­tion is builtin.

Five first minutes

As I said, get­ting started is easy. You down­load the tar­ball on GitHub, un­pack it in a di­rec­tory named akvorado, run docker-compose up point your browser to port 8081 and you get the demo site. With­out the data. You need to wait a bit to have fake data.

Next hour

If you have a bit more time, you can re­move the part gen­er­at­ing the ran­dom data from Akvo­rado con­fig­u­ra­tion file (which is writ­ten in YAML) and also from docker-compose, which starts the ser­vices to gen­er­ate the data. Then, you can con­fig­ure ev­ery­thing else. It’s easy.

Flows

About flow con­fig­u­ra­tion. Akvo­rado ac­cepts flows from any­one. There is noth­ing to con­fig­ure. Send NetFlow/IPFIX flows on port 2055 and sFlow on port 6343.

SNMP

Then, you need to con­fig­ure SNMP. It’s not su­per mod­ern but it is widely sup­ported. Cur­rently, this is not re­ally flex­i­ble. When send­ing flows from a given IP ad­dress, Akvo­rado uses the same IP to send SNMP queries, to fetch the router name and in­ter­faces. This is manda­tory to con­fig­ure that. Fill up the com­mu­nity. You need to con­fig­ure your routers to ac­cept SNMP requests.

Router classification

The sec­ond point is that, for each router send­ing flows, you can use clas­si­fi­ca­tion rules to add a group, a role, a site, a re­gion. It is done with rules. This is not manda­tory, but this is a good warmup for the next step, to work on your regex skills be­cause it re­lies on it a lot.

As an ex­am­ple, at Free, we name our de­vices th2-something, with the name of the site on first po­si­tion. The first rule says that from the ex­porter name, we cap­ture what is be­fore the first dash and it will be the site name. Then, if it ends with .it, the re­gion is Italy. If it starts with Wash­ing­ton or New York, the re­gion is USA. If it ends with .fr, the re­gion is France. You can as­sem­ble more or less com­plex rules.

Interface classification

Fol­low­ing the same idea, it is pos­si­ble to clas­sify in­ter­faces. It is not manda­tory but it is quite im­por­tant. You re­ally should do it. For each in­ter­face, we have a bound­ary which says ex­ter­nal, in­ter­nal or un­known. It is im­por­tant to clas­sify in­ter­faces on this cri­te­ria. You can also at­tach a con­nec­tiv­ity type. This could be tran­sit, PNI, IX, etc. A provider (who is on the re­mote side).

We use the same kind of rules. Here is a more com­plex ex­am­ple. We take the in­ter­face de­scrip­tion. If it starts with tran­sit, PNI, PPNI, etc., this part will be the con­nec­tiv­ity. A && is miss­ing from the end be­cause the rule is not over. If it matched, we use the sec­ond word that is the provider name. For ex­am­ple, at Free, we use Transit: Cogent and some other stuff. Here, we will cap­ture Cogent. If both rules matches, we also con­sider this is an ex­ter­nal in­ter­face. For ev­ery­thing else, we con­sider this is an in­ter­nal in­terface.

Remaining steps

That’s the only thing to do for a ba­sic de­ploy­ment. You can check if ev­ery­thing works on the web in­ter­face. Check the doc­u­men­ta­tion for the var­i­ous con­fig­u­ra­tion set­tings. There is also a trou­bleshoot­ing sec­tion which should help if you can’t get your flows in the in­ter­face. The met­rics will help in this case.

Web UI

The web in­ter­face. You can draw sev­eral kind of graphs. Do you want stack­ing ar­eas? Just lines? On a grid (each graph in its own box)? Or maybe a “sankey” graph (if you don’t know what this is, I have an ex­am­ple later)?

You choose the time pe­riod to ex­tract the data. Data can be grouped us­ing di­men­sions. You can group by AS, coun­try, provider, etc. You can fil­ter the data. It uses an SQL-like lan­guage. An ed­i­tor with com­ple­tion is here to help. It may be a bit raw, but with the com­ple­tion, I think you should quickly get what you want.

Examples

Here are a few ex­am­ples. Here, we have used the stacked ar­eas. Each color is a source AS. The fil­ter is… the in­put in­ter­face should be clas­si­fied as ex­ter­nal and the provider is Co­gent. It shows what we get from Co­gent, grouped by the AS num­ber. Here, we have en­abled the “bidi­rec­tional” op­tion. You have the in­put and the out­put. Akvo­rado au­to­mat­i­cally in­verts the fil­ter to get the sec­ond part of the graph.

Examples

Here, this is the same plot with lines. Stack­ing ar­eas is handy to see the to­tal, but this is dif­fi­cult to com­pare the value of each area. With lines, we can eas­ily see the or­ange line is al­ways lower than the blue line and this was not easy to see when us­ing stacked areas.

Examples

An­other ex­am­ple, still with stack­ing ar­eas. We group by “Eth­er­net type” (IPv4, IPv6) and we use a more com­plex fil­ter. The source should be one of the Google AS, and we get this result.

Other so­lu­tions are us­ing Grafana. Its tem­plat­ing lan­guage is more lim­ited. You have place hold­ers in your SQL re­quests that get re­placed by val­ues in drop down menus. You may have to cre­ate sev­eral dash­boards de­pend­ing on the kind of query you want to run. Maybe drop­down menus are enough, like when fil­ter­ing per AS or per coun­try, but for some things, you will have to cre­ate sev­eral dash­boards. Here, we have a tool specif­i­cally cre­ated for net­work flows.

Examples

Here is the “sankey” graph. You can see the flows go­ing from one di­men­sion to an­other. Each col­umn is a di­men­sion. We have the source AS, the in­put provider, the con­nec­tiv­ity type and the source port. Most of the traf­fic goes through Co­gent, which is a tran­sit provider. Two thirds of the traf­fic comes from port 443. A small part of the traf­fic comes from an IX (DECIX). It is a con­ve­nient graph to see where your traf­fic goes.

About AS names

About the AS names, I don’t know if you have no­ticed, but the AS names are quite clean. It is of­ten a prob­lem we have. PeeringDB is clean but does not have all the AS names. The RIR data­bases have all of them, but as it’s dif­fi­cult to up­date, there are AS with odd names. For ex­am­ple, Net­flix is AS-SSI.

I have pub­lished a small project mix­ing sev­eral data sources. There are rules to clean up the names. This is ex­ported as a CSV file. It’s up­dated weekly. Fetch it if you need it. It also uses DB-IP as a source in­stead of ARIN. ARIN li­cense does not al­low me to fetch the data I need to ex­tract the AS names.

Under the hood

Akvo­rado is split in 3 parts. It’s writ­ten in Go. There is the “in­let.” It re­ceives the flows, adds more data, se­ri­al­ize them and send the re­sult to Kafka. The con­sole com­po­nent serves the web UI and an un­doc­u­mented API. The or­ches­tra­tor com­po­nent con­fig­ures the other com­po­nents, in­clud­ing the ex­ter­nal ones, like Kafka and Click­House. It con­fig­ures them, cre­ates the ta­bles, etc. It’s one of the rea­son it works out-of-the-box.

On the draw­ing, you can see how the flows are built from the var­i­ous bits re­ceived from NetFlow and IPFIX, and data ex­tracted from SNMP. The AS num­bers can come from flows or GeoIP data­bases. The coun­try is from the GeoIP data­bases. The clas­si­fiers add more in­for­ma­tion. This makes the fi­nal flow sent to ClickHouse.

Open source components (backend)

Open source com­po­nents. We use GoFlow2 to col­lect net­work flows. Sarama for Kafka. For met­rics, this is the Prometheus client in Go. ze­rolog for log­ging. co­bra for the CLI. The ex­pres­sion lan­guage for clas­si­fi­ca­tion is expr. Gin for the web frame­work. Map­struc­ture and val­ida­tor to parse and val­i­date con­fig­u­ra­tion files.

Open source components (infrastructure)

For the in­fra­struc­ture side, there is a Kafka bro­ker in the mid­dle. It’s quite use­ful to dis­trib­ute con­sumers and pro­duc­ers. The in­let com­po­nent can be dis­trib­uted. You can put ev­ery­thing on a sin­gle VM, but, if you want, you can use sev­eral NetFlow col­lec­tors and they write into the same Kafka cluster.

Also, if you want to stop Click­House, you can. There is no data loss. Kafka acts as a buf­fer. When Click­House starts again, it will re­sume from the last in­gested flow. That’s why this is in­ter­est­ing to use Kafka. And that’s why it is a com­mon com­po­nent in many projects. It’s not hard to manage.

Click­House is a colum­nar data­base. Data are stored col­umn by col­umn in­stead of line by line in a reg­u­lar data­base. It al­lows one to ex­tract huge chunks of data quickly. Com­pared to other colum­nar data­bases, it uses a SQL di­alect which looks like reg­u­lar SQL. It is quite ver­sa­tile and there are a lot of func­tions avail­able. It can be per­for­mant with­out putting much ef­fort into it.

At Free, we are still us­ing the VM that was pro­vided for test­ing. It han­dles the load with­out a sweat. Click­House stays fast. I can’t do a demo, but most re­quests are ex­e­cuted in less than a sec­ond ex­cept for a few cases.

Open source components (frontend)

The web fron­tend was the most painful part to write. Java­Script has a lot of frame­works. Here are the com­po­nents we use in Akvo­rado. One of the most im­por­tant is the one han­dling the graphs. It is Apache ECharts. It is fea­ture­ful, flex­i­ble, and quite bug-free. Please, look at the demo on their web­site to check the avail­able fea­tures. If you want to write a tool with graphs to dis­play, have a look at it. It is not triv­ial to use, but it had all the fea­tures I needed.

Anti-DDOS

A fea­ture that is not avail­able yet, but as we have a lot of data in Click­House, we can build a prim­i­tive anti-DDoS sys­tem. We can run SQL re­quests on the data in Click­House. You run the re­quest to de­tect a DDoS in a script trig­gered ev­ery 10 sec­onds. And from the re­sult, you can build a Flowspec rule. It is in­jected in a BIRD in­stance and routers con­nect to it to fetch the cur­rent Flowspec rules.

ClickHouse query

As an ex­am­ple, here is one of the re­quests we use. It de­tects UDP am­pli­fi­ca­tion at­tacks. It is a bit com­plex, but let’s de­ci­pher it. Data are grouped minute by minute. We look at the 5 last minutes.

We group by des­ti­na­tion IP ad­dress (that’s the IP we want to pro­tect). We group by pro­to­col to fil­ter on the UDP pro­to­col. We group by source port, be­cause dur­ing an UDP am­pli­fi­ca­tion, the source port is known (it could be NTP for example).

We com­pute the band­width in bytes per sec­ond. A quan­tile for the packet size is com­puted. It’s one of the many fea­tures of Click­House. It al­lows us to eas­ily com­pute quan­tiles. We count the flows, the num­ber of unique source IP ad­dresses, the num­ber of unique coun­tries. When there are more than 50 sources or more than 10 coun­tries, and when we have more than 200 Mbps, and that the pro­to­col is UDP, it looks like an UDP am­pli­fi­ca­tion attack.

FlowSpec rule

We cre­ate a Flowspec rule that looks like this. For the tar­get IP, when the source port is 123, and the packet length is 468, the pro­to­col is UDP, we drop the packet. We don’t rate-limit be­cause le­git­i­mate flows will be flooded by the il­le­git­i­mate ones and they will be dropped too. Us­ing Flowspec is nice: we not only re­strict one source port, but also a spe­cific packet size. Le­git­i­mate NTP pack­ets are never 468 bytes. It’s al­ways smaller. The cus­tomer will be pro­tected and won’t no­tice a thing.

Future plans

As for the planned fea­tures, we are work­ing on the BGP sup­port to get AS paths, com­mu­ni­ties, and ori­gin AS, no­tably when they are in­ter­nals as we can’t get them from GeoIP. It will be avail­able soon. We will also im­ple­ment traf­fic fore­cast­ing. And maybe anom­aly de­tec­tion as it gets to­gether. It should en­able you to check your ca­pac­ity plan­ning for a router.

VRF sup­port is also planned. We don’t need it yet. We only sup­port one VRF be­cause we are only us­ing Akvo­rado for our pub­lic traffic.

Dash­boards are also planned. How­ever, you can cur­rently book­mark the URL. The URL con­tains a hash of the re­quest. You can share them with a col­league to show the re­sult of a re­quest you built. Or save it somewhere.

Questions?