Save data to InfluxDB

    Create a rule:

    Go to EMQX Dashboard (opens new window), select the “rule” tab on the menu to the left.

    Select “message.publish”, then type in the following SQL:

    image

    Bind an action:

    Click on the “+ Add” button under “Action Handler”, and then select “Data to InfluxDB” in the pop-up dialog window.

    Fill in the parameters required by the action:

    1). Measurement: Measurement of the data point.

    2). Field Keys: Which fields can be used as fields of data point.

    3). Tags Keys. Which fields can be used as tags of data point.

    4). Timestamp Key. Which fields can be used as timestamp of data point.

    5). Set Timestamp. Whether to generate a timestamp if ‘Timestamp Key’ is not configured.

    image

    6). Bind a resource to the action. Since the dropdown list “Resource” is empty for now, we create a new resource by clicking on the “New Resource” to the top right, and then select “InfluxDB”:

    Keep all the configs as default, and click on the “Testing Connection” button to make sure the connection can be created successfully, and then click on the “Create” button.

    image

    Back to the “Actions” dialog, and then click on the “Confirm” button.

    Back to the creating rule page, then click on “Create” button. The rule we created will be show in the rule list:

    image

    We have finished, testing the rule by sending an MQTT message to emqx:

    Then inspect the InfluxDB table, verify a new record has been inserted: