tcex.tcex_metrics_v2 module

TcEx Framework Module for working with Metrics in the ThreatConnect Platform.

class tcex.tcex_metrics_v2.TcExMetricsV2(tcex, name, description, data_type, interval, keyed=False)[source]

Bases: object

TcEx Metrics Class

add(value, date=None, return_value=False, key=None)[source]

Add metrics data to collection.

Parameters:
  • value (str) – The value of the metric.
  • date (str, optional) – The optional date of the metric.
  • (bool, default (return_value) – False): Tell the API to return the updates metric value.
  • key (str, optional) – The key value for keyed metrics.
Returns:

If return_value is True a dict with the current value for the time period

is returned.

Return type:

dict

add_keyed(value, key, date=None, return_value=False)[source]

Add keyed metrics data to collection.

Parameters:
  • value (str) – The value of the metric.
  • key (str) – The key value for keyed metrics.
  • date (str, optional) – The optional date of the metric.
  • (bool, default (return_value) – False): Tell the API to return the updates metric value.
Returns:

If return_value is True a dict with the current value for the time period

is returned.

Return type:

dict

metric_create()[source]

Create the defined metric.

{
    "status": "Success",
    "data": {
        "customMetricConfig": {
            "id": 12,
            "name": "Added Reports",
            "dataType": "Sum",
            "interval": "Daily",
            "keyedValues": false,
            "description": "Added reports daily count."
        }
    }
}
metric_find()[source]

Find the Metric by name.

{
    "status": "Success",
    "data": {
        "resultCount": 1,
        "customMetricConfig": [
            {
                "id": 9,
                "name": "My Metric",
                "dataType": "Sum",
                "interval": "Daily",
                "keyedValues": false,
                "description": "TcEx Metric Testing"
            }
        ]
    }
}