I have some messages that look like this:
{
"measurement":"observation",
"timestamp":"2022-03-08T18:04:48.389Z",
"fields": {
"rms0": 0.22936178743839264,
"max0": 0.22936178743839264,
"rms1": 0.2076568752527237,
"max1": 0.2076568752527237,
"rms2": 0.20974993705749512,
"max2": 0.20974993705749512
},
"tags": {
"bucket":"powermon",
"address":"CA64"
}
}
Using basic ingestion, I'm sending them to this topic:
$aws/rules/PowerMonRule
I added three actions to that rule. One was to write the message to CloudWatch Logs for both the normal and the error condition. The second rule attempts to write that data to SiteWise. This is where I'm having a problem. No data ever actually shows up, and I'm not quite sure how to figure out why. What I'm logging now is what comes out of the rule; is there some way to log what happens when it goes into SiteWise so I can figure out what SiteWise is doing with the data?
My timestamp is in an ISO style format so for every property that I write I repeat the conversion. I tested this by writing an IoT Rule that writes to Timestream and that worked correctly, so I think it should work here. For the same reason I think select * then referring to the values as ${fields.rms0}
should work OK.
My model has these measurements:
{
"id": "5fd1be48-f8ab-44a1-9d93-2c8102f80e02",
"name": "Irms0",
"dataType": "DOUBLE",
"unit": "Amp",
"type": {
"measurement": {}
}
},
{
"id": "085dfa46-3b8a-47a2-b325-1d211b33a6f4",
"name": "Irms1",
"dataType": "DOUBLE",
"unit": "Amp",
"type": {
"measurement": {}
}
},
{
"id": "1ec8a6c6-a9cc-4bde-9ae5-4394b09914c8",
"name": "Irms2",
"dataType": "DOUBLE",
"unit": "Amp",
"type": {
"measurement": {}
}
}
so what I did was set up an alarm rule with this action (see below). What it does is to take the message (the rule is just SELECT *
) and pull out the three fields, which are stored in attributes with IDs matching the above. For now, the rule is set up to write to a specific, hard-coded asset ID, and the property IDs pulled from the model.
{
"iotSiteWise": {
"putAssetPropertyValueEntries": [
{
"assetId": "e6739e7d-248e-47cd-ba53-bf369126d482",
"propertyId": "5fd1be48-f8ab-44a1-9d93-2c8102f80e02",
"propertyValues": [
{
"value": {
"doubleValue": "${fields.rms0}"
},
"timestamp": {
"timeInSeconds": "${time_to_epoch(ts,\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\")}"
}
}
]
},
{
"assetId": "e6739e7d-248e-47cd-ba53-bf369126d482",
"propertyId": "085dfa46-3b8a-47a2-b325-1d211b33a6f4",
"propertyValues": [
{
"value": {
"doubleValue": "${fields.rms1}"
},
"timestamp": {
"timeInSeconds": "${time_to_epoch(ts,\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\")}"
}
}
]
},
{
"assetId": "e6739e7d-248e-47cd-ba53-bf369126d482",
"propertyId": "1ec8a6c6-a9cc-4bde-9ae5-4394b09914c8",
"propertyValues": [
{
"value": {
"doubleValue": "${fields.rms2}"
},
"timestamp": {
"timeInSeconds": "${time_to_epoch(ts,\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\")}"
}
}
]
}
]
}
}
ahhhhhh so I was looking for the logs in the wrong log group!!!
It doesn't like this:
I feel like I"m very close to this working.