Apply metrics
Apply metrics within stream processing functions
Objective
Use calculated metrics within processor logic, analytics, ML inferencing or simply send metrics to connected consumers.
Metrics applications
To access metrics two methods have been provided:
Emit projection Metrics can be included within the emit
select
statement to enhance output events.Query interface Metrics can also be accessed via the Metric Query API for use in custom processors, enhancing the integration of metric data in analytics workflows.
Emit projection
Metrics can be added to the final output event using the emit select
statement metrics query syntax.
This section explains how use the metrics query language.
Example
This example will add the avg_bid_max
metric to the output event on a successful symbol look up match.
Query Structure
Users define metric queries directly within the select
statement, allowing for dynamic lookups based on conditions such as a symbol
value.
The query structure is formed of three required components and an optional override output alias.
Required components:
metric-family
metrics
predicate
Optional
output-alias
Structure follows a pragmatic form:
<metrics-family>.<metrics>;<predicate> '<output-alias>'
metric-family
This is the logical name of the group of metrics, which should correspond to a metric name declared within the compute section.
metrics
A comma delimited list of metrics or asterisk. Any defined metric needs to correspond the query projection attributes.
predicate
Matching and filtering statement using standard SQL. This is used to extract only those records that fulfils a specified condition.
output alias
Use an alias for the output metric rather than the metric name for a single field output.
Examples
Query interface
Metrics can also be accessed via the Metric Query API for use in custom processors, enhancing the integration of metric data in analytics workflows.
Find further information on how to leverage the value through the API documentation.
Last updated