This change split the inlet component into a simpler inlet and a new
outlet component. The new inlet component receive flows and put them in
Kafka, unparsed. The outlet component takes them from Kafka and resume
the processing from here (flow parsing, enrichment) and puts them in
ClickHouse.
The main goal is to ensure the inlet does a minimal work to not be late
when processing packets (and restart faster). It also brings some
simplification as the number of knobs to tune everything is reduced: for
inlet, we only need to tune the queue size for UDP, the number of
workers and a few Kafka parameters; for outlet, we need to tune a few
Kafka parameters, the number of workers and a few ClickHouse parameters.
The outlet component features a simple Kafka input component. The core
component becomes just a callback function. There is also a new
ClickHouse component to push data to ClickHouse using the low-level
ch-go library with batch inserts.
This processing has an impact on the internal representation of a
FlowMessage. Previously, it was tailored to dynamically build the
protobuf message to be put in Kafka. Now, it builds the batch request to
be sent to ClickHouse. This makes the FlowMessage structure hides the
content of the next batch request and therefore, it should be reused.
This also changes the way we decode flows as they don't output
FlowMessage anymore, they reuse one that is provided to each worker.
The ClickHouse tables are slightly updated. Instead of using Kafka
engine, the Null engine is used instead.
Fix#1122
For each case, we test from native map and from YAML. This should
capture all the cases we are interested.
Also, simplify pretty diff by using stringer for everything. I don't
remember why this wasn't the case. Maybe IP addresses? It's possible
to opt out by overriding formatters.
This is a first step to accept another kind of GeoIP database (like
City). This also introduces the way we want to deprecate stuff:
transform the map structure.
This is not efficient. We can half the number of columns with a 1-hour
sampling, but we also half the compression ratio. This makes it quite
inefficient. Moreover, on a 5m resolution, Clickhouse executes
requests as fast as with the default 1s resolution.
```
┌─table────────┬─count()─┬───────────────size─┬──────────────ratio─┐
│ flows │ 565 │ 7.613838967867196 │ 22.40685541786694 │
│ flows_10s │ 585 │ 10.035293261520565 │ 12.433305037652858 │
│ flows_1h0m0s │ 577 │ 4.217916643247008 │ 9.856020485544366 │
│ flows_5m0s │ 584 │ 5.837094695307314 │ 10.835867553690852 │
│ flows_1m0s │ 582 │ 7.629598970524967 │ 11.400152339478653 │
└──────────────┴─────────┴────────────────────┴────────────────────┘
```
Instead, start from a clean sheet by rebuilding the flow table and
dropping the Date column, using smaller partitions and ordering a bit
more data to help compression.
This is a tentative to downsample flows. However, we can only group by
a prefix of the primary key. Therefore, all downsampling intervals
should be encoded in the order by clause, which is not what we want.