Create custom metrics
Add pre-computed metrics to custom processors that drive advanced analytic use cases
Pre-computed metrics generated by the Metrics Engine can be used within a custom processing component. For example, events could be filtered by user-defined metrics using time intervals, scoring models use metrics as part of the input feature space or build KPIs that combine metrics with event data.
Requirements
See Setting up the environment documentation
Note all gradle commands must be execute at the root of the project directory
Development steps
Register query
Get metrics
Explaining each step
Step 1: Register query
All queries to be executed must be registered, this reduces the overhead of recreating the target SQL query on each function call. The interface elegantly handles duplicate queries by providing the same query token in the form of a UUID.
Attribute | Description | Example |
---|---|---|
metricFamily | The metric family this query relates to and belongs to. | |
metrics | An array of metric names that match the metric table columns. | |
predicate | A SQL where predicate statement filters required metrics. |
Example
The queryToken
returned is used as a parameter on the query
method. Therefore it is best to be cached as a object class variable.
Step 2 Get metrics
This API provides the ability to query the target metric family for a set of pre-computed metrics. The function returns an Optional object type that is either empty or with a map of metrics with corresponding values.
Attribute | Description | Example |
---|---|---|
queryToken | The token provided from the query registration process | |
params | An array of parameters that match the query predicate definition |
Example
Last updated