Commit Graph

218 Commits

Author SHA1 Message Date
Vincent Bernat
217c484061 common/helpers: rename PrefixTo16 to PrefixTo6
Move it to common/helpers/ipv6.go and use it where needed.
2025-11-04 08:05:30 +01:00
Vincent Bernat
1cc33d4cc3 outlet/routing: fix lookup benchmark
Some checks failed
CI / 🤖 Check dependabot status (push) Has been cancelled
CI / 🐧 Test on Linux (${{ github.ref_type == 'tag' }}, misc) (push) Has been cancelled
CI / 🐧 Test on Linux (coverage) (push) Has been cancelled
CI / 🐧 Test on Linux (regular) (push) Has been cancelled
CI / ❄️ Build on Nix (push) Has been cancelled
CI / 🍏 Build and test on macOS (push) Has been cancelled
CI / 🧪 End-to-end testing (push) Has been cancelled
CI / 🔍 Upload code coverage (push) Has been cancelled
CI / 🔬 Test only Go (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 20) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 22) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 24) (push) Has been cancelled
CI / ⚖️ Check licenses (push) Has been cancelled
CI / 🐋 Build Docker images (push) Has been cancelled
CI / 🐋 Tag Docker images (push) Has been cancelled
CI / 🚀 Publish release (push) Has been cancelled
Update Nix dependency hashes / Update dependency hashes (push) Has been cancelled
The lookup benchmark was incorrect. When looking up a large number of
prefixes on each loop, b.Loop() calibrate on a larger and less precise
value than if it were measuring only one lookup where it would iterate
more to get a precise timing.

The problem may also exist for the insertion benchmark, but it's
difficult to do only one insertion per loop, as after many iterations,
there is nothing more we can insert. I suppose BART's author is not
trying to benchmark insertions because of this.

See https://github.com/akvorado/akvorado/pull/2040 and
https://github.com/gaissmai/bart/issues/351#issuecomment-3428806758.
2025-10-21 22:28:56 +02:00
Vincent Bernat
b1d6382585 common/embed: replace all go:embed use by an embedded archive
Some of the files were quite big:

- asns.csv ~ 3 MB
- index.js ~ 1.5 MB
- *.svg ~ 2 MB

Use a ZIP archive to put them all and embed it. This reduce the binary
size from 89 MB to 82 MB. 🤯

This also pulls some code modernization (use of http.ServeFileFS).
2025-09-03 00:00:05 +02:00
Vincent Bernat
413f923dcc docker: update ClickHouse to 25.8 2025-08-30 23:46:17 +02:00
Vincent Bernat
e2f1df9add tests: replace godebug by go-cmp for structure diffs
go-cmp is stricter and allow to catch more problems. Moreover, the
output is a bit nicer.
2025-08-23 16:03:09 +02:00
Vincent Bernat
59215899fc common/reporter: when running benchmarks, set log level to warning 2025-08-17 11:06:07 +02:00
Vincent Bernat
f7cc5e3dbc orchestrator/clickhouse: add a benchmark for networks.csv
```
goos: linux
goarch: amd64
pkg: akvorado/orchestrator/clickhouse
cpu: AMD Ryzen 5 5600X 6-Core Processor
BenchmarkNetworks-12                 482                 2.447 ms/op
```
2025-08-17 11:05:58 +02:00
Vincent Bernat
f974d5591a orchestrator/clickhouse: run some tests without a ClickHouse database
Some tests don't rely on the ClickHouse database at all. Allow them to
run without it.
2025-08-17 10:42:10 +02:00
kornix
2c8161e946 orchestrator/clickhouse: fix name for ICMP type 0, code 0
Name field updated for ICMP type 0, code 0 message

Fix #1892
2025-08-17 08:11:55 +02:00
Vincent Bernat
6118bb7aac common/helpers: convert SubnetMap to github.com/gaissmai/bart
I did not benchmark it myself, but it was benchmarked here:
 https://github.com/osrg/gobgp/issues/1414#issuecomment-3067255941

Of course, no guarantee that this benchmark matches our use cases.
Moreover, SubnetMap have been optimized to avoid parsing keys all
the time.

Also, the interface is a bit nicer and it uses netip.Prefix directly.

The next step is to convert outlet/routing/provider/bmp.
2025-08-16 09:38:44 +02:00
Vincent Bernat
98eb1bdba5 chore: make a run of gofumpt 2025-08-05 06:21:34 +02:00
Vincent Bernat
03b947e3c5 chore: fix many staticcheck warnings
The most important ones were fixed in the two previous commit.
2025-08-02 20:54:49 +02:00
Vincent Bernat
4f68271eea orchestrator/clickhouse: fix GeoIP-related tests 2025-08-02 18:06:38 +02:00
Vincent Bernat
0a10764cc9 orchestrator: switch to github.com/oschwald/maxminddb-golang/v2
Also, remove the AS name, this is not used at all.
2025-08-02 15:56:54 +02:00
Vincent Bernat
f5ae97e30d orchestrator/clickhouse: guess IP by connecting to port 80
It seems MacOS does not like to connect to port 0 (even if this is not
really a connection).
2025-07-30 08:36:12 +02:00
Vincent Bernat
a70029a4cd orchestrator/clickhouse: also guess the port when guessing HTTP URL 2025-07-30 08:11:28 +02:00
Vincent Bernat
19d07d350c common/remotedatasource: add a Stop() method
This is cleaner this way. We can't use it for the static provider as we
cannot stop a provider.
2025-07-29 08:36:16 +02:00
Vincent Bernat
5e669db4b3 chore: use errors.New() instead of fmt.Errorf() 2025-07-29 07:42:49 +02:00
Vincent Bernat
18beb310ee chore: replace interface{} with any 2025-07-29 07:42:49 +02:00
Vincent Bernat
10dfefebb4 orchestrator/clickhouse: avoid leaking contexts
Scope the cancel() method to avoid leaking contexts in an infinite loop.
2025-07-29 07:42:49 +02:00
Vincent Bernat
cce61cb0d6 common/remotedatasource: rename from remotedatasourcefetcher
Also rename RemoteDataSource to Source.
2025-07-28 18:41:50 +02:00
Vincent Bernat
47494ddf79 docker: udpate ClickHouse to 25.3
And sort tables to load them in the right order by looking at the
dependencies. This version of ClickHouse is less lenient.
2025-07-27 21:44:28 +02:00
Vincent Bernat
85226d0326 docker: create a database "test" for ClickHouse
Keep using the default one for the migration tests, but for the small
tests, use the "test" one.
2025-07-27 21:44:28 +02:00
Vincent Bernat
ac68c5970e inlet: split inlet into new inlet and outlet
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
2025-07-27 21:44:28 +02:00
Vincent Bernat
5a9a6e6f0a common/helpers: add a hook to deprecate some fields
And apply it to SystemLogTTL and PrometheusEndpoint. It would be nice to
log a warning, but we don't have access to a logger here.
2025-07-27 21:44:28 +02:00
Vincent Bernat
c70f3b74bf orchestrator/clickhouse: remove init.sh endpoint
Instead, just map configuration files inside the container. As we don't
have to push the schema anymore, pushing some arbitrary configuration
does not seem to be our job.
2025-07-27 21:44:28 +02:00
Vincent Bernat
ab96b05583 orchestrator/clickhouse: update protocols.csv 2025-07-13 09:39:45 +02:00
Vincent Bernat
d60a714b8c orchestrator/clickhouse: do not embed clickhouse database settings
Instead, properly use them from the clickhousedb component. Also provide
some automatic migration.
2025-07-08 09:06:31 +02:00
Vincent Bernat
183a5cbb25 orchestrator/clickhouse: do not hardcode schema hash in tests 2025-07-05 20:32:01 +02:00
Vincent Bernat
fb3f5f976b common: use slices from standard library instead of x/exp/slices 2025-06-15 13:58:30 +02:00
Vincent Bernat
e08331a286 common/helpers: switch to a blessed fork of mapstructure 2025-02-15 14:51:17 +01:00
Vincent Bernat
0b98674e69 orchestrator/clickhouse: set TTL for more log tables 2024-12-26 15:39:12 +01:00
Vincent Bernat
3d6d3461d9 orchestrator/clickhouse: also sets TTL for system.text_log table 2024-12-26 15:28:37 +01:00
netixx
f0d85ebb9e Fix system reload request to include db name 2024-12-17 18:23:00 +01:00
Vincent Bernat
aa9e5d1d67 orchestrator/clickhouse: escape user-provided strings
Notably username and password may contain quotes or backslashes.
2024-10-27 08:43:19 +01:00
netixx
b62a433858 Support basic-auth to reach orchestrator from clickhouse 2024-10-27 08:02:10 +01:00
Vincent Bernat
44d48fa9e6 orchestrator/clickhouse: remove unneeded indirection 2024-08-13 18:21:43 +02:00
Vincent Bernat
71239750ac chore: use time.NewTimer() instead of time.After()
Prefer use of time.NewTimer() when there is a risk of accumulating
timers in a loop. This enables the use of t.Stop() to avoid leaking too
many timers.

For tests, we don't need to do that. For places where the alternative to
the timer is just the app dying, we don't need to do that either.

In Go 1.23, it won't make a difference.
2024-07-06 16:10:37 +02:00
Vincent Bernat
7ec09aa6f3 build: don't ship tcp.csv and udp.csv
Fetch them when building. Keep them up-to-date for Nix like NPM/Go
modules.
2024-06-16 10:57:53 +02:00
Vincent Bernat
03e623f2b7 orchestrator/clickhouse: update protocols.csv 2024-06-14 22:29:43 +02:00
Vincent Bernat
e08b26a5f6 orchestrator/clickhouse: 24.3 got the INTERPOLATE fix 2024-06-14 22:15:43 +02:00
Vincent Bernat
f9f7369ca7 orchestrator/clickhouse: 24.4 gets the INTERPOLATE fix 2024-06-14 22:15:43 +02:00
Vincent Bernat
625429f27f orchestrator/clickhouse: add compatibility check for INTERPOLATE issue
I don't want to keep disabling the experimental analyzer forever. The
version check could be turned into disabling the experimental analyzer,
but this is better to push people to update their versions.

To be pushed only when 24.3 (LTS) and 24.4 gets the fix.
2024-06-14 22:15:43 +02:00
Paul Galceran
43c169677a Resolve L4 ports protocol names (#1257)
* fix: generation of protocols.csv file

* feat: generation of ports-tcp.csv and ports-udp.csv files

* build: add rules for creating udp and tcp csv files

* feat: create dictionary tcp and udp

* refactor: add replaceRegexpOne

* test: transform src port and dest port columns in SQL

* test: add TCP and UDP dictionaries for migration testing
2024-06-14 21:52:56 +02:00
Vincent Bernat
297e04b95c common: clickHouse → clickhouse
Let's say that we use "ClickHouse" and "clickhouse".
2024-06-09 14:59:09 +02:00
netixx
098973a20e Fix typo in merging of attributes for Site 2024-05-16 10:11:39 +02:00
Vincent Bernat
600f22f98f orchestrator/clickhouse: remove previous networks.csv temporary files
Fix #1221
2024-05-15 13:56:02 +02:00
Vincent Bernat
3b669ffe85 orchestrator/clickhouse: add a message when removing file 2024-05-11 20:04:21 +02:00
Vincent Bernat
93452cfbfa orchestrator: do not use AS names for tenants
This was introduced with #1059, but I think this was a mistake. Notably,
it enables erasing the tenants provided by the user.

It also opens the question whetever to have network sources or static
sources override more specific entries or not. This is currently not the
case, but then, if a more specific GeoIP entry appears, it may require
to add a more specific entry if overriding is needed.

This could also be configurable.
2024-04-27 15:07:38 +02:00
Vincent Bernat
f905f9dd25 orchestrator/clickhouse: fix panic in networks CSV refresher
Upon second refresh, we close again the "ready" channel, leading to a
panic.
2024-04-13 15:55:20 +02:00