- Newest
- Most votes
- Most comments
Hi Greg,
I have created a rule with the connection to CloudWatch>Log.
SELECT get(payload.streams, 1).id as sensorid, ROUND(get(payload.streams, 1).value) as sensordata FROM 'device/topic'
Here I get this return value. It should be correct and write to the timestream database. I don't understand why it says the values are empty. Also, how could I get the entire data. I always find only the "S55". but I think that is a challenge after I have already imported the data into the TimestreamDB ;)
@message
{"sensorid":"S55","sensordata":37}
@timestamp
1687337346072
sensordata
37
sensorid
S55
I'm pretty much at the end of my thinking. I don't know what the error should be when the values are displayed to me at Cloudwatch>Log.
Republish I haven't figured out yet how it can help me here.
Do you have any other idea maybe?
Best regards
Normen
Hi NLVP. There appears to be a formatting error in your MQTT message. I assume the message is meant to start as:
{
"datetime": "2023-06-20T08:49:00Z",
"payload": {
"streams": [
{
}, { "id": "RS62",
"value": 885.4801218896597
},
Assuming that, you should have more joy with this:
SELECT get(payload.streams, 1).id as sensorid, ROUND(get(payload.streams, 1).value) as sensordata
In general, when trying to create more complex rules, I recommend you use the Republish action to develop and debug the SQL statement.
Hi Greg,
first of all thank you very much for the answer.
I have tried with the query and unfortunately have not come to any result yet. It still says that the fields are empty.
I will look at the rePublish, thanks for pointing that out. I have always lacked a direct return of hints as to what the problem may be. A good debugging environment is very valuable for timely error handling :)
Best regards
Normen
Relevant content
- Accepted Answerasked 2 years ago
- asked 2 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
Something seems wrong. S55 is element 3, not 1, according to the message you gave in the question. But anyway, if you want to iterate through an array, and especially if the array has variable length, you should use a Lambda rule action.
I think initially it was saying it was empty because your rule was sending a payload that was just
{}
. Not sure about now. For the Republish action, just add a second action to your rule, and re-publish to any topic you like. Then you can use MQTT Test Client to subscribe to that topic. This will be faster feedback than using CloudWatch (although the new Cloud Logs Live Tail feature might close the gap).