aria.ops.definition.attribute

  1#  Copyright 2022 VMware, Inc.
  2#  SPDX-License-Identifier: Apache-2.0
  3from abc import ABC
  4from typing import Optional
  5
  6from aria.ops.definition.assertions import validate_key
  7from aria.ops.definition.units import Unit
  8
  9
 10class Attribute(ABC):
 11    def __init__(
 12        self,
 13        key: str,
 14        label: Optional[str] = None,
 15        unit: Optional[Unit] = None,
 16        is_rate: bool = False,
 17        is_discrete: bool = False,
 18        is_kpi: bool = False,
 19        is_impact: bool = False,
 20        is_key_attribute: bool = False,
 21        dashboard_order: int = 0,
 22    ):
 23        """
 24        :param key: Used to identify the parameter.
 25        :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
 26        :param unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a
 27        consistent manner, and perform conversions when appropriate.
 28        :param is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this
 29        will be set automatically. Otherwise, defaults to False.
 30        :param is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous
 31        (floating point)
 32        :param is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's
 33        'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
 34        :param is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a
 35        proxy to a root cause, but not the root cause itself.
 36        :param is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
 37        :param dashboard_order: Determines the order parameters will be displayed in the UI.
 38        """
 39        self.key = validate_key(key, "Attribute")
 40        self.label = label
 41        if label is None:
 42            self.label = key
 43        self.unit = unit.value.key if unit else None
 44        self.is_rate = unit.value.is_rate if unit else is_rate
 45        self.is_discrete = is_discrete
 46        self.is_kpi = is_kpi
 47        self.is_impact = is_impact
 48        self.is_key_attribute = is_key_attribute
 49        self.dashboard_order = dashboard_order
 50
 51    def to_json(self) -> dict:
 52        return {
 53            "key": self.key,
 54            "label": self.label,
 55            "unit": self.unit,
 56            "is_rate": self.is_rate,
 57            "is_discrete": self.is_discrete,
 58            "is_kpi": self.is_kpi,
 59            "is_impact": self.is_impact,
 60            "is_key_attribute": self.is_key_attribute,
 61            "dashboard_order": self.dashboard_order,
 62        }
 63
 64
 65class MetricAttribute(Attribute):
 66    def __init__(
 67        self,
 68        key: str,
 69        label: Optional[str] = None,
 70        unit: Optional[Unit] = None,
 71        is_rate: bool = False,
 72        is_discrete: bool = False,
 73        is_kpi: bool = False,
 74        is_impact: bool = False,
 75        is_key_attribute: bool = False,
 76        dashboard_order: int = 0,
 77    ):
 78        """
 79        :param key: Used to identify the parameter.
 80        :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
 81        :param unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a
 82        consistent manner, and perform conversions when appropriate.
 83        :param is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this
 84        will be set automatically. Otherwise, defaults to False.
 85        :param is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous
 86        (floating point)
 87        :param is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's
 88        'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
 89        :param is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a
 90        proxy to a root cause, but not the root cause itself.
 91        :param is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
 92        :param dashboard_order: Determines the order parameters will be displayed in the UI.
 93        """
 94        super().__init__(
 95            key,
 96            label,
 97            unit,
 98            is_rate,
 99            is_discrete,
100            is_kpi,
101            is_impact,
102            is_key_attribute,
103            dashboard_order,
104        )
105
106    def to_json(self) -> dict:
107        return super().to_json() | {
108            "data_type": "integer" if self.is_discrete else "float",
109            "is_property": False,
110        }
111
112
113class PropertyAttribute(Attribute):
114    def __init__(
115        self,
116        key: str,
117        label: Optional[str] = None,
118        is_string: bool = True,
119        unit: Optional[Unit] = None,
120        is_rate: bool = False,
121        is_discrete: bool = False,
122        is_kpi: bool = False,
123        is_impact: bool = False,
124        is_key_attribute: bool = False,
125        dashboard_order: int = 0,
126    ):
127        """
128        :param key: Used to identify the parameter.
129        :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
130        :param is_string: Determines if the property is numeric or string (text).
131        :param unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a
132        consistent manner, and perform conversions when appropriate.
133        :param is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this
134        will be set automatically. Otherwise, defaults to False.
135        :param is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous
136        (floating point). Defaults to False, unless 'is_string' is set, in which case it will always be set to True.
137        :param is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's
138        'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
139        :param is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a
140        proxy to a root cause, but not the root cause itself.
141        :param is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
142        :param dashboard_order: Determines the order parameters will be displayed in the UI.
143        """
144        super().__init__(
145            key,
146            label,
147            unit,
148            is_rate,
149            is_discrete,
150            is_kpi,
151            is_impact,
152            is_key_attribute,
153            dashboard_order,
154        )
155        self.is_string = is_string
156
157    def to_json(self) -> dict:
158        return super().to_json() | {
159            "data_type": "string"
160            if self.is_string
161            else "integer"
162            if self.is_discrete
163            else "float",
164            "is_discrete": True if self.is_string else self.is_discrete,
165            "is_property": True,
166        }
class Attribute(abc.ABC):
11class Attribute(ABC):
12    def __init__(
13        self,
14        key: str,
15        label: Optional[str] = None,
16        unit: Optional[Unit] = None,
17        is_rate: bool = False,
18        is_discrete: bool = False,
19        is_kpi: bool = False,
20        is_impact: bool = False,
21        is_key_attribute: bool = False,
22        dashboard_order: int = 0,
23    ):
24        """
25        :param key: Used to identify the parameter.
26        :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
27        :param unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a
28        consistent manner, and perform conversions when appropriate.
29        :param is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this
30        will be set automatically. Otherwise, defaults to False.
31        :param is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous
32        (floating point)
33        :param is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's
34        'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
35        :param is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a
36        proxy to a root cause, but not the root cause itself.
37        :param is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
38        :param dashboard_order: Determines the order parameters will be displayed in the UI.
39        """
40        self.key = validate_key(key, "Attribute")
41        self.label = label
42        if label is None:
43            self.label = key
44        self.unit = unit.value.key if unit else None
45        self.is_rate = unit.value.is_rate if unit else is_rate
46        self.is_discrete = is_discrete
47        self.is_kpi = is_kpi
48        self.is_impact = is_impact
49        self.is_key_attribute = is_key_attribute
50        self.dashboard_order = dashboard_order
51
52    def to_json(self) -> dict:
53        return {
54            "key": self.key,
55            "label": self.label,
56            "unit": self.unit,
57            "is_rate": self.is_rate,
58            "is_discrete": self.is_discrete,
59            "is_kpi": self.is_kpi,
60            "is_impact": self.is_impact,
61            "is_key_attribute": self.is_key_attribute,
62            "dashboard_order": self.dashboard_order,
63        }

Helper class that provides a standard way to create an ABC using inheritance.

Attribute( key: str, label: Optional[str] = None, unit: Optional[aria.ops.definition.units.Unit] = None, is_rate: bool = False, is_discrete: bool = False, is_kpi: bool = False, is_impact: bool = False, is_key_attribute: bool = False, dashboard_order: int = 0)
12    def __init__(
13        self,
14        key: str,
15        label: Optional[str] = None,
16        unit: Optional[Unit] = None,
17        is_rate: bool = False,
18        is_discrete: bool = False,
19        is_kpi: bool = False,
20        is_impact: bool = False,
21        is_key_attribute: bool = False,
22        dashboard_order: int = 0,
23    ):
24        """
25        :param key: Used to identify the parameter.
26        :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
27        :param unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a
28        consistent manner, and perform conversions when appropriate.
29        :param is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this
30        will be set automatically. Otherwise, defaults to False.
31        :param is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous
32        (floating point)
33        :param is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's
34        'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
35        :param is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a
36        proxy to a root cause, but not the root cause itself.
37        :param is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
38        :param dashboard_order: Determines the order parameters will be displayed in the UI.
39        """
40        self.key = validate_key(key, "Attribute")
41        self.label = label
42        if label is None:
43            self.label = key
44        self.unit = unit.value.key if unit else None
45        self.is_rate = unit.value.is_rate if unit else is_rate
46        self.is_discrete = is_discrete
47        self.is_kpi = is_kpi
48        self.is_impact = is_impact
49        self.is_key_attribute = is_key_attribute
50        self.dashboard_order = dashboard_order
Parameters
  • key: Used to identify the parameter.
  • label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
  • unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a consistent manner, and perform conversions when appropriate.
  • is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this will be set automatically. Otherwise, defaults to False.
  • is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous (floating point)
  • is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's 'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
  • is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a proxy to a root cause, but not the root cause itself.
  • is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
  • dashboard_order: Determines the order parameters will be displayed in the UI.
def to_json(self) -> dict:
52    def to_json(self) -> dict:
53        return {
54            "key": self.key,
55            "label": self.label,
56            "unit": self.unit,
57            "is_rate": self.is_rate,
58            "is_discrete": self.is_discrete,
59            "is_kpi": self.is_kpi,
60            "is_impact": self.is_impact,
61            "is_key_attribute": self.is_key_attribute,
62            "dashboard_order": self.dashboard_order,
63        }
class MetricAttribute(Attribute):
 66class MetricAttribute(Attribute):
 67    def __init__(
 68        self,
 69        key: str,
 70        label: Optional[str] = None,
 71        unit: Optional[Unit] = None,
 72        is_rate: bool = False,
 73        is_discrete: bool = False,
 74        is_kpi: bool = False,
 75        is_impact: bool = False,
 76        is_key_attribute: bool = False,
 77        dashboard_order: int = 0,
 78    ):
 79        """
 80        :param key: Used to identify the parameter.
 81        :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
 82        :param unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a
 83        consistent manner, and perform conversions when appropriate.
 84        :param is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this
 85        will be set automatically. Otherwise, defaults to False.
 86        :param is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous
 87        (floating point)
 88        :param is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's
 89        'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
 90        :param is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a
 91        proxy to a root cause, but not the root cause itself.
 92        :param is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
 93        :param dashboard_order: Determines the order parameters will be displayed in the UI.
 94        """
 95        super().__init__(
 96            key,
 97            label,
 98            unit,
 99            is_rate,
100            is_discrete,
101            is_kpi,
102            is_impact,
103            is_key_attribute,
104            dashboard_order,
105        )
106
107    def to_json(self) -> dict:
108        return super().to_json() | {
109            "data_type": "integer" if self.is_discrete else "float",
110            "is_property": False,
111        }

Helper class that provides a standard way to create an ABC using inheritance.

MetricAttribute( key: str, label: Optional[str] = None, unit: Optional[aria.ops.definition.units.Unit] = None, is_rate: bool = False, is_discrete: bool = False, is_kpi: bool = False, is_impact: bool = False, is_key_attribute: bool = False, dashboard_order: int = 0)
 67    def __init__(
 68        self,
 69        key: str,
 70        label: Optional[str] = None,
 71        unit: Optional[Unit] = None,
 72        is_rate: bool = False,
 73        is_discrete: bool = False,
 74        is_kpi: bool = False,
 75        is_impact: bool = False,
 76        is_key_attribute: bool = False,
 77        dashboard_order: int = 0,
 78    ):
 79        """
 80        :param key: Used to identify the parameter.
 81        :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
 82        :param unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a
 83        consistent manner, and perform conversions when appropriate.
 84        :param is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this
 85        will be set automatically. Otherwise, defaults to False.
 86        :param is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous
 87        (floating point)
 88        :param is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's
 89        'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
 90        :param is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a
 91        proxy to a root cause, but not the root cause itself.
 92        :param is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
 93        :param dashboard_order: Determines the order parameters will be displayed in the UI.
 94        """
 95        super().__init__(
 96            key,
 97            label,
 98            unit,
 99            is_rate,
100            is_discrete,
101            is_kpi,
102            is_impact,
103            is_key_attribute,
104            dashboard_order,
105        )
Parameters
  • key: Used to identify the parameter.
  • label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
  • unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a consistent manner, and perform conversions when appropriate.
  • is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this will be set automatically. Otherwise, defaults to False.
  • is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous (floating point)
  • is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's 'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
  • is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a proxy to a root cause, but not the root cause itself.
  • is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
  • dashboard_order: Determines the order parameters will be displayed in the UI.
def to_json(self) -> dict:
107    def to_json(self) -> dict:
108        return super().to_json() | {
109            "data_type": "integer" if self.is_discrete else "float",
110            "is_property": False,
111        }
class PropertyAttribute(Attribute):
114class PropertyAttribute(Attribute):
115    def __init__(
116        self,
117        key: str,
118        label: Optional[str] = None,
119        is_string: bool = True,
120        unit: Optional[Unit] = None,
121        is_rate: bool = False,
122        is_discrete: bool = False,
123        is_kpi: bool = False,
124        is_impact: bool = False,
125        is_key_attribute: bool = False,
126        dashboard_order: int = 0,
127    ):
128        """
129        :param key: Used to identify the parameter.
130        :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
131        :param is_string: Determines if the property is numeric or string (text).
132        :param unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a
133        consistent manner, and perform conversions when appropriate.
134        :param is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this
135        will be set automatically. Otherwise, defaults to False.
136        :param is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous
137        (floating point). Defaults to False, unless 'is_string' is set, in which case it will always be set to True.
138        :param is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's
139        'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
140        :param is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a
141        proxy to a root cause, but not the root cause itself.
142        :param is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
143        :param dashboard_order: Determines the order parameters will be displayed in the UI.
144        """
145        super().__init__(
146            key,
147            label,
148            unit,
149            is_rate,
150            is_discrete,
151            is_kpi,
152            is_impact,
153            is_key_attribute,
154            dashboard_order,
155        )
156        self.is_string = is_string
157
158    def to_json(self) -> dict:
159        return super().to_json() | {
160            "data_type": "string"
161            if self.is_string
162            else "integer"
163            if self.is_discrete
164            else "float",
165            "is_discrete": True if self.is_string else self.is_discrete,
166            "is_property": True,
167        }

Helper class that provides a standard way to create an ABC using inheritance.

PropertyAttribute( key: str, label: Optional[str] = None, is_string: bool = True, unit: Optional[aria.ops.definition.units.Unit] = None, is_rate: bool = False, is_discrete: bool = False, is_kpi: bool = False, is_impact: bool = False, is_key_attribute: bool = False, dashboard_order: int = 0)
115    def __init__(
116        self,
117        key: str,
118        label: Optional[str] = None,
119        is_string: bool = True,
120        unit: Optional[Unit] = None,
121        is_rate: bool = False,
122        is_discrete: bool = False,
123        is_kpi: bool = False,
124        is_impact: bool = False,
125        is_key_attribute: bool = False,
126        dashboard_order: int = 0,
127    ):
128        """
129        :param key: Used to identify the parameter.
130        :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
131        :param is_string: Determines if the property is numeric or string (text).
132        :param unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a
133        consistent manner, and perform conversions when appropriate.
134        :param is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this
135        will be set automatically. Otherwise, defaults to False.
136        :param is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous
137        (floating point). Defaults to False, unless 'is_string' is set, in which case it will always be set to True.
138        :param is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's
139        'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
140        :param is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a
141        proxy to a root cause, but not the root cause itself.
142        :param is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
143        :param dashboard_order: Determines the order parameters will be displayed in the UI.
144        """
145        super().__init__(
146            key,
147            label,
148            unit,
149            is_rate,
150            is_discrete,
151            is_kpi,
152            is_impact,
153            is_key_attribute,
154            dashboard_order,
155        )
156        self.is_string = is_string
Parameters
  • key: Used to identify the parameter.
  • label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
  • is_string: Determines if the property is numeric or string (text).
  • unit: Specifies what unit this metric is returned in. This allows the UI to display the units in a consistent manner, and perform conversions when appropriate.
  • is_rate: Declares this attribute as a rate (e.g., kilobytes per second). If a unit is specified, this will be set automatically. Otherwise, defaults to False.
  • is_discrete: Declares that this attribute's range of values is discrete (integer) rather than continuous (floating point). Defaults to False, unless 'is_string' is set, in which case it will always be set to True.
  • is_kpi: If set, threshold breaches for this metric will be used in the calculation of the object's 'Self - Health Score' metric, which can affect the 'Anomalies' Badge.
  • is_impact: If set, this attribute will never be the 'root cause' of an issue. For example, it could be a proxy to a root cause, but not the root cause itself.
  • is_key_attribute: True if the attribute should be shown in some object summary widgets in the UI.
  • dashboard_order: Determines the order parameters will be displayed in the UI.
def to_json(self) -> dict:
158    def to_json(self) -> dict:
159        return super().to_json() | {
160            "data_type": "string"
161            if self.is_string
162            else "integer"
163            if self.is_discrete
164            else "float",
165            "is_discrete": True if self.is_string else self.is_discrete,
166            "is_property": True,
167        }