Skip to content

Export data from MQTT device using mqtt-export #1359

@Erickrk

Description

@Erickrk

📚 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 and using the App Service Configurable tutorial 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:

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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions