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:
{"name": "custom.remote.python.my_plugin","version": "1.001","type": "python","entity": "CUSTOM_DEVICE","metricGroup": "my_plugin","processTypeNames": ["PYTHON"],"technologies": ["example technology"],"source": {"package": "my_plugin","className": "MyPlugin","activation": "Remote"},"metrics": [{"entity": "CUSTOM_DEVICE","statetimeseries": {"key": "my_state","states": ["OK", "Troubles", "Bad"],"dimensions": [],"displayname": "My state"}}],"ui": {"keymetrics": [{"key": "my_state","displayname": "My state","statemetric": true}],"charts": [{"group": "States","title": "My state","series": [{"key": "my_state","displayname": " ","seriestype": "bar","statecolors": ["#008cdb", "#b4e5f9", " #2ab6f4"],"statechart": true}]}]}}
Note that a single chart can't contain both numeric and state timeseries.
Report states
See how to make your extension send state information:
from ruxit.api.base_plugin import RemoteBasePluginclass MyPlugin(RemoteBasePlugin):def query(self, **kwargs):group = self.topology_builder.create_group("My group1", "My group1")device = group.create_element("My device1", "My device1")device.state_metric("my_state", "OK")