Custom views (deprecated)

Deprecated

Custom views is a deprecated feature. New Relic recommends using the Metric Explorer in Insights to:

  • Search all your metric data, including custom metrics
  • Create customizable metric charts
  • Add metric charts to Insights dashboards

Access to this feature depends on your subscription level.

Plugins is not supported with accounts that host data in the EU region data center.

Custom views in Liquid

New Relic custom views allow users to visualize custom metric data in charts and HTML tables. Custom Views are written using a custom version of Liquid, a templating language created for Shopify. Custom view code looks like normal HTML interspersed with small blocks of code. The Liquid Wiki has additional information about how to write templates.

Every Liquid custom view has access to four context variables, account, application, metrics, and applications. The account variable is an Account drop for the current account, and the application variable points to the current application selection. The metrics variable allows access to metrics for the current application and the applications variable can be used to access the applications belonging to the current account.

Drops are secure wrappers around New Relic objects and methods accessible from Liquid templates. Drops expose a limited number of method calls available on each object in a Liquid template, as specified below.

Account drops

Methods

  • id: The integer id of the account
  • name: The name of the account
  • applications: A collection proxy for the account applications. Applications can be looked up using this syntax:
app = account.applications['The app name']

The return value of the lookup is an Application drop.

Application drops

An application drop represents an application.

Methods

  • id: The integer id of the application
  • name: The name of the application
  • health_status: Returns a 1, 2 or 3 which indicates the overall health of the application. The traffic_light filter can be used to render a traffic light from the health_status integer value.
  • metrics: An ApplicationMetrics drop which can be used to look up metrics.

Application metric drops

An application metrics drop is a collection proxy that can be used to find metrics.

{{ application.metrics['metric name'] }}

You can also access the metrics for the current account selection with just the metrics variable.

{{ metrics['metric name'] }}

You can use the application metrics drop to look up a specific metric like in the above sample. You can also use it to retrieve multiple metrics using a regular expression match:

{% assign metrics = application.metrics.find_by_regexp['account'] %}

The return value of a single metric lookup is an application metric drop. The return value of a find_by_regexp invocation is an array of application metric drops.

You can use the metric selector to browse all available metrics and insert metric names or regexp values into your custom view for use in chart tags or filters. If you have added custom metrics via custom metrics, you will see them in the metric selector.

An ApplicationMetric drop represents a single application metric and can be used to fetch metric values. Metric value functions like call_count, time_percentage_by_host, and average_value_by_host can be directly invoked on this drop. Metric value functions are also used as a parameter for chart tags to specify the value to display in the chart. The return value of a value function invocation is a MetricValue.

Methods

  • id: The integer id of the metric
  • name: The name of the metric

Examples

{{ application.metrics['Memory/Physical'].average_value_by_host.value }}
{{ metrics['CPU/User Time'].time_percentage_by_host.value }}

Value methods

Some of the value methods return the same data for a given metric, but with different units. Units, if any, are listed in parentheses after the value method.

  • total_value (ms): The total value of the metric for each period within the time window. Use the value_suffix attribute to set the suffix
  • average_value, average_response_time (ms): The average value of the metric for each period within the time window.
  • count, call_count: The number of data points for the metric value (e.g. # of method invocations)
  • requests_per_minute (rpm), calls_per_minute (cpm), errors_per_minute (epm): The number of requests per minute
  • min_value, min_call_time (ms): The smallest metric value collected during the period.
  • max_value, max_call_time (ms): The largest metric value collected during the period.
  • time_percentage (%): Useful for DB and CPU percentage utilization, added across all applicable hosts.
  • time_percentage_by_host (%): Time percentage averaged across the # of hosts.
  • average_value_by_host: The raw value averaged across the # of hosts.
  • score: The value of a scoring method, currently used with Apdex metrics.

Filters

Filters are methods in Liquid. They always take their first parameter as the output of the left side of the filter (before the '|'). For more information about using filters, see the Liquid Wiki on Filters.

Examples

traffic_light(input, caution_threshold = 1, danger_threshold = 2)

This filter renders a traffic light image by comparing the input value against upper and lower thresholds. If the danger threshold is exceeded, the light will be red. If the caution threshold is exceeded, the light will be yellow. Otherwise it will be green.

{{ application.health_status | traffic_light }}

{{ application.metrics['Memory/Physical'].average_value_by_host.value | traffic_light:800,1300 }}

link_to_application(input, application)

This filter generates a link to an application. The input value is the link text.

{{ 'current application' | link_to_application:application }}

link_to_custom_view(input, custom view name or id)

This filter generates a link to a custom view. The input value is the link text.

{{ 'For more detail see this custom view' | link_to_custom_view:'My Custom View' }}

round(input, places = 0)

This filter rounds a value.

{{ 109.45 | round:1 }}

percentage(input)

This filter turns a value to a percentage by multiplying it by 100 and rounding to two places.

{{ 0.87 | percentage }}

Arithmetic filters

These filters are core features of Liquid:

# addition
plus(input, operand)
    
# subtraction
minus(input, operand)
    
# multiplication
times(input, operand)

# division
divided_by(input, operand)

sort_table(table_id, column, order = 'asc')

This filter sorts a table identified by DOM id "table_id", with a default sort on the column numbered "column" in the order specified. The order is an optional parameter. Once invoked, the table can be re-sorted dynamically by clicking on the table headers. Here is an example: {% assign metrics = application.metrics.find_by_regexp['.Controller/.'] %}

<table id="metrics_table">
<thead>
  <tr>
    <th></th>
    <th>Resp. time (300,1000)</th>
    <th></th>
    <th>RPM(10,50)</th>
    <th>Action</th>
  </tr>
</thead>
<tbody>
{% for metric in metrics %}
  <tr>
    <td>{{metric.average_response_time.value | traffic_light:300, 1000}}</td>
    <td>{{metric.average_response_time.value}}</td>
    <td>{{metric.requests_per_minute.value | traffic_light:10, 50}}</td>
    <td>{{metric.requests_per_minute.value}}</td>
    <td>{{metric.name}}</td>
  </tr>
{% endfor %}
</tbody>
</table>

{{ 'metrics_table' | sort_table:2, 'desc' }}

The last line calls the table sort, sorting on the second column in descending order. For more information, see Liquid Filters.

Tags

Tags in Liquid are used to create logic and other custom behavior in your custom views. For more information about built-in tags, see The Liquid Wiki page on Tags. The New Relic custom tags listed below are used to display charts and alter the time window.

Chart tags

New Relic custom views support chart rendering using a set of custom tags. Common chart attributes include:

  • title: The chart title
  • subtitle: The subtitle
  • value: A metric value function
  • label: A function on the metric name that returns the label for each metric's timeseries. Possible values are ui_name (default), long_ui_name, last_segment (returns the last '/'-separated segment of the metric name), or segment_N (returns the Nth segment of the metric name).
  • application: Either an application id or a name. This can be used to override the selected application.
  • since: Changes the time window used for the metric data query. See the since block.
  • hide_legend: Hides the graph legend when set to true
  • limit: Limits the number of metrics matched by a regular expression metric match
  • link_to: A url that will become the drilldown link for the chart
  • link_to_custom_view: A custom view name or id. The chart will hyperlink to the given custom view.
  • caution_threshold: A number value representing a caution threshold. A yellow horizontal line will be drawn on the graph at this value.
  • danger_threshold: A number value representing a danger threshold. A red horizontal line will be drawn on the graph at this value.
  • value_suffix: A suffix to be appended to all metric values
  • simple_tooltip: when true, the tooltip is just the value and suffix

Referencing metrics

Metric data can be referenced in two ways: either by using the name of a specific metric, or by providing a regular expression that matches multiple metrics. Use either the metric or the regexp attribute (but not both) in each chart tag to set the metric source.

  • metric: A string that matches a single metric. The value should be in single quotes and it should not be escaped.
  • regexp: A regular expression that matches metrics. This expression should be wrapped in quotes and it should not be escaped.

The following values are provided for informational purposes, for customers who created custom views using these values prior to June 2012. You can access your old custom views and create new custom dashboards from the New Relic Custom dashboards menu.

line_chart

{% line_chart value:time_percentage metric:'CPU/User Time' title:'CPU' %}

pie_chart

{% pie_chart regexp:'ActiveRecord/(save|find|destroy)' title:'Active Record' value:time_percentage %}

horizontal_bar_chart

{% horizontal_bar_chart value:call_count title:'Active Record' regexp:'ActiveRecord/(save|find|destroy)' %}

compare_with_last_week_chart

{% compare_with_last_week_chart metric:'ActiveRecord/all' title:'Week to Week Comparison' value:time_percentage %}

compare_with_yesterday_chart

{% compare_with_yesterday_chart metric:'ActiveRecord/all' title:'ActiveRecord' value:time_percentage %}

Similar to the compare_with_last_week_chart but uses a 24 hour time period for comparison rather than 7 day.

compare_with_yesterday_and_last_week_chart

{% compare_with_yesterday_and_last_week_chart metric:'ActiveRecord/all' title:'ActiveRecord' value:time_percentage %}

A combination of compare_with_yesterday_chart and compare_with_last_week_chart.

daily_summary_chart

{% daily_summary_chart metric:'Controller' title:'Daily Summary Chart' value:call_count %}

weekly_summary_chart

{% weekly_summary_chart metric:'Controller' title:'Weekly Summary Chart' value:call_count %}

Blocks

Blocks in Liquid are tags that are used to create logic in your custom view. There are many blocks built into Liquid, as well as the custom New Relic 'since' block.

since

New Relic's since block tag is used to specify a time window for a set of queries. This tag must be followed by a matching endsince tag. All metric data value and chart data queries occurring within a since tag will be scoped to the given time range. Charts will override this time window if the since attribute is specified, but this tag is useful for scoping an entire custom view to a particular time window. It is also the only way to change the time window scope of a metric value query.

Examples

{% since midnight %} 
  {{ application.metrics['Memory/Physical'].average_value_by_host.value }} 
{% endsince %}

{% since 3.hours.ago %} 
  {% line_chart value:time_percentage metric:'CPU/User Time' title:'CPU Last 3 hours' %} 
{% endsince %}

For more help

Recommendations for learning more: