mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
inlet/geoip: add an option to make the database optional
This commit is contained in:
@@ -30,8 +30,9 @@ inlet:
|
|||||||
kafka:
|
kafka:
|
||||||
compression-codec: zstd
|
compression-codec: zstd
|
||||||
geoip:
|
geoip:
|
||||||
# asn-database: /usr/share/GeoIP/GeoLite2-ASN.mmdb
|
optional: true
|
||||||
# country-database: /usr/share/GeoIP/GeoLite2-Country.mmdb
|
asn-database: /usr/share/GeoIP/GeoLite2-ASN.mmdb
|
||||||
|
country-database: /usr/share/GeoIP/GeoLite2-Country.mmdb
|
||||||
snmp:
|
snmp:
|
||||||
workers: 10
|
workers: 10
|
||||||
flow:
|
flow:
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ A few synthetic flows are generated in the background. Take a look at
|
|||||||
the `docker-compose.yml` file if you want to setup the GeoIP database.
|
the `docker-compose.yml` file if you want to setup the GeoIP database.
|
||||||
It requires two environment variables to fetch them from
|
It requires two environment variables to fetch them from
|
||||||
[MaxMind](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data).
|
[MaxMind](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data).
|
||||||
The appropriate configuration also needs to be uncommented in
|
|
||||||
`akvorado.yaml`.
|
|
||||||
|
|
||||||
Be sure to flush the conntrack table after starting. See the
|
Be sure to flush the conntrack table after starting. See the
|
||||||
[troubleshooting section](05-troubleshooting.md#no-packets-received)
|
[troubleshooting section](05-troubleshooting.md#no-packets-received)
|
||||||
|
|||||||
@@ -203,6 +203,8 @@ is provided, the component is inactive. It accepts the following keys:
|
|||||||
|
|
||||||
- `asn-database` tells the path to the ASN database
|
- `asn-database` tells the path to the ASN database
|
||||||
- `country-database` tells the path to the country database
|
- `country-database` tells the path to the country database
|
||||||
|
- `optional` makes the presence of the databases optional on start
|
||||||
|
(when not present on start, the component is just disabled)
|
||||||
|
|
||||||
[MaxMind DB file format]: https://maxmind.github.io/MaxMind-DB/
|
[MaxMind DB file format]: https://maxmind.github.io/MaxMind-DB/
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ volumes:
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
geoip:
|
geoip:
|
||||||
|
# Put ACCOUNT_ID and LICENSE_KEY here, or provide them on the command-line
|
||||||
|
# (env GEOIPUPDATE_ACCOUNT_ID=... GEOIPUPDATE_LICENSE_KEY=... docker-compose ...)
|
||||||
image: maxmindinc/geoipupdate:v4
|
image: maxmindinc/geoipupdate:v4
|
||||||
environment:
|
environment:
|
||||||
- GEOIPUPDATE_ACCOUNT_ID
|
- GEOIPUPDATE_ACCOUNT_ID
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ type Configuration struct {
|
|||||||
ASNDatabase string
|
ASNDatabase string
|
||||||
// CountryDatabase defines the path to the country database.
|
// CountryDatabase defines the path to the country database.
|
||||||
CountryDatabase string
|
CountryDatabase string
|
||||||
|
// Optional tells if we need to error if not present on start.
|
||||||
|
Optional bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultConfiguration represents the default configuration for the
|
// DefaultConfiguration represents the default configuration for the
|
||||||
|
|||||||
@@ -90,10 +90,10 @@ func (c *Component) openDatabase(which string, path string, container *atomic.Va
|
|||||||
|
|
||||||
// Start starts the GeoIP component.
|
// Start starts the GeoIP component.
|
||||||
func (c *Component) Start() error {
|
func (c *Component) Start() error {
|
||||||
if err := c.openDatabase("country", c.config.CountryDatabase, &c.db.country); err != nil {
|
if err := c.openDatabase("country", c.config.CountryDatabase, &c.db.country); err != nil && !c.config.Optional {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := c.openDatabase("asn", c.config.ASNDatabase, &c.db.asn); err != nil {
|
if err := c.openDatabase("asn", c.config.ASNDatabase, &c.db.asn); err != nil && !c.config.Optional {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if c.db.country.Load() == nil && c.db.asn.Load() == nil {
|
if c.db.country.Load() == nil && c.db.asn.Load() == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user