State metrics

Use states to understand the health of any device monitored by an ActiveGate plugin.

Define states

See this example of state definition in JSON:

JSON essential
Download
{
    "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 plugin send state information:

How to report device groups
Download
from ruxit.api.base_plugin import RemoteBasePlugin

class 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")