-
-
Notifications
You must be signed in to change notification settings - Fork 124
[feature] Added configurable timeseries database backends #672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| [agent] | ||
| # Keep data series compatible with OpenWISP records written over HTTP. | ||
| omit_hostname = true | ||
|
|
||
| [[inputs.socket_listener]] | ||
| service_address = "udp://:8089" | ||
| data_format = "influx" | ||
| read_buffer_size = 8388608 | ||
| [inputs.socket_listener.tags] | ||
| bucket = "${TIMESERIES_DB}" | ||
|
|
||
| [[inputs.socket_listener]] | ||
| service_address = "udp://:8090" | ||
| data_format = "influx" | ||
| read_buffer_size = 8388608 | ||
| [inputs.socket_listener.tags] | ||
| bucket = "${TIMESERIES_DB}_short" | ||
|
|
||
| [[outputs.influxdb_v2]] | ||
| urls = ["http://influxdb2:8086"] | ||
| token = "${INFLUXDB2_TOKEN}" | ||
| organization = "${INFLUXDB2_ORG}" | ||
| bucket = "${TIMESERIES_DB}" | ||
| bucket_tag = "bucket" | ||
| exclude_bucket_tag = true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ services: | |
| - postgres | ||
| - redis | ||
| - postfix | ||
| - influxdb | ||
| - ${TIMESERIES_BACKEND:-influxdb} | ||
|
|
||
| api: | ||
| image: openwisp/openwisp-api:${OPENWISP_VERSION:-edge} | ||
|
|
@@ -214,6 +214,47 @@ services: | |
| volumes: | ||
| - influxdb_data:/var/lib/influxdb | ||
|
|
||
| influxdb2: | ||
| image: influxdb:2.9.1-alpine | ||
| restart: always | ||
| profiles: | ||
| - influxdb2 | ||
| environment: | ||
| - DOCKER_INFLUXDB_INIT_MODE=setup | ||
| - DOCKER_INFLUXDB_INIT_USERNAME=$INFLUXDB2_USER | ||
| - DOCKER_INFLUXDB_INIT_PASSWORD=$INFLUXDB2_PASS | ||
| - DOCKER_INFLUXDB_INIT_ORG=$INFLUXDB2_ORG | ||
| - DOCKER_INFLUXDB_INIT_BUCKET=$INFLUXDB2_BUCKET | ||
| - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=$INFLUXDB2_TOKEN | ||
| volumes: | ||
| - influxdb2_data:/var/lib/influxdb2 | ||
|
|
||
| telegraf: | ||
| image: telegraf:1.31-alpine | ||
| restart: always | ||
| profiles: | ||
| - influxdb2 | ||
| environment: | ||
| - TIMESERIES_DB=$INFLUXDB2_BUCKET | ||
| - INFLUXDB2_ORG=$INFLUXDB2_ORG | ||
| - INFLUXDB2_TOKEN=$INFLUXDB2_TOKEN | ||
| volumes: | ||
| - ./deploy/telegraf.conf:/etc/telegraf/telegraf.conf:ro | ||
| depends_on: | ||
| - influxdb2 | ||
|
|
||
| elasticsearch: | ||
| image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-9.4.3} | ||
| restart: always | ||
| profiles: | ||
| - elasticsearch | ||
| environment: | ||
| - discovery.type=single-node | ||
| - xpack.security.enabled=false | ||
| - ES_JAVA_OPTS=-Xms512m -Xmx512m | ||
|
Comment on lines
+251
to
+254
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift Do not disable Elasticsearch security in the default service. When the As per path instructions, flag potential security vulnerabilities. 🤖 Prompt for AI AgentsSource: Path instructions |
||
| volumes: | ||
| - elasticsearch_data:/usr/share/elasticsearch/data | ||
|
|
||
| redis: | ||
| image: redis:alpine | ||
| restart: always | ||
|
|
@@ -222,6 +263,8 @@ services: | |
|
|
||
| volumes: | ||
| influxdb_data: {} | ||
| influxdb2_data: {} | ||
| elasticsearch_data: {} | ||
| postgres_data: {} | ||
| redis_data: {} | ||
| openwisp_certs: {} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,10 @@ Additionally, you can search for the following prefixes: | |
|
|
||
| - ``OPENWISP_``: OpenWISP application settings. | ||
| - ``DB_``: PostgreSQL Database settings. | ||
| - ``TIMESERIES_``: Timeseries database backend settings. | ||
| - ``INFLUXDB_``: InfluxDB settings. | ||
| - ``INFLUXDB2_``: InfluxDB 2.x settings. | ||
| - ``ELASTICSEARCH_``: Elasticsearch settings. | ||
| - ``DJANGO_``: Django settings. | ||
| - ``EMAIL_``: Email settings (see also ``POSTFIX_``). | ||
| - ``POSTFIX_``: Postfix settings (see also ``EMAIL_``). | ||
|
|
@@ -642,11 +645,69 @@ PostgreSQL Database | |
| <https://docs.djangoproject.com/en/4.2/ref/contrib/gis/db-api/#module-django.contrib.gis.db.backends>`__. | ||
| - **Default:** ``django.contrib.gis.db.backends.postgis`` | ||
|
|
||
| InfluxDB | ||
| -------- | ||
| Timeseries Database | ||
| ------------------- | ||
|
|
||
| InfluxDB 1.8 is the default timeseries database used by the | ||
| :doc:`Monitoring module </monitoring/index>`. InfluxDB 2.x and | ||
| Elasticsearch are available as opt-in backends. | ||
|
|
||
| To use the default InfluxDB 1.8 backend: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| TIMESERIES_BACKEND=influxdb | ||
|
|
||
| To use InfluxDB 2.x: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| TIMESERIES_BACKEND=influxdb2 | ||
| COMPOSE_PROFILES=influxdb2 | ||
|
|
||
| To use Elasticsearch: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| TIMESERIES_BACKEND=elasticsearch | ||
| COMPOSE_PROFILES=elasticsearch | ||
|
|
||
| When using an optional backend, both ``TIMESERIES_BACKEND`` and | ||
| ``COMPOSE_PROFILES`` must be set to the same backend name. | ||
|
|
||
| ``COMPOSE_PROFILES`` | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Docker Compose profiles to enable. Set this to | ||
| ``influxdb2`` or ``elasticsearch`` when using one of the optional | ||
| timeseries backend services. | ||
| - **Valid Values:** A comma-separated list of Docker Compose profile names. | ||
| - **Default:** ``""`` (empty string). | ||
|
|
||
| ``TIMESERIES_BACKEND`` | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| InfluxDB is the default time series database used by the :doc:`Monitoring | ||
| module </monitoring/index>`. | ||
| - **Explanation:** Timeseries database backend used by OpenWISP Monitoring. | ||
| - **Valid Values:** ``influxdb``, ``influxdb2``, ``elasticsearch``. | ||
| - **Default:** ``influxdb``. | ||
|
|
||
| ``TIMESERIES_UDP_WRITES`` | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Whether to write timeseries data over UDP. InfluxDB 2.x | ||
| UDP writes are handled by the ``telegraf`` container because InfluxDB 2.x | ||
| does not support UDP writes natively. Elasticsearch does not support UDP | ||
| writes. | ||
| - **Valid Values:** ``True``, ``False``. | ||
| - **Default:** ``False``. | ||
|
|
||
| ``TIMESERIES_UDP_PORT`` | ||
| ~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** UDP port used for timeseries writes. For InfluxDB 2.x, | ||
| this is the Telegraf listener port. | ||
| - **Valid Values:** INTEGER. | ||
| - **Default:** ``8089``. | ||
|
|
||
| ``INFLUXDB_USER`` | ||
| ~~~~~~~~~~~~~~~~~ | ||
|
|
@@ -692,6 +753,87 @@ module </monitoring/index>`. | |
| - **Valid Values:** STRING. | ||
| - **Default:** ``26280h0m0s`` (3 years). | ||
|
|
||
| ``INFLUXDB2_USER`` | ||
| ~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Username used to initialize the InfluxDB 2.x Docker | ||
| container. | ||
| - **Valid Values:** STRING. | ||
| - **Default:** ``admin``. | ||
|
|
||
| ``INFLUXDB2_PASS`` | ||
| ~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Password used to initialize the InfluxDB 2.x Docker | ||
| container. | ||
| - **Valid Values:** STRING. | ||
| - **Default:** ``adminadmin``. | ||
|
|
||
| ``INFLUXDB2_BUCKET`` | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Bucket used by the InfluxDB 2.x backend. | ||
| - **Valid Values:** STRING. | ||
| - **Default:** ``openwisp``. | ||
|
|
||
| ``INFLUXDB2_HOST`` | ||
| ~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Host to be used when connecting to InfluxDB 2.x. | ||
| - **Valid Values:** any valid hostname or IP address. | ||
| - **Default:** ``influxdb2``. | ||
|
|
||
| ``INFLUXDB2_PORT`` | ||
| ~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Port on which InfluxDB 2.x is listening. | ||
| - **Valid Values:** INTEGER. | ||
| - **Default:** ``8086``. | ||
|
Comment on lines
+779
to
+791
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Document
As per path instructions, documentation must remain consistent with implemented behavior. 🤖 Prompt for AI AgentsSource: Path instructions |
||
|
|
||
| ``INFLUXDB2_ORG`` | ||
| ~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** InfluxDB 2.x organization used by OpenWISP Monitoring. | ||
| - **Valid Values:** STRING. | ||
| - **Default:** ``openwisp``. | ||
|
|
||
| ``INFLUXDB2_TOKEN`` | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** InfluxDB 2.x API token used by OpenWISP Monitoring. | ||
| - **Valid Values:** STRING. | ||
| - **Default:** ``openwisp-token``. | ||
|
|
||
| ``INFLUXDB2_UDP_HOST`` | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Hostname of the Telegraf UDP listener used for InfluxDB | ||
| 2.x UDP writes. | ||
| - **Valid Values:** any valid hostname or IP address. | ||
| - **Default:** ``telegraf``. | ||
|
|
||
| ``ELASTICSEARCH_NAME`` | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Name used by OpenWISP Monitoring for Elasticsearch data | ||
| streams. | ||
| - **Valid Values:** STRING. | ||
| - **Default:** ``openwisp``. | ||
|
|
||
| ``ELASTICSEARCH_URL`` | ||
| ~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** URL used to connect to Elasticsearch. | ||
| - **Valid Values:** URL. | ||
| - **Default:** ``http://elasticsearch:9200``. | ||
|
|
||
| ``ELASTICSEARCH_VERSION`` | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| - **Explanation:** Elasticsearch Docker image version. | ||
| - **Valid Values:** Any valid Elasticsearch Docker image tag. | ||
| - **Default:** ``9.4.3``. | ||
|
|
||
| Postfix | ||
| ------- | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Honor the configurable InfluxDB 2.x endpoint and UDP port.
images/common/openwisp/settings.pyhonorsINFLUXDB2_HOST,INFLUXDB2_PORT, andTIMESERIES_UDP_PORT. This file fixes the listeners to8089and8090and fixes the output URL tohttp://influxdb2:8086. If an operator overrides these settings, UDP writes fail or are stored in a different InfluxDB instance than HTTP writes.Pass the relevant values through
docker-compose.yml, parameterize this configuration, and add a regression test with nondefault host or port values.As per path instructions, tests must cover relevant success, error, boundary, and unusual input scenarios.
🤖 Prompt for AI Agents
Source: Path instructions