Time Series, Event, and Category Models

firetower.category.TSTuple

alias of TimeSeriesTuple

class firetower.category.Category(redis_conn, signature=None, cat_id=None, event=None)[source]

A class to encapsulate operations involving categories and their metadata

Currently exposes 3 read/write properties: signature, human_name, and threshold.

classmethod classify(queue, classifiers, error, threshold)[source]

Determine which category, if any, a signature belongs to.

If it doesn’t find a match, then it’ll save the error into a new category, which subsequent errors are checked against.

Args:
queue: redis connection instance. classifiers: list of Classifier instances. error: dict of json payload with a ‘sig’ key. threshold: float, classification threshold to match.
static construct_cat_id(signature)[source]

Create Category ID hash from a category signature.

Args:
signature: str, signature of category.
Returns:
str, sha1 hash.
classmethod create(redis_conn, signature, event=None)[source]

Adds category metadata.

Args:
redis_conn: Redis connection to use. signature: Signature of the new category. event: Optional. Event to save under the new category.

This method will set 3 metadata fields for the category hash: * category is the full text of the original cateory. * verbose_name is the human readable name for this category (used for

display purposes)
  • threshold is the custom threshold for this category

The key values are in the form {category_hash}:{metadata_name} e.g. a909ede39c09d84ed1839c5ca0f9b9876113770b:category

classmethod get_all_categories(redis_conn)[source]

Return a list of all currently defined categories

recategorise(default_threshold, archive_time=None)[source]

WARNING: Will remove this category and re-sort its events

Args:
default_threshold: Default threshold to try and reclassify on.
This takes the place of what is pulled from the config in firetower-server.
archive_time: Optional. After reclassification if this is set
everything before this time will be archived from this point back.
to_dict(num_recent=5)[source]

Return a dictionary representation of this cats metadata

Args:
num_recent: int, number of recent categorizations to include. defaults to five.
Returns:
dict, containing string value of signature, human readbable name of the category, the classification threshold, and a list of the most recent event signatures classified as this category.

Project Versions

Previous topic

Alert Model

Next topic

Classifier functions

This Page