790f8a6abf
* Minor changes on mqtt publisher using nats Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove vernemq dependencies Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Restore VerneMQ config files Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Fix Makefile to support custom Docker profiles The Makefile has been updated to support custom Docker profiles. Previously, the Makefile only supported the default profiles for the message broker and MQTT broker. Now, the Makefile allows for custom profiles to be specified using environment variables. If the MF_BROKER_TYPE or MF_MQTT_BROKER_TYPE variables are not set, the default values "nats" and "nats" will be used, respectively. This change enables more flexibility in configuring the Docker environment for the project. The `run` target has also been modified to use the correct broker configuration file based on the MF_BROKER_TYPE variable. The sed command in the `run` target now replaces the placeholder in the docker/docker-compose.yml file with the appropriate broker configuration file. This commit improves the Makefile to support custom Docker profiles and ensures the correct broker configuration file is used when running the project. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Fix queue binding issue in RabbitMQ pubsub The commit fixes an issue in the RabbitMQ pubsub implementation where the queue binding was not correctly set up. Instead of using the topic as the queue name, the commit now uses a unique client ID generated by combining the topic and subscriber ID. This ensures that each subscriber has its own dedicated queue. The commit also updates the queue binding to use the correct queue name. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor Docker config editing in Makefile The commit refactors the `edit_docker_config` function in the Makefile to improve readability and maintainability. The changes include: - Removing unnecessary conditionals related to the `rabbitmq` broker These changes ensure that the Docker configuration is correctly updated based on the specified MQTT broker type. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Fix failing tests on RabbitMQ Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor MQTT_BROKER comment in docker-compose.yml The MQTT_BROKER comment in the docker-compose.yml file has been updated to provide a more accurate description of its functionality. The comment now states that the MQTT_BROKER handles MQTT communication between MQTT adapters and the message broker, instead of Mainflux services. This change improves clarity and aligns with the actual purpose of the MQTT_BROKER. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename `MF_BROKER` to `MF_MESSAGE_BROKER` The Makefile and Semaphore configuration files have been refactored to update the variable names related to the message broker type. These changes ensure consistency and clarity in the codebase by using more descriptive variable names related to the message broker type. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Fix Docker profile configuration for nats_rabbitmq Update the Docker profile configuration for nats_rabbitmq by replacing the NATS URL in the .env file with the correct value. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename MF_BROKER_URL to MF_MESSAGE_BROKER_URL Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Fix MQTT QoS level in pubsub.go The MQTT QoS level in the pubsub.go file was set to 1, which is the default level. However, since NATS supports up to QoS 1, I updated the QoS level comment to reflect this. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor NewPublisher to accept QoS parameter The NewPublisher function in the pkg/messaging/mqtt/publisher.go file has been refactored to accept a new parameter, qos, which represents the Quality of Service level for MQTT message publishing. This change allows for more flexibility in configuring the MQTT publisher. The NewPublisher function now has the following signature: ```go func NewPublisher(address string, qos uint8, timeout time.Duration) (messaging.Publisher, error) ``` This change ensures that the MQTT publisher can be created with the desired QoS level, enhancing the reliability and delivery guarantees of the published messages. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Fix test assertions in pubsub_test.go The test assertions in the pubsub_test.go file were incorrect. This commit fixes the assertions to properly compare the expected and received message values. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Test configurable MQTT broker Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> Signed-off-by: rodneyosodo <blackd0t@protonmail.com> |
||
---|---|---|
.. | ||
README.md | ||
consumer.go | ||
consumer_test.go | ||
doc.go | ||
fields.go | ||
setup_test.go | ||
tags.go |
README.md
InfluxDB writer
InfluxDB writer provides message repository implementation for InfluxDB.
Configuration
The service is configured using the environment variables presented in the following table. Note that any unset variables will be replaced with their default values.
Variable | Description | Default |
---|---|---|
MF_INFLUX_WRITER_LOG_LEVEL | Log level for InfluxDB writer (debug, info, warn, error) | info |
MF_INFLUX_WRITER_CONFIG_PATH | Config file path with message broker subjects list, payload type and content-type | /configs.toml |
MF_INFLUX_WRITER_HTTP_HOST | Service HTTP host | |
MF_INFLUX_WRITER_HTTP_PORT | Service HTTP port | 9006 |
MF_INFLUX_WRITER_HTTP_SERVER_CERT | Path to server certificate in pem format | |
MF_INFLUX_WRITER_HTTP_SERVER_KEY | Path to server key in pem format | |
MF_INFLUXDB_PROTOCOL | InfluxDB protocol | http |
MF_INFLUXDB_HOST | InfluxDB host name | mainflux-influxdb |
MF_INFLUXDB_PORT | Default port of InfluxDB database | 8086 |
MF_INFLUXDB_ADMIN_USER | Default user of InfluxDB database | mainflux |
MF_INFLUXDB_ADMIN_PASSWORD | Default password of InfluxDB user | mainflux |
MF_INFLUXDB_NAME | InfluxDB database name | mainflux |
MF_INFLUXDB_BUCKET | InfluxDB bucket name | mainflux-bucket |
MF_INFLUXDB_ORG | InfluxDB organization name | mainflux |
MF_INFLUXDB_TOKEN | InfluxDB API token | mainflux-token |
MF_INFLUXDB_DBURL | InfluxDB database URL | |
MF_INFLUXDB_USER_AGENT | InfluxDB user agent | |
MF_INFLUXDB_TIMEOUT | InfluxDB client connection readiness timeout | 1s |
MF_INFLUXDB_INSECURE_SKIP_VERIFY | InfluxDB client connection insecure skip verify | false |
MF_MESSAGE_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
MF_JAEGER_URL | Jaeger server URL | http://jaeger:14268/api/traces |
MF_SEND_TELEMETRY | Send telemetry to mainflux call home server | true |
MF_INFLUX_WRITER_INSTANCE_ID | InfluxDB writer instance ID |
Deployment
The service itself is distributed as Docker container. Check the influxdb-writer
service section in docker-compose to see how service is deployed.
To start the service, execute the following shell script:
# download the latest version of the service
git clone https://github.com/mainflux/mainflux
cd mainflux
# compile the influxdb
make influxdb
# copy binary to bin
make install
# Set the environment variables and run the service
MF_INFLUX_WRITER_LOG_LEVEL=[Influx writer log level] \
MF_INFLUX_WRITER_CONFIG_PATH=[Config file path with Message broker subjects list, payload type and content-type] \
MF_INFLUX_WRITER_HTTP_HOST=[Service HTTP host] \
MF_INFLUX_WRITER_HTTP_PORT=[Service HTTP port] \
MF_INFLUX_WRITER_HTTP_SERVER_CERT=[Service HTTP server cert] \
MF_INFLUX_WRITER_HTTP_SERVER_KEY=[Service HTTP server key] \
MF_INFLUXDB_PROTOCOL=[InfluxDB protocol] \
MF_INFLUXDB_HOST=[InfluxDB database host] \
MF_INFLUXDB_PORT=[InfluxDB database port] \
MF_INFLUXDB_ADMIN_USER=[InfluxDB admin user] \
MF_INFLUXDB_ADMIN_PASSWORD=[InfluxDB admin password] \
MF_INFLUXDB_NAME=[InfluxDB database name] \
MF_INFLUXDB_BUCKET=[InfluxDB bucket] \
MF_INFLUXDB_ORG=[InfluxDB org] \
MF_INFLUXDB_TOKEN=[InfluxDB token] \
MF_INFLUXDB_DBURL=[InfluxDB database url] \
MF_INFLUXDB_USER_AGENT=[InfluxDB user agent] \
MF_INFLUXDB_TIMEOUT=[InfluxDB timeout] \
MF_INFLUXDB_INSECURE_SKIP_VERIFY=[InfluxDB insecure skip verify] \
MF_MESSAGE_BROKER_URL=[Message broker instance URL] \
MF_JAEGER_URL=[Jaeger server URL] \
MF_SEND_TELEMETRY=[Send telemetry to mainflux call home server] \
MF_INFLUX_WRITER_INSTANCE_ID=[Influx writer instance ID] \
$GOBIN/mainflux-influxdb
Using docker-compose
This service can be deployed using docker containers.
Docker compose file is available in <project_root>/docker/addons/influxdb-writer/docker-compose.yml
. Besides database
and writer service, it contains InfluxData Web Admin Interface which can be used for database
exploration and data visualization and analytics. In order to run Mainflux InfluxDB writer, execute the following command:
docker-compose -f docker/addons/influxdb-writer/docker-compose.yml up -d
And, to use the default .env file, execute the following command:
docker-compose -f docker/addons/influxdb-writer/docker-compose.yml up --env-file docker/.env -d
Please note that you need to start core services before the additional ones.
Usage
Starting service will start consuming normalized messages in SenML format.
Official docs can be found here.