Skip to content

NewRelic APM Browser

udx-github edited this page Sep 16, 2026 · 5 revisions

Creates NewRelic APM and Browser monitoring applications with alert policies and Slack notifications.

Use this module when a Rabbit service needs application performance monitoring, browser real-user monitoring, or both, with configurable alert thresholds and Slack notification workflows.

Supported Features

  • APM alert policy with error rate, response time, and Apdex conditions.
  • APM application settings configuration (when the agent has reported data).
  • APM entity tags.
  • Browser application creation with JavaScript snippet output.
  • Browser alert policy with page load time, JS error, and AJAX error rate conditions.
  • Shared alert signal defaults (evaluation window, occurrences, minimum sample size) with per-condition overrides, percentile-based duration alerts, and host/message exclusions for AJAX and JS error conditions.
  • Slack notification destination, channels, and workflows for both APM and Browser alerts.
  • Independent enable/disable for APM and Browser.

Prerequisites

  • A NewRelic account and API key available to the deployment runtime.
  • For APM: an APM agent configured in the application reporting to NewRelic.
  • For Slack notifications: a Slack webhook URL.

Important Notes

  • apm.app_name must match the name reported by the APM agent.
  • apm.configure_app_settings should only be set to true after the APM agent has reported data at least once.
  • browser.enabled: true creates a standalone Browser application and returns a browser_js_config output containing the JavaScript snippet to embed in the site's <head>.
  • R2A placeholders (#{Environment}, #{Lifecycle}, #{Owner}, #{Repository}) are supported in tag values.
  • slack.webhook_url set to empty string disables Slack notifications.
  • Conditions evaluate 300-second windows and open only when every window in threshold_duration breaches. Rate and duration conditions ignore windows with fewer than min_sample_size events (10 by default). Set alert_defaults.min_sample_size: 0 to evaluate every window.
  • threshold_duration is rounded up to a multiple of the condition's aggregation_window: at least one window, at most the largest multiple that fits in 86400 seconds. An aggregation_window outside 30-21600 or an unknown threshold_occurrences fails the plan.
  • browser.alerts.js_errors.threshold counts affected sessions per window by default (metric: sessions); set metric: count for raw error events.

Minimal Example

services:
  - name: "NewRelic APM and Browser"
    module: "newrelic-apm-browser"
    id: "newrelic"
    deployment_order: 145
    configurations:
      apm:
        enabled: true
        app_name: "www-example-com-#{Environment}"
      browser:
        enabled: true
        app_name: "www-example-com-#{Environment}-browser"
      slack:
        webhook_url: "projects/<project-id>/secrets/<slack-webhook-secret>"
        channel: "#alerts"

Outputs

Output Description
apm_entity_guid NewRelic entity GUID of the APM application (null if configure_app_settings is false).
apm_alert_policy_id ID of the APM alert policy (null if APM is disabled).
browser_application_id NewRelic application ID of the Browser app (null if Browser is disabled).
browser_js_config JavaScript snippet for Browser monitoring (sensitive, null if Browser is disabled).
browser_alert_policy_id ID of the Browser alert policy (null if Browser is disabled).
slack_destination_id ID of the Slack notification destination (null if Slack is disabled).
apm_workflow_id ID of the APM to Slack workflow (null if APM or Slack is disabled).
browser_workflow_id ID of the Browser to Slack workflow (null if Browser or Slack is disabled).

Full Configuration Schema

The fields below are public module inputs under configurations.

configurations:
  slack:
    webhook_url: ""
    channel: "#alerts"
  alert_defaults:
    aggregation_window: 300
    threshold_occurrences: "all"
    min_sample_size: 10
  apm:
    enabled: false
    app_name: ""
    apdex_threshold: 0.5
    configure_app_settings: false
    enable_real_user_monitoring: true
    transaction_tracer:
      record_sql: "obfuscated"
      threshold: 1.0
    tags: {}
    alerts:
      error_rate:
        enabled: true
        threshold: 5
        threshold_duration: 300
      response_time:
        enabled: true
        statistic: "average"
        threshold: 2.0
        threshold_duration: 300
      apdex:
        enabled: true
        threshold: 0.75
        threshold_duration: 300
  browser:
    enabled: false
    app_name: ""
    cookies_enabled: true
    distributed_tracing_enabled: true
    loader_type: "SPA"
    tags: {}
    alerts:
      page_load_time:
        enabled: true
        statistic: "p75"
        threshold: 5.0
        threshold_duration: 300
      js_errors:
        enabled: true
        metric: "sessions"
        threshold: 5
        threshold_duration: 300
        exclude_messages: ["Script error."]
      ajax_error_rate:
        enabled: true
        threshold: 5
        threshold_duration: 300
        min_status_code: 400
        include_hosts: []
        exclude_hosts: ["browser", "bam.nr-data.net", "bam-cell.nr-data.net", "js-agent.newrelic.com"]

Every entry under apm.alerts.* and browser.alerts.* also accepts aggregation_window, threshold_occurrences, and min_sample_size to override alert_defaults for that condition.

slack

Field Type Required Description
webhook_url string No Slack webhook URL or GCP Secret Manager path. Empty disables Slack.
channel string No Slack channel. Defaults to #alerts.

alert_defaults

Field Type Required Description
aggregation_window number No Evaluation window in seconds for every condition (30-21600). Defaults to 300.
threshold_occurrences string No all (every window in threshold_duration must breach) or at_least_once. Defaults to all.
min_sample_size number No Minimum events per window before a rate or duration window can breach; 0 disables. Defaults to 10. Not applied to js_errors.

apm

Field Type Required Description
enabled boolean No Enables APM monitoring. Defaults to false.
app_name string Conditional APM application name. Required when enabled is true.
apdex_threshold number No Apdex T value in seconds. Defaults to 0.5.
configure_app_settings boolean No Configures app settings (only after agent reports data). Defaults to false.
enable_real_user_monitoring boolean No Enables browser auto-instrumentation via APM. Defaults to true.
transaction_tracer.record_sql string No SQL recording mode. Defaults to obfuscated.
transaction_tracer.threshold number No Transaction tracer threshold in seconds. Defaults to 1.0.
tags map[string] No Entity tags for the APM app.
alerts.error_rate.enabled boolean No Enables error rate alert. Defaults to true.
alerts.error_rate.threshold number No Error rate threshold (%). Defaults to 5.
alerts.error_rate.threshold_duration number No Duration in seconds. Defaults to 300.
alerts.response_time.enabled boolean No Enables response time alert. Defaults to true.
alerts.response_time.statistic string No average, median, p75, p90, p95, or p99 of transaction duration. Defaults to average.
alerts.response_time.threshold number No Response time threshold in seconds. Defaults to 2.0.
alerts.response_time.threshold_duration number No Duration in seconds. Defaults to 300.
alerts.apdex.enabled boolean No Enables Apdex alert. Defaults to true.
alerts.apdex.threshold number No Apdex score threshold (0-1). Defaults to 0.75.
alerts.apdex.threshold_duration number No Duration in seconds. Defaults to 300.
alerts.*.aggregation_window number No Per-condition override of alert_defaults.aggregation_window.
alerts.*.threshold_occurrences string No Per-condition override of alert_defaults.threshold_occurrences.
alerts.*.min_sample_size number No Per-condition override of alert_defaults.min_sample_size.

browser

Field Type Required Description
enabled boolean No Enables Browser monitoring. Defaults to false.
app_name string Conditional Browser application name. Required when enabled is true.
cookies_enabled boolean No Enables cookies. Defaults to true.
distributed_tracing_enabled boolean No Enables distributed tracing. Defaults to true.
loader_type string No Browser agent loader type: SPA, PRO, or LITE. Defaults to SPA.
tags map[string] No Entity tags for the Browser app.
alerts.page_load_time.enabled boolean No Enables page load time alert. Defaults to true.
alerts.page_load_time.statistic string No average, median, p75, p90, p95, or p99 of page load duration. Defaults to p75.
alerts.page_load_time.threshold number No Page load time threshold in seconds. Defaults to 5.0.
alerts.page_load_time.threshold_duration number No Duration in seconds. Defaults to 300.
alerts.js_errors.enabled boolean No Enables JS error alert. Defaults to true.
alerts.js_errors.metric string No sessions (unique sessions with an error) or count (error events). Defaults to sessions.
alerts.js_errors.threshold number No Sessions or events per window. Defaults to 5.
alerts.js_errors.threshold_duration number No Duration in seconds. Defaults to 300.
alerts.js_errors.exclude_messages list[string] No Substrings; errors whose message contains one are ignored. Defaults to ["Script error."].
alerts.ajax_error_rate.enabled boolean No Enables AJAX error rate alert. Defaults to true.
alerts.ajax_error_rate.threshold number No AJAX error rate threshold (%). Defaults to 5.
alerts.ajax_error_rate.threshold_duration number No Duration in seconds. Defaults to 300.
alerts.ajax_error_rate.min_status_code number No Lowest HTTP status counted as an error. Defaults to 400.
alerts.ajax_error_rate.include_hosts list[string] No When non-empty, only requests to these hostnames are evaluated. Defaults to [].
alerts.ajax_error_rate.exclude_hosts list[string] No Hostnames removed from the population. Defaults to the Browser agent beacon hosts (browser, bam.nr-data.net, bam-cell.nr-data.net, js-agent.newrelic.com).
alerts.*.aggregation_window number No Per-condition override of alert_defaults.aggregation_window.
alerts.*.threshold_occurrences string No Per-condition override of alert_defaults.threshold_occurrences.
alerts.*.min_sample_size number No Per-condition override of alert_defaults.min_sample_size (not used by js_errors).

Clone this wiki locally