How to send clientid or topic in rules

We’ve set up EMQX 5.0 in a kubernetes cluster running in GCP. We managed to create a data bridge with a rule that takes everything in a topic like /devices/# and we to create a rule to republish that into our webserver. The ${payload} works fine but we cannot work with the ${clientid} or ${topic}. What can be happening?

How is your SQL written? If you don’t use the form SELECT * FROM ..., then you need to select it manually, such as SELECT clientid, username FROM xxx

The strange thing is that I’ve tried with both * and the specific select like

SELECT clientid FROM “t/#”

When doing both, I managed to get the ${payload} nothing else works.

Hi, it is best to provide detailed configuration. Some variables only exist in specific events. For example, the payload variable only exists in the message.publish event.

Did you fix this?

I have the same issue:

Rule =

The payload is provided by the clientID is not.


If any one else runs into this. The issue is that Payload is a JSON object and the clientID is a string. You need to wrap the client string into a JSON object example:

    "deviceId" : "${clientid}",
    "payload" :  ${payload}