Adding a Metric
A metric is an entity type provided with TIBCO BusinessEvents Views. At design time, you configure the metric resource to calculate the metric data you want to use. At run time, the metric entity stores the computed data.
A metric entity has two types of metric fields: group-by and aggregation. A metric also has an optional type of field, called a tracking field, where you can add more information related to the metric.
Metrics are generally populated when an event triggers a rule. The rule computes the metric field values using a special ontology function, compute(). For more on this, see Adding an Event and a Rule to Populate the Metric Values.
- Group-by field
- A group-by field determines the categories of data in the chart. It also acts as the identifier for a metric instance. Suppose an event triggers a rule that computes a metric’s values. If the group by field value matches the value in an existing metric instance (stored in the cache or backing store), then the existing instance is updated using the newly-computed metric values. But if there is no match, then a new metric instance is created. As an example, the ticker is the group-by value. All events for the same ticker symbol update the price and volume for the same metric instance, instead of creating a new instance.
Note:
- Multiple group by fields
- Suppose you define two group-by fields. In this case, the metric instance is defined using both those values, similar to the way key fields work in databases. For example, City and State are group by fields. The values City = Palo Alto and State = California would constitute the key for one metric instance, and City = Santa Cruz and State = California would identify a different metric instance.
- Aggregation field
- Aggregation fields define the values that appear in charts. Different types of aggregation are available (using formulas explained in Aggregation Fields in TIBCO BusinessEvents Views Developer’s Guide). The tutorial uses Set aggregation, which just replaces the existing value with the current value. In the tutorial, Price and Volume are aggregation fields.
- Tracking field
- Tracking fields are optional fields that enrich the metric’s information. Tracking fields display on the search page only. Tracking fields display only if tracking is enabled. See TIBCO BusinessEvents Views Developer’s Guide for more information.
- Select the
Dashboards folder. Click the
New Metric toolbar button:
Tip: The toolbar is the quickest way to set up a project. It helps you add the resources in the right order, and you’ll find that it also creates useful defaults based on the prior resource you added.
You can also add resources in other ways too. For example, press Ctrl+N, and select TIBCO BusinessEvents > Views > Metric.
- You see the New Metric wizard. Name the metric M_TickerTracker and click Next.
- At the Add new group by fields page, change the default field name, Field_1, name to Ticker (a string property), then click Next.
- At the Add new aggregation fields page, define these fields. (Click the add button on the right to add the second field):
- Click Finish. You see the metric editor showing the configured metric. Details you entered in the wizard are saved automatically.
Postrequisites
You have added a metric. Next you will configure an optional feature of metrics, enabling Dashboard users to click links to URLs related to metric fields.
- Select the
Dashboards folder. Click the
New Metric toolbar button: