Create Your Own Custom Metrics
Retrace makes it easy to track and monitor any number of custom metrics, business KPIs, and other important business or application events that could provide insights into application or user behavior. With Stackify, you can monitor, trend, and setup alerts for these important events, making them an actionable part of your overall application health picture.
Why Custom Metrics with Retrace?
There are many ways to track application metrics. Including Windows Performance Counters, JMX MBeans, StatsD, and many other solutions.
Retrace simplifies the process in several ways. Most importantly? It just works.
Add 1-2 lines of code to your app and our system automatically creates the metric, reports the data, collects the data from your app, sends it to our system, and allows full charting, monitoring, and alerting.
- They work no matter where your app is deployed
- Nothing additional to install on your servers
Examples of Custom Metrics Usage
Custom metrics can be used a wide variety of usages. Below are some common examples of how and why you would use custom metrics within your application.
Learn more from our blog: When & How to Use Custom Application Metrics
Count How Often a Certain Event Happens
They are very useful for tracking how often anything happens. This could be as simple as how many times someone logs in to your software. At Stackify we use it to track things like how many log messages our platform ingests per minute.
Being able to monitor these metrics makes it easy to monitor when the numbers are a lot higher or lower than anticipated.
Track How Long a Transaction Takes
A good example of this is tracking how long specific parts of your code takes. For example, we use it to track how long it takes to process a message being read and processed off a queue. We also use it to track the latency of how long the items were in the queue.
One of the best uses is to track how long it takes to execute a specific Elasticsearch, MongoDB, or SQL query.
Gauge Based Metrics
Think of gauge metrics like the gauges in a car or airplane. They report the current value of something.
At Stackify we use it to track how many concurrent messages we are processing off a queue. When we start processing we increment a metric, when we are done, we decrement it. Overtime we can see how many we concurrently process.
Requirements for Using Custom Metrics
The following are requisites for using Stackify's Custom Metrics functionality:
- There needs to be an agent running on the server where the application is running.
- The app that you are setting up needs to be registered by the agent so that it appears in the Apps page of Stackify.
- You need to use one of our supported API libraries
Supported API Libraries
Types of Custom Metrics
- Gauge: Keeps track of the last value that was set in the current minute
- Counter: Calculates the rate per minute
- Average: Calculates the average of all values in the current minute
- Sum: Calculates the total sum of all values in the current minute
- Timer: Calculates the average elapsed time for an operation in the current minute
The code varies by programming languages but is very simple. With a 1-2 lines of code you record a wide array of custom application metrics. Our libraries and Retrace take care of automatically adding the metrics to your application instances.
StackifyLib.Metrics.Count("Users", "Login Success");
Configuring Alert Thresholds
Once the data starts feeding to Retrace, you can then configure the alert thresholds on the values that report from the application's monitoring configuration screen. For more information on App Configuration, take a look at the Configuring App Monitors article. By setting these thresholds with values that make sense for each individual metric, you will be alerted with a Warning, Critical, or Outage, depending on the setup.