Commit Graph

25 Commits

Author SHA1 Message Date
Vincent Bernat
74146e428d console: use a less hacky way to pass context to build SQL templates
Instead of trying to embed that in the template, provide a list of
templates with their associated input contexts and join them with UNION
ALL.
2025-09-04 07:41:08 +02:00
Vincent Bernat
98eb1bdba5 chore: make a run of gofumpt 2025-08-05 06:21:34 +02:00
dimbdr
6c0e8e1791 feat: configure limit type (#1482)
* Add limit type field selection

* Take into account LimitType to generate SQL request for Line graph

Also, add LimitType in default configuration for console

* Take into account LimitType to generate SQL request for Sankey graph

* Refactor on SQL query used by line and sankey

* Add limitType description in doc

* Order by max in graphLine when limitType max is used

* Fix query when using top max

Revert some modifications, as they were no longer relevant with the query fixed.

* Rework way to sort by max in line graph type

* Add configuration validation on LimitType

---------

Co-authored-by: Dimitri Baudrier <github.52grm@simplelogin.com>
2024-11-23 18:39:28 +01:00
Vincent Bernat
41510619ff console: fix top row selection when multiple sampling rates 2024-10-31 07:52:46 +01:00
Vincent Bernat
a449736a62 build: use Go 1.22 range over ints
Done with:

```
git grep -l 'for.*:= 0.*++' \
  | xargs sed -i -E 's/for (.*) := 0; \1 < (.*); \1\+\+/for \1 := range \2/'
```

And a few manual fixes due to unused variables. There is something fishy
in BMP rib test. Add a comment about that. This is not equivalent (as
with range, random is evaluated once, while in the original loop, it is
evaluated at each iteration). I believe the intent was to behave like
with range.
2024-08-14 10:11:35 +02:00
netixx
a312bc307e Use unit for sorting topX instead of always using bytes 2024-07-16 21:58:54 +02:00
Vincent Bernat
b5cc995557 console/query: SrcVlan/DstVlan as a dimension
Make the code more generic for IPv6 types and UInt types to
format them correctly.

Fix #623
2023-04-12 21:03:04 +02:00
Vincent Bernat
33a0a17fcb console: log SQL query on error 2023-02-25 10:51:13 +01:00
Vincent Bernat
63267f0f5b console: enable SrcAddr/DstAddr truncation to a fixed length 2023-02-22 20:55:21 +01:00
Vincent Bernat
609fa24a27 console: factor graphXXXHandlerInput
This is similar to what is done in TypeScript.
2023-02-22 20:54:58 +01:00
Vincent Bernat
e4c3a6b723 console: move /sankey and /graph to /graph/sankey and /graph/line
Also rename stuff to GraphSankey and GraphLine for consistency.
2023-02-22 20:54:58 +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
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
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
b5e48e8cfd console: also use dimensions to tell if we need to use main table 2022-08-08 11:35:18 +02:00
Vincent Bernat
b745cfd356 console: fix test about reverse filter direction 2022-08-08 09:42:27 +02:00
Vincent Bernat
c01489948f general: use map[string]struct{} instead of map[string]bool 2022-08-05 18:12:41 +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
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
335df53ac7 console/sankey: remove loops in DAG 2022-06-03 17:14:27 +02:00
Vincent Bernat
a1ff21eb09 console: ability to display L2 bps in addition to L3 bps 2022-06-03 11:47:38 +02:00
Vincent Bernat
2d4f5214bd tests: handle JSON in TestHTTPEndpoints 2022-05-26 10:40:55 +02:00
Vincent Bernat
6b6e1b8fba doc: update with a few words about the console 2022-05-24 22:09:21 +02:00
Vincent Bernat
be444652f0 console: ability to get values in pps instead of bps 2022-05-24 20:34:23 +02:00
Vincent Bernat
bd3c79c057 console: endpoint for sankey graph 2022-05-22 16:48:36 +02:00