Metrics provide a semantic layer that gives business meaning to your data. They centralize the definition of a business indicator so that it can be consistently used throughout your application. Metrics can be of different types — Sum, Count, Count Distinct, Min, Max, or Average — depending on how they aggregate data. Depending on your use case, you can query metrics in time series, counter, or leaderboard format.
Metrics enable you to build product experiences like dashboards, leaderboards, key performance indicators, or analytics APIs. With Metrics, you can define metrics once and use their data throughout your web or mobile applications via Propel's API.
Metric Query API
You can query Metrics in different ways depending on the experience you are looking to build.
This is the simplest Metric Query API, it returns a single value summarizing the Metric over the requested time range.
The time series Metric Query API returns data to visualize as a time series bar or line chart over the requested time range.
The leaderboard Metric Query API is useful for building rankings or ‚top N‚ visualizations over one or more Dimensions over the requested time range.
The Metric definition
A Metric is powered by a Data Pool and is defined by its type, its Metric Filters, and an optional set of Dimensions that can be filtered at query time. You can define Metrics via the Console or API.
The Data Pool provides the data for the Metric. It ensures that the Metric has the data they need and that it is served blazingly fast so you can power responsive, interactive product experiences.
The Data Pool's' primary timestamp column acts a the the Metric's time dimension.
Each Metric type performs a different data aggregation. Below is a list of all the available Metric types:
|Sum||Sums the values of the specified column for every record that matches the Metric Filters. It will sum the values for each time granularity for time series queries.||Revenue|
|Count||Counts the number of records that matches the Metric Filters. It will count the values for each time granularity for time series queries.||Page views|
|Count Distinct||Counts the number of distinct values in the specified column for every record that matches the Metric Filters. It will count the distinct values for each time granularity for time series queries.||Unique visitors|
|Max||Selects the maximum value of the specified column for every record that matches the Metric Filters. It will select the maximum value for each time granularity for time series queries.||Maximum speed|
|Min||Selects the minimum value of the specified column for every record that matches the Metric Filters. It will select the minimum value for each time granularity for time series queries.||Minimum temperature|
|Average||Averages the values of the specified column for every record that matches the Metric Filters. It will average the values for each time granularity for time series queries.||Average call handle time|
Dimensions are qualitative values used to categorize and segment the Metric data. For example, if you have a revenue metric and want to see revenue by country, product, or salesperson, then country, product, and salesperson would be Dimensions in the revenue Metric definition.
Do not expose as Dimensions columns that are internal and not meant to be used in customer-facing applications.
Metric Filters enable you to define a Metric with a subset of records from the given Data Pool. If no Filters are present, Propel will include all the Data Pool records in the Metric calculations.
Suppose you need to define a revenue Metric that does not include promotional (PROMO) transactions. In that case, you can create a Metric Filter and exclude transactions with type "PROMO" in the Metric definition instead of remembering to filter them every time you query the revenue Metric.