edgexfoundry / edgexfoundry/edgex-docs
Export data from MQTT device using mqtt-export
- Dominant language
- HTML
- Stars
- 44
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
Description
# 📚 Docs or Wiki Bug Report
### Description [**REQUIRED**]
I've been reading through the docs and trying to piece together how to export data being published to my local broker, edgex-mqtt-broker, to a broker on the internet, specifically to HiveMQ. To achieve this, I'm attempting to mimic my device using the [MQTT simulated device](https://docs.edgexfoundry.org/3.1/examples/Ch-ExamplesAddingMQTTDevice/#using-a-mqtt-device-simulator) and using the [App Service Configurable tutorial](https://docs.edgexfoundry.org/3.1/microservices/application/AppServiceConfigurable/#metric-targettype) to export data, but with no luck so far.
First, the MQTT simulated device doesn't post its test messages to the default "edgex/events". Instead, it publishes to an MQTT topic named "incoming/data/my-custom-device/values", which I believe does not trigger the "edgex/events" topic by default. Following the Application Service Configurable docs, I managed to create a configuration.yaml file that can subscribe to other topics—unfortunately, always with "edgex/" as a prefix. Is there a way to change that? Here is my current configuration:
```yaml
Writable:
LogLevel: "INFO"
StoreAndForward:
Enabled: false
Pipeline:
TargetType: "metric"
# FilterByDeviceName
ExecutionOrder: "ToLineProtocol, MQTTExport"
Functions:
ToLineProtocol:
Parameters:
Tags: ""
MQTTExport:
Parameters:
BrokerAddress: "broker.hivemq.com:1883"
Topic: "edgex-export"
SecretName: "mqtt"
ClientId: "MQTT-Export"
QOS: "0"
AutoReconnect: "true"
MaxReconnectInterval: "" # Empty value means use default setting
KeepAlive: "" # Empty indicates to use default value
ConnectTimeout: "" # Empty indicates to use default value
Retain: "false"
SkipVerify: "false"
AuthMode: "none"
PersistOnError: "false"
WillEnabled: "false"
WillPayload: ""
WillQos: "0"
WillRetained: "false"
WillTopic: ""
PreConnect: "true"
PreConnectRetryCount: "" # Empty value means use default setting
PreConnectRetryInterval: "" # Empty value means use default setting
Service:
Host: "localhost"
Port: 59703
StartupMsg: "app-mqtt-export has Started"
MessageBus:
Optional:
ClientId: "app-mqtt-export"
Trigger:
SubscribeTopics: "incoming/data/#"
```
I've modified the simulated device code to publish data to "edgex/incoming/data/" and confirmed that messages are being published by subscribing to this topic using another script.
If I use 'events/#' as the value for SubscribeTopics, it successfully publishes some incorrect data but with the same frequency as the Virtual Device used to, so I assume it's only a parsing error. On the other hand, when using the default configurations, the [Virtual Device](https://docs.edgexfoundry.org/3.0/microservices/device/virtual/Ch-VirtualDevice/) is exported to HiveMQ without issues. The only difference I see with its implementation is the 'FilterByDeviceName' tag and the topic where events are posted—the default 'edgex/events'.
Am I on the right path to export data from an MQTT device, and what am I missing in the configuration?
## 🔬 Minimal Reproduction
### What's the affected URL? [**REQUIRED**]
Following the steps above should lead to the same outcome.
### Expected vs Actual Behavior
I expected that the MQTT device would be able to post something to 'edgex/events' by default, but in practice, I have to change both the JavaScript code used to simulate the device and the app-service-configurable YAML file to get it exported.
## 🔥 Exception or Error
n/a
## 🌍 Your Environment
I'm running Edgex 3.1 and trying to follow the latest tutorials.
Contributor guide
Assessment
This issue has not been assessed yet.