Group metrics

When you report device group-wide metrics, moving beyond a single device, you can get insights into the general group status, group processing performance, or count group elements (devices). The group metrics behave like standard metrics and similarly, you can use them in:

group metrics charts located at the bottom of a device group page

You'll find device group metric charts at the bottom of the Group overview page.

How to use device group metrics

JSON declaration

To change the primary entity of the metric to group, you have to specify it in the JSON metric declaration in the metrics section.

group metric declaration
Download
{
    "name": "custom.remote.python.my_plugin",
    "version": "1.001",
    "type": "python",
    "entity": "CUSTOM_DEVICE",
    "processTypeNames": ["PYTHON"],
    "technologies": ["example technology"],
    "source": {
        "package": "my_plugin",
        "className": "MyPlugin",
        "activation": "Remote"
    },
    "metrics": [
        {
            "entity": "CUSTOM_DEVICE_GROUP",
            "timeseries": {
                "key": "cluster_nodes_ok",
                "unit": "Count",
                "displayname": "cluster node ok"
            }
        }
    ],
    "ui": {
        "keymetrics": [
            {
                "key": "cluster_nodes_ok",
                "displayname": "Group key metric"
            }
        ],
        "charts": [
            {
                "group": "Cluster charts",
                "title": "My chart",
                "series": [
                    {
                        "key": "cluster_nodes_ok",
                        "displayname": " "
                    }
                ]
            }
        ]
    }
}

The remaining JSON code is the same as for standard metrics. Note that you mustn't use both a device metric and a device-group metric in one chart, as these would be difficult to compare.

Python usage

To use a device group metric with the Python code, you need to create a group with topology builder first. Then you can add either the absolute or relative value to the device group.

Device group metric usage
Download
def query(self, **kwargs):
    group = self.topology_builder.create_group("group_id", "group_name")
    group.absolute(key='cluster_nodes_ok', value=5)

Note: It's a good practice to report device group metrics from the master device, because multiplying metrics with the same time stamp on the same entity may lead to unexcepted behavior.