State metrics
Use states to understand the health of any device monitored by an ActiveGate extension.
Define states
See this example of state definition in JSON:
1{2 "name": "custom.remote.python.my_plugin",3 "version": "1.001",4 "type": "python",5 "entity": "CUSTOM_DEVICE",6 "metricGroup": "my_plugin",7 "processTypeNames": ["PYTHON"],8 "technologies": ["example technology"],9 "source": {10 "package": "my_plugin",11 "className": "MyPlugin",12 "activation": "Remote"13 },14 "metrics": [15 {16 "entity": "CUSTOM_DEVICE",17 "statetimeseries": {18 "key": "my_state",19 "states": ["OK", "Troubles", "Bad"],20 "dimensions": [],21 "displayname": "My state"22 }23 }24 ],25 "ui": {26 "keymetrics": [27 {28 "key": "my_state",29 "displayname": "My state",30 "statemetric": true31 }32 ],33 "charts": [34 {35 "group": "States",36 "title": "My state",37 "series": [38 {39 "key": "my_state",40 "displayname": " ",41 "seriestype": "bar",42 "statecolors": ["#008cdb", "#b4e5f9", " #2ab6f4"],43 "statechart": true44 }45 ]46 }47 ]48 }49}
Note that a single chart can't contain both numeric and state timeseries.
Report states
See how to make your extension send state information:
1from ruxit.api.base_plugin import RemoteBasePlugin23class MyPlugin(RemoteBasePlugin):4 def query(self, **kwargs):5 group = self.topology_builder.create_group("My group1", "My group1")6 device = group.create_element("My device1", "My device1")7 device.state_metric("my_state", "OK")