Create a Custom Query

This page describes the elements that define a custom query and provides several examples of using the Query Builder to create custom queries.

Elements that Define a Custom Query

To create a custom query, you must specify the following elements:

  • Aggregation function
  • Metric
  • Where Clause
  • Group By Clause
  • Legend

The sections below describe these elements.

Aggregation Function

Aggregation is a method of reducing the amount of data that SigNoz displays, and you can use it to identify patterns or outliers in your data. SigNoz allows you to perform both temporal and spatial aggregation.

Temporal Aggregation

SigNoz re-aggregates into longer intervals the metrics you collect at a high frequency, allowing low-resolution time series to be pre-calculated or used in place of the original metric data. SigNoz auto-adjusts this interval based on the time range selected to limit the number of points it plots on the chart. The following example diagram shows the aggregation of data into ten second intervals:

Temporal Aggregation

Spatial Aggregation

If you collect a metric and you don’t need all the attributes, you can remove unwanted attributes. This way, your metrics will only have the attributes that you need. The following diagram shows the aggregation of the entire set of time series into a single value at each interval of time:

Spatial Aggregation

Supported Aggregation Functions

SigNoz supports the following aggregation functions:

  • NOOP (No aggregation)
  • COUNT (Number of values in each set of data)
  • COUNT_DISTINCT (Number of distinct values in each set of data)
  • SUM (Sum of all the values)
  • AVG (Average of all the values)
  • MAX (Maximum of all the values)
  • MIN (Minimum of all the values)
  • P05 (5th percentile of values)
  • P10 (10th percentile of values)
  • P20 (20th percentile of values)
  • P25 (25th percentile of values)
  • P50 (50th percentile of values)
  • P75 (75th percentile of values)
  • P90 (90th percentile of values)
  • P95 (95th percentile of values)
  • P99 (99th percentile of values)
  • RATE (Rate of change of value for each time series)
  • SUM_RATE (Sum of the rate of change of each time series)
  • RATE_SUM (Rate of change on sum aggregated values)
  • RATE_AVG (Rate of change on avg aggregated values)
  • RATE_MAX (Rate of change on max aggregated values)
  • RATE_MIN (Rate of change on min aggregated values)

How do Metrics work in SigNoz?

Application metrics represent a characteristic of your application as a value at a specific point in time. For example, an application metric is the number of requests per second your application serves. SigNoz collects information as a sequence of data points every minute and then represents the data through time in a graphical form. The X-axis is time, and the Y-axis is the value.

You can use a where clause to specify the filtering condition for your query, enabling you to select only data that meets the specified criteria. SigNoz will only plot data for which the where clause evaluates to true, and it’ll exclude everything else. For example, you can use a where clause to plot only the HTTP requests from a service named foo that returned a 500 status code.

The following operators are supported:

  • IN
  • NIN
  • LIKE
  • NLIKE
📝 Note

You can use the IN and NIN operators as an alternative for = and != with a single value.

Group By Clause

You can use the Group By clause to divide the results of your query based on the property you specify. The following example diagram shows how a Group By clause aggregates the same metric into separate groups, each group representing an AWS region:

Group By Clause

Legend

Use the Legend text box to specify a legend name for your time series.

Sample Example to Create Custom Queries

Checkout the Query Builder documentation for examples on how to create custom queries using Query Builder.

Was this page helpful?