Commit Graph

23 Commits

Author SHA1 Message Date
Vincent Bernat
5e826d48b1 console: fix intermittent failure when requesting previous period
Notably when the main table is required, but also on rare conditions
when another table would be selected because of the interval selection.

This is not perfect as sometimes, we won't have the data.
2025-07-16 20:46:35 +02:00
Vincent Bernat
28783ff4f3 orchestrator/clickhouse: add support for distributed/replicated tables
Fix #605

All MergeTree tables are now replicated.

For some tables, a `_local` variant is added and the non-`_local`
variant is now distributed. The distributed tables are the `flows`
table, the `flows_DDDD` tables (where `DDDD` is a duration), as well as
the `flows_raw_errors` table. The `exporters` table is not distributed
and stays local.

The data is following this schema:

- data is coming from `flows_HHHH_raw` table, using the Kafka engine

- the `flows_HHHH_raw_consumer` reads data from `flows_HHHH_raw` (local)
  and sends it to `flows` (distributed) when there is no error

- the `flows_raw_errors_consumer` reads data from
  `flows_HHHH_raw` (local) and sends it to
  `flows_raw_errors` (distributed)

- the `flows_DDDD_consumer` reads fata from `flows_local` (local) and
  sends it to `flow_DDDD_local` (local)

- the `exporters_consumer` reads data from `flows` (distributed) and
  sends it to `exporters` (local)

The reason for `flows_HHHH_raw_consumer` to send data to the distributed
`flows` table, and not the local one is to ensure flows are
balanced (for example, if there is not enough Kafka partitions). But
sending it to `flows_local` would have been possible.

On the other hand, it is important for `flows_DDDD_consumer` to read
from local to avoid duplication. It could have sent to distributed, but
the data is now balanced correctly and we just send it to local instead
for better performance.

The `exporters_consumer` is allowed to read from the distributed `flows`
table because it writes the result to the local `exporters` table.
2024-04-04 22:03:12 +02:00
Vincent Bernat
4eaaf977b7 console: API validation for /graph/table-interval
Also add simple HTTP tests.
2024-03-25 14:49:48 +01:00
Itah
e41e64a3ac console/clickhouse: Expose API route to get best table and interval from time range 2024-03-25 14:20:22 +01:00
Vincent Bernat
2303b579e4 inlet/flow: document better how we get L3 from L2 length for sFlow
And after reading again, I don't understand why we are 10% off for l2bps.
2023-11-01 21:46:33 +01:00
Vincent Bernat
b464a00be1 console: fix %-display when speed of an interface is 0
And add a warning about that in the documentation.
2023-06-22 01:16:06 +02:00
Vincent Bernat
f07e930e60 console/clickhouse: use ExporterAddress instead of ExporterName for %
There is more guarantee that this is unique.
2023-02-09 21:25:30 +01:00
Vincent Bernat
d5cde97891 console: add “%” to available units
This is useful to detect interfaces that are close to saturation
quickly. It would usually require to group by exporter name and
interface name and it may not make sense for some graph types (like
stacked 100%). It is useful with Lines and Grid.
2023-02-09 21:14:36 +01:00
Vincent Bernat
740251f30d console: fix calculation of the L2 overhead when selecting L2 bps 2023-02-01 14:52:49 +01:00
Vincent Bernat
c6a9319b57 common/schema: turns into a component
This is a first step to make it accept configuration. Most of the
changes are quite trivial, but I also ran into some difficulties with
query columns and filters. They need the schema for parsing, but parsing
happens before dependencies are instantiated (and even if it was not the
case, parsing is stateless). Therefore, I have added a `Validate()`
method that must be called after instantiation. Various bits `panic()`
if not validated to ensure we catch all cases.

The alternative to make the component manages a global state would have
been simpler but it would break once we add the ability to add or
disable columns.
2023-01-18 12:22:10 +01:00
Vincent Bernat
e9cab6d64c console: remove debug print instructions 2022-11-22 19:20:30 +01:00
Vincent Bernat
9cddee94f8 console: fix selection of aggregate table on impossible resolution
When requesting a too small resolution for data that are too far in the
past, prefer to select a table with data than a table without.
Previously, the resolution was a hard requirement.
2022-11-21 18:38:50 +01:00
Vincent Bernat
78fb01c223 chore: fix some small issues detected by golangci-lint
But not using it as some linters are either plain incorrect (the one
suggesting to not use nil for `c.t.Context()`) or just
debatable (checking for err value is a good practice, but there are
good reasons to opt out in some cases).
2022-08-10 17:44:32 +02:00
Vincent Bernat
454a3eb9d3 console: add "previous period" mode
This displays a line for the previous period on stacked graphs.
Previous period depends on the current period. It could be hour, day,
week, month, or year.
2022-08-09 21:40:06 +02:00
Vincent Bernat
67703cc61e console: use templates to build SQL query
This is needed if we want to be able to mix use of several tables
inside a single query (for example, flows_1m0s for a part of the query
and flows_5m0s for another part to overlay historical data).

Also, the way we handle time buckets is now cleaner. The previous way
had two stages of rounding and was incorrect. We were discarding the
first and last value for this reason. The new way only has one stage
of rounding and is correct. It tries hard to align the buckets at the
specified start time. We don't need to discard these values anymore.
We still discard the last one because it could be incomplete (when end
is "now").
2022-08-09 11:45:40 +02:00
Vincent Bernat
1aa260bae2 console/filter: let parser tells us if we need the main table or not
This is more robust this way. We also introduce the ability to reverse
the direction of a filter.
2022-08-04 18:54:41 +02:00
Vincent Bernat
fad0c5db16 console: simplify SQL request by computing target resolution in Go 2022-07-26 23:51:32 +02:00
Vincent Bernat
84289c246e console: error out if no flows table is present yet 2022-07-12 21:45:31 +02:00
Vincent Bernat
d5dcc885bc console: use resolution when all tables are equally bad for old data 2022-07-09 08:42:42 +02:00
Vincent Bernat
412bb1f535 console: fill missing values with 0 for timeseries graphs 2022-07-08 09:43:09 +02:00
Vincent Bernat
8be1bca4fd license: AGPL-3.0-only
```
git ls-files \*.js \*.go \
  | xargs sed -i '1i // SPDX-FileCopyrightText: 2022 Free Mobile\n// SPDX-License-Identifier: AGPL-3.0-only\n'
git ls-files \*.vue \
  | xargs sed -i '1i <!-- SPDX-FileCopyrightText: 2022 Free Mobile -->\n<!-- SPDX-License-Identifier: AGPL-3.0-only -->\n'
```
2022-06-29 11:42:28 +02:00
Vincent Bernat
0879da9512 console: SrcAddress → SrcAddr when selecting flow table 2022-05-21 19:38:20 +02:00
Vincent Bernat
05276dbc63 console: make use of consolidated tables 2022-05-10 09:30:33 +02:00