console: make the upper limit for dimensions configurable

This commit is contained in:
Vincent Bernat
2022-10-05 08:22:25 +02:00
parent bc75d04bc6
commit 9c7e3db6e7
4 changed files with 25 additions and 9 deletions

View File

@@ -19,6 +19,8 @@ type Configuration struct {
DefaultVisualizeOptions VisualizeOptionsConfiguration
// HomepageTopWidgets defines the list of widgets to display on the home page.
HomepageTopWidgets []string `validate:"dive,oneof=src-as dst-as src-country dst-country exporter protocol etype src-port dst-port"`
// DimensionsLimit put an upper limit to the number of dimensions to return.
DimensionsLimit int `validate:"min=10"`
}
// VisualizeOptionsConfiguration defines options for the "visualize" tab.
@@ -43,6 +45,7 @@ func DefaultConfiguration() Configuration {
Dimensions: []queryColumn{queryColumnSrcAS},
},
HomepageTopWidgets: []string{"src-as", "src-port", "protocol", "src-country", "etype"},
DimensionsLimit: 50,
}
}

View File

@@ -470,12 +470,17 @@ The main components of the console service are `http`, `console`,
`authentication` and `database`. `http` accepts the [same
configuration](#http) as for the inlet service.
The console itself accepts the `default-visualize-options` and the
`homepage-top-widgets` keys. The first one defines default options for
the "visualize" tab and the second one defines the widgets to display
The console itself accepts the following keys:
- `default-visualize-options` to define default options for the
"visualize" tab and the second one defines the widgets to display
on the home page (among `src-as`, `dst-as`, `src-country`,
`dst-country`, `exporter`, `protocol`, `etype`, `src-port`, and
`dst-port`). Here is an example:
`dst-port`)
- `homepage-top-widgets` to define the widgets to display on the home page
- `dimensions-limit` to set the upper limit of the number of returned dimensions
Here is an example:
```yaml
console:

View File

@@ -13,7 +13,9 @@ identified with a specific icon:
## Unreleased
- 🌱 *docker*: Split demo exporters out of `docker-compose.yml`.
- 🌱 *docker*: Split demo exporters out of `docker-compose.yml`
- 🌱 *console*: Make the upper limit for dimensions configurable
(`console.dimensions-limit`)
## 1.6.0 - 2022-09-30
@@ -27,7 +29,7 @@ but also the AS paths and the communities. Check `inlet.bmp` and
-*inlet*: add `inlet.snmp.agents` to override exporter IP address for SNMP queries
- 🩹 *inlet*: handle sFlow specific interface number for locally
originated/terminated traffic, discarded traffic and traffic sent to
multiple interfaces.
multiple interfaces
- 🌱 *build*: Docker image is built using Nix instead of Alpine
[PR #155]: https://github.com/akvorado/akvorado/pull/155

View File

@@ -21,7 +21,7 @@ type graphHandlerInput struct {
End time.Time `json:"end" binding:"required,gtfield=Start"`
Points uint `json:"points" binding:"required,min=5,max=2000"` // minimum number of points
Dimensions []queryColumn `json:"dimensions"` // group by ...
Limit int `json:"limit" binding:"min=1,max=50"` // limit product of dimensions
Limit int `json:"limit" binding:"min=1"` // limit product of dimensions
Filter queryFilter `json:"filter"` // where ...
Units string `json:"units" binding:"required,oneof=pps l2bps l3bps"`
Bidirectional bool `json:"bidirectional"`
@@ -211,6 +211,12 @@ func (c *Component) graphHandlerFunc(gc *gin.Context) {
gc.JSON(http.StatusBadRequest, gin.H{"message": helpers.Capitalize(err.Error())})
return
}
if input.Limit > c.config.DimensionsLimit {
gc.JSON(http.StatusBadRequest,
gin.H{"message": fmt.Sprintf("Limit is set beyond maximum value (%d)",
c.config.DimensionsLimit)})
return
}
sqlQuery := input.toSQL()
sqlQuery = c.finalizeQuery(sqlQuery)