thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
221 stars 54 forks source link

Missing alarms topic in the c8y-bridge.conf #1583

Closed zhong-ys closed 1 year ago

zhong-ys commented 1 year ago

Describe the bug The /etc/tedge/mosquitto-conf/c8y-bridge.conf dosen't have the topic for alarms. To show the published alarms in the c8y UI the topic for alarms has to be added manually and mosquitto.service needs to be restart.

Expected behavior The topic for alarms should be included in the c8y-bridge.conf by default.

Environment (please complete the following information):

rina23q commented 1 year ago

I would follow up this issue a little. In /crates/core/tedge/src/cli/connect/bridge_config_c8y.rs, the bridged topics are defined.

let mut topics: Vec<String> = vec![
// skip lines
    // c8y JSON
    r#"inventory/managedObjects/update/# out 2 c8y/ """#.into(),
    r#"measurement/measurements/create out 2 c8y/ """#.into(),
    r#"event/events/create out 2 c8y/ """#.into(),
    r#"error in 2 c8y/ """#.into(),
];

As far as I remember, our c8y mapper converts the incoming alarm message to SmartREST, therefore we didn't include alarm/alarms/create topic inside the bridge file. However, why not? There can be a usecase like @zhong-ys, wanted to publish an alarm message directly on alarm/alarms/create with the c8y's JSON over MQTT feature.

In short, the proposal is to add this line.

    r#"alarm/alarms/create out 2 c8y/ """#.into(),
rina23q commented 1 year ago

I merged the fix by #1590. Build is https://github.com/thin-edge/thin-edge.io/actions/runs/3472983811.

With this fix, user can publish JSON to create an alarm. For example, publish this MQTT message.

Topic: c8y/alarm/alarms/create Payload:

{
    "type": "TestAlarm",
    "text": "I am an alarm",
    "severity": "MINOR",
    "status": "ACTIVE",
    "time": "2014-03-03T12:03:27.845Z"
}

Then, you will see the alarm is created on your thin-edge device in Cumulocity.

gligorisaev commented 1 year ago

@rina23q the mentioned Build was failed, cannot use for testing

reubenmiller commented 1 year ago

@gligorisaev We just fixed the build issues (due to a libc dependency problem). Since the change has already been merged, you can take it from the latest build run.

https://github.com/thin-edge/thin-edge.io/actions/runs/3563851913

rina23q commented 1 year ago

Assign back to @gligorisaev as the build issue got solved now.

gligorisaev commented 1 year ago

Tested/confirmed successfull