Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support publishing service telemetry data #1971

Closed
reubenmiller opened this issue May 15, 2023 · 3 comments
Closed

Support publishing service telemetry data #1971

reubenmiller opened this issue May 15, 2023 · 3 comments
Assignees
Labels
improvement User value theme:monitoring Theme: Service monitoring and watchdogs
Milestone

Comments

@reubenmiller
Copy link
Contributor

reubenmiller commented May 15, 2023

Is your feature improvement request related to a problem? Please describe.

If a service health endpoint has been registered to thin-edge.io via the tedge/health/{service_name} endpoint, sending measurements to tedge/measurements/{service_name} should not result in the creation of a child device in Cumulocity.

Describe the solution you'd like

A dedicated MQTT topics which allows services to publish Inventory, Measurements, Events and Alarms. This would allow services to publish additional information about the status of the service, e.g. CPU, RAM usage, additional running meta info (e.g. process ids, run command).

The new topic names could be called.

tedge/health/{service}/measurements
tedge/health/{service}/events
tedge/health/{service}/alarms
tedge/health/{service}/inventory

Describe alternatives you've considered

Alternatively, when the tedge-mapper-c8y received a message on the tedge/measurement/{service_name} topic, it could check if the name has been registered via the tedge/health/{service_name} endpoint, and skip register a new child logic (e.g. skip sending the topic=c8y/s/us payload=101,{service_name},{service_name},thin-edge.io-child

Additional context

Cumulocity IoT has two different smart rest messages which involve the registration/creation of a linked entity.

Type SmartREST Template ID
Create a child device 101
Create a service 102

Both SmartREST message templates will create a managed object with the given External Identity, however 101 will link the created managed object as a childDevice, where as the 102 message will link the device as a childAddition. The different types of managed object links control how the managed object is treated in the UI (and other api for that matter).

@albinsuresh
Copy link
Contributor

The registration of services has already been done in #2266 and the entity store now has the external ID of the services as well. So, all that is left is to send the telemetry data to that external ID, just like it's done for devices, using their external ID. For example, a measurement for a service with the external ID myDatabaseService would be as follows:

{
    "externalSource":{
        "externalId":"myDatabaseService",
        "type":"c8y_Serial"
    },
    "type": "c8y_TemperatureMeasurement",
    "time": "2023-09-29T17:57:00+05:30",
    "c8y_TemperatureMeasurement": {
        "T": {
            "value": 20,
            "unit": "C"
        }
    }
}

The mechanism to generate payloads like this from a given external_id already exists in the mapper(used already for child devices). The same can be used for services as well.

The rules are the same while using SmartREST as well. Just use the external ID of the service in the topic like c8y/s/us/myDatabaseService for a service on the main device. And similarly for a service on a child device, publish to c8y/s/us/childExternalId/myDatabaseService.

To generate such hierarchical topics for a service the smartrest_publish_topic_for_entity API in the c8y_mapper_ext::converter can be used.

@reubenmiller
Copy link
Contributor Author

Note: The suggested mqtt api in this ticket is no longer applicable and the new MQTT interface is used instead.

See the system tests included in the following PR:

@gligorisaev gligorisaev self-assigned this Oct 26, 2023
@gligorisaev
Copy link
Contributor

QA has thoroughly checked the feature and here are the results:

  • Test for ticket exists in the test suite.
  • tests/RobotFramework/tests/cumulocity/telemetry/child_device_telemetry.robot
  • tests/RobotFramework/tests/cumulocity/telemetry/thin-edge_device_telemetry.robot
  • QA has tested the bug and could not reproduce it anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement User value theme:monitoring Theme: Service monitoring and watchdogs
Projects
None yet
Development

No branches or pull requests

4 participants