Skip to content

Latest commit

 

History

History
128 lines (87 loc) · 6.71 KB

ruby-telemetry-context.mdx

File metadata and controls

128 lines (87 loc) · 6.71 KB
title metaDescription
Ruby telemetry in context
For apps monitored by the Ruby agent, learn how to link log data with related data across the rest of the New Relic platform.

Telemetry in context for the Ruby agent connects your logs with all of your telemetry data for your apps, hosts, and other entities. Bringing all of this data together in a single tool helps you quickly:

  • Cut through the noise of thousands of logs when troubleshooting time-critical issues, so you automatically see only the most relevant logs.
  • Navigate within multiple types of telemetry data, and have the data correlate back to the original issue.
  • Easily drill down into more detailed information from the same place in the UI.
  • Find the log lines that you need to identify and resolve a problem.

Telemetry in context in APM UI

**Telemetry in context:** From the left nav in the APM UI, you can select an error and immediately see related logs, log details, host name, important attributes, and more.

Enable and configure [#enable]

You have three options to configure telemetry in context for your application:

<Collapser id="1-agent" title="Option 1 (simplest): Let the agent forward your logs."

This is the simplest approach, and it's a great choice for developers who may not have the access or interest in setting up a log forwarder, or for accounts that want to see the power of logs in context without a lot of overhead.

All you need to do is install an agent version with log forwarding capabilities (Ruby agent 6.8.0 or higher), and update your configuration to enable forwarding.

newrelic.yml:

application_logging.forwarding.enabled: true

Environment variable:

NEW_RELIC_APPLICATION_LOGGING_FORWARDING_ENABLED=true

This option may be on by default in a future agent version.

Optional adjustments:

Once this is enabled, you also have control over the maximum number of logs sent to New Relic every minute. The default value is 10,000. If more than 10,000 logs are received in a 60-second window, your logs will begin to be sampled.

Set it to a higher number to receive more logs. Set it to a lower number to receive fewer logs. Any integer is valid.

newrelic.yml:

application_logging.forwarding.max_samples_stored: 10_000

Environment variable:

NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED: 10000

<Collapser id="2-decorate" title="Option 2: Let the agent decorate your logs."

Already have a log forwarder you like? We've got you covered! Language agents can decorate your logs with the linking metadata needed to provide access to telemetry-in-context features.

Simply enable log decorating in your configuration, and relaunch the agent to start decorating your logs.

newrelic.yml:

application_logging.local_decorating.enabled: true

Environment variable:

NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED=true

Our decorator adds four attributes to every log message: entity.guid, hostname, trace.id, and span.id. Example:

This is my log message. NR-LINKING|{entity.guid}|{hostname}|{trace.id}|{span.id}|

We recommend this option over the old decorating formatter, NewRelic::Agent::Logging::DecoratingFormatter.

<Collapser id="3-old-formatter" title="Option 3: Use the old decorating formatter."

Before language agents had the ability to forward and decorate logs, you could enable logs in context by updating your application to use the NewRelic::Agent::Logging::DecoratingFormatter to send linking metadata.

This option is still supported, but is no longer encouraged. For instructions to use this approach, see Ruby: Configure logs in context.

Also, this method requires that you install a log forwarder before enabling logs in context. If you do not have a log forwarder, the New Relic One UI will prompt you to use our infrastructure agent.

Secure your data [#obfuscation]

Your logs may include sensitive information protected by HIPAA or other compliance protocols. By default we obfuscate number patterns that appear to be for items such as credit cards or Social Security numbers, but you may need to hash or mask additional information.

For more information, see our documentation about obfuscation expressions and rules. You can hash or mask your log data by using the New Relic UI or by using NerdGraph, our GraphQL API.

Explore your data [#view-ui]

To make the most of your logging data:

  • On the APM Summary page, click your Web transaction time chart to view logs associated with a specific point in time.
  • Check your app's Errors inbox to view the logs associated with your errors.
  • Use distributed tracing to see the logs associated with individual traces.
  • Explore more logging data across your platform with our Logs UI.
  • Set up alerts based on log output and severity.
  • Query your data using our specialized UI for logs data, and create dashboards with the results.

Troubleshooting tips [#troubleshooting]

Typically your logs will start to appear less than a minute after you enable telemetry in context. Check your app's Triage > Logs section. You will also start seeing log patterns related to the error there.

Logs from APM Triage section

If you don't see any logs for errors or traces, there may not be any for your app. Try refreshing the UI page, or change the selected time period.