Metrics

The ThreatConnect ™ TcEx App Framework provides an simple interface for Creating and adding metrics in Apps. The TcExMetricsV2 module will automatically create the Metric if it does not already exists in ThreatConnect. The Metric Name is a unique field in the ThreatConnect platform. For more information on ThreatConnect Metrics see the docs at https://docs.threatconnect.com/en/latest/rest_api/custom_metrics/custom_metrics.html#custom-metrics.

Metrics Instance

The tcex.metrics() method has required fields of name, description, data_type, interval, and keyed as parameters.

1
metrics = tcex.metric('My Metrics', 'Metric Testing', 'Sum', 'Daily', False)

Add Metrics

The add() method has a required field of value. It also accepts an option fields for date, return_value, and key. If no date is provided the current datetime will be used. The return_value field will tell the API to return the value for the current interval. The key arg is only used for Keyed Metrics or the add_keyed() method can be used.

1
2
metrics = tcex.metric('My Metric', 'TcEx Metric Testing', 'Sum', 'Daily', False)
metrics.add(123)

Add Keyed Metrics

The add_keyed() method has a required field of value and key. It also accepts an option fields for date, and return_value. If no date is provided the current datetime will be used. The return_value field will tell the API to return the value for the current interval.

1
2
3
metrics = tcex.metric('My Keyed Metric', 'TcEx Keyed Metric Testing', 'Sum', 'Daily', True)
address_results = metrics.add(100, key='Address', date='2019-03-28T12:25:40Z', return_value=True)
host_results = metrics.add(99, 'Host', '2019-03-28T12:25:40Z', True)