Add a new RFC for cloud event data mapping#3
Conversation
|
Hi @ctron I have done a bit more digging with the GCP equivalent (by no means exemplar), UDMI envelope as well as other examples are on the CloudEvents adapters page. Google adopt a layered approach where A lot of this information can be included in the It looks like the The Examples below are in json but the CloudEvents headers would most likely be sent to knative as HTTP headers. Proposed Drogue IoT: {
"specversion": "1.0",
"id": "b280e845-b3c5-458f-af84-896f90bd2019",
"source": "//example.com/my-tenant/my-device",
"type": "io.drogue.message_published",
"datacontenttype": "application/json",
"time": "2021-02-11T13:52:25.646Z",
"subject": "pointset",
"dataschema": "https://raw.githubusercontent.com/faucetsdn/udmi/1.3.6/schema/event_pointset.json",
"data": {
"version": 1,
"timestamp": "2021-02-11T13:52:25Z",
"points": {
"recalcitrant_angle": { "present_value": 40 },
"faulty_finding": { "present_value": false },
"superimposition_reading": { "present_value": 72 }
}
}
}GCP IoT Core + eventarc: {
"specversion": "1.0",
"id": "2008878765719495",
"source": "//pubsub.googleapis.com/projects/my-project/topics/my-iot-project",
"type": "google.cloud.pubsub.topic.v1.messagePublished",
"datacontenttype": "application/json",
"time": "2021-02-11T13:52:25.646Z",
"data": {
"message": {
"attributes": {
"deviceId": "my-device",
"deviceNumId": "2852723095039291",
"deviceRegistryId": "my-iot-project",
"deviceRegistryLocation": "europe-west1",
"projectId": "my-project",
"subFolder": "pointset"
},
"data": {
"version": 1,
"timestamp": "2021-02-11T13:52:25Z",
"points": {
"recalcitrant_angle": { "present_value": 40 },
"faulty_finding": { "present_value": false },
"superimposition_reading": { "present_value": 72 }
}
},
"messageId": "2008878765719495",
"message_id": "2008878765719495",
"publishTime": "2021-02-11T13:52:25.646Z",
"publish_time": "2021-02-11T13:52:25.646Z"
},
"subscription": "projects/my-project/subscriptions/eventarc-europe-west1-trigger-pubsub-sub-249"
}
} |
| | `source` | ✓ | The [device id](#device-id) | | ||
| | `specversion` | ✓ | Always contains `1.0` | | ||
| | `type` | ✓ | ?? | | ||
| | `datacontenttype` | ✓ | The mime type of the payload. As provided by the device. Defaults to `application/octet-stream`. | |
There was a problem hiding this comment.
If there is a default, maybe it should not be required? According to cloudevents spec it is optional.
There was a problem hiding this comment.
From a cloud events perspective, it is optional. I wanted to make it mandatory from our perspective. So that consuming application can rely on that attribute.
|
@garyedwards This is great, I really like it! What do you think about adding I already changed |
|
I also think that we should support the portioning extension: https://github.com/cloudevents/spec/blob/v1.0.1/extensions/partitioning.md … and probably fill it with a app/device ID combination. |
|
I think The UDMI envelope.json does a pretty good job at picking out useful additional attributes for IoT. I am not sure if I have not used partitioning, it looks like it would be specific to the internal workings of Drogue. I guess if used it would also make sense to include the aforementioned Regarding naming, you could follow UDMI and just drop the camel case. I think your proposed naming looks cleaner but could be a XKCD 927 situation. I guess other systems use different naming anyway and it would be simple to map between:
Drogue flavour: {
"specversion": "1.0",
"id": "b280e845-b3c5-458f-af84-896f90bd2019",
"source": "//example.com/my-application/my-device",
"type": "io.drogue.message_published",
"datacontenttype": "application/json",
"time": "2021-02-11T13:52:25.646Z",
"subject": "pointset",
"dataschema": "https://raw.githubusercontent.com/faucetsdn/udmi/1.3.5/schema/event_pointset.json",
"instance": "example.com",
"application": "my-application",
"device": "my-device",
"deviceuuid": "40b6a495-b92c-4a71-b5f2-ea8b9ac6fbcf",
"data": {
"version": 1,
"timestamp": "2021-02-11T13:52:25Z",
"points": {
"recalcitrant_angle": { "present_value": 40 },
"faulty_finding": { "present_value": false },
"superimposition_reading": { "present_value": 72 }
}
}
}Drogue UDMI flavour: {
"specversion": "1.0",
"id": "b280e845-b3c5-458f-af84-896f90bd2019",
"source": "//example.com/my-application/my-device",
"type": "io.drogue.message_published",
"datacontenttype": "application/json",
"time": "2021-02-11T13:52:25.646Z",
"subject": "pointset",
"dataschema": "https://raw.githubusercontent.com/faucetsdn/udmi/1.3.5/schema/event_pointset.json",
"projectid": "example.com",
"deviceregistryid": "my-application",
"deviceid": "my-device",
"devicenumid": "40b6a495-b92c-4a71-b5f2-ea8b9ac6fbcf",
"data": {
"version": 1,
"timestamp": "2021-02-11T13:52:25Z",
"points": {
"recalcitrant_angle": { "present_value": 40 },
"faulty_finding": { "present_value": false },
"superimposition_reading": { "present_value": 72 }
}
}
} |
In most messaging systems, messages within a partition provides guaranteed ordering of events, so I think a particular application consuming events will prefer some notion of ordering within an app + device. |
|
@garyedwards This is great input! I really appreciate it. I hope this goes into the right direction for you as well!
Yea, there are lots of other mappings. If considering UDMI, then we would also need to evaluate other standards, and find a common denominator. And I am not sure if that time is well invested. I think we should spend the time on making this look nice in the context of Drogue, and then spend some time on exemplary mappings to other standards. Same for OPC UA, probably Sparkplug, and a "few" others 😀
Currently no. But that might be an interesting idea. Currently the ID of the device is assigned by the user. However, every device has a set of aliases, one being the ID itself. That allows you to create and replace a device later on, keeping the ID stable on the cloud side. If we would make the initial ID optional, and put a UUID in place, then we would have the same feature I guess. Which means that we would need to put in fields in the event for "reported device id" (as reported by the device) and "stored device id" (as stored in the registry). The "stored" ID should go out on the cloud side, while we could add the "reported" to the events as well. That should allow the
I am not sure what the meaning of As Ulf mentioned, the I guess two things we didn't really think about are timestamp (source, received, …) and gateways. Currently there is no "received by gateway X" indication in the event. As a gateway is just another device in the same application, I guess a simple |
|
@ctron defiantly going in the right direction, this is a really great project. Agree there are many standard, better to make it work for Drogue and map later. I think
I think I did notice that a lot of my suggestion where already implemented in |
Good point 👍
That is a great idea! So we would have We already had a discussion in the chat about writing a "book", or at least some pages of documentation. I think this would help, as "documentation" is currently spread all over the place. And is hard to track down.
Awesome! I would love some feedback! |
If it's hard to find a new name, I think |
|
Sorry for the long delay. However, I already started to adopt the ideas from this RFC in a development branch of mine:
I need to finish up a few things, and will come back to this in a few days. |
So yes, that would work. However is would somehow imply that the event traveled through a gateway, which wouldn't be the case. Taking a look at SMTP, we have the However, peeking at the spec if notices the header So my proposal would be to use the |
124d675 to
de3aa40
Compare
|
I found some time (and need 😁) to update the RFC, integrating the comments/feedback. Thanks for that! I think this looks good. I am only not completely sure about the I still kept it in there, as I don't see another way to obtain this information through a different way. |
I think |
|
Ok … so I think 0.4.0 already contains most of the things we discussed here :) Only the @garyedwards Unless the |
This is work in progress. You are welcome to comment, propose changes, or even for the repository and create PRs for the branch this PR is based on.
Also see: drogue-iot/drogue-cloud#29