Skip to content

Commit

Permalink
Merge pull request #2734 from alanwest/alanwest/otel-logs
Browse files Browse the repository at this point in the history
Sending logs from OpenTelemetry
  • Loading branch information
barbnewrelic committed Jun 17, 2021
2 parents 7d3be39 + c504793 commit f9769b3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: OpenTelemetry and logging
tags:
- Integrations
- Open source telemetry integrations
- OpenTelemetry
---

Logs are one of the core data types in OpenTelemetry. They may represent application logs, machine generated events, or system logs. Our OpenTelemetry [log data model in GitHub](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md) describes them in detail.

Let's look at how to send logs, correlate them with applications, and view them in New Relic.

## Send logs to New Relic [#send-logs]

The [New Relic Exporter](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/newrelicexporter) for the [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/) supports exporting logs to New Relic. The general pattern is to configure the collector to:

1. Receive logs from any of the log receivers. Some of the receiver options include [Filelog Receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiver), [Fluent Forward Receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/fluentforwardreceiver), and [Syslog Receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/syslogreceiver).
2. Process logs, potentially annotating them with resource information. Some of the processor options include [Resource Detection Processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor) and [Resource Processor](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/resourceprocessor).
3. Export logs via the [New Relic Exporter](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/newrelicexporter).

## Application log correlation [#log-correlation]

Application logs are more useful if they're correlated with other telemetry data produced by the application. The OpenTelemetry [semantic convention for services](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions#service) specifies `service.name` as a required field. All application metric, trace, and log data sent to New Relic with the same `service.name` are associated with the same [entity](/docs/new-relic-one/use-new-relic-one/core-concepts/what-entity-new-relic).

The specifics of how logs get annotated with the `service.name` resource attribute depends on the application's environment:

- Applications may produce structured JSON logs, which you can configure to include `service.name` as another field.
- You can deploy applications alongside a dedicated [Collector Agent](https://opentelemetry.io/docs/collector/getting-started/#agent) instance, which you can configure with a [Resource Processor](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/resourceprocessor) to annotate logs with the `service.name` attribute.

Optionally, additional application [trace context](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/overview.md#log-correlation) (sometimes called execution context) can be propagated to log messages. The setup and availability of this depends on the language and logging framework used by the application. The general strategy is to set up the application to write structured JSON logs and to configure it to extract trace context into specified [trace context fields](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#trace-context-fields) on available log messages.

The [Logs in Context with Log4j2 example in GitHub](https://github.com/newrelic/newrelic-opentelemetry-examples/tree/main/java/logs-in-context-log4j2) demonstrates an end-to-end working example for a simple Java application using Log4j2.

## View OpenTelemetry logs [#view-logs]

Here are two ways you can view logs:

* Look in the New Relic [Logs UI](/docs/logs/log-management/ui-data/use-logs-ui/).
* If your logs are correlated with an application, view them in the [context of the application](/docs/integrations/open-source-telemetry-integrations/opentelemetry/view-your-opentelemetry-data-new-relic#logs).
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,48 @@ To get started with the explorer:

![Screen capture showing how to filter for OpenTelemetry services.](./images/explorer_otel_services.png "Filter for OpenTelemetry to see only those entities.")

3. Click the service you want to know more about, and if you need help understanding the data, see the explanations below.
3. Click the service you want to know more about.

If you need help understanding the data, see the explanations which follow.

### Summary page [#summary]

The opening page of the explorer is the **Summary** page listing various golden signals about your entity. Golden signals are key monitoring details such as response time, throughput, and error rate. By using this information, you can quickly decide if you need to dig deeper.

### Distributed Tracing [#tracing]
### Distributed tracing [#tracing]

When you access distributed tracing through the explorer, you are looking at traces that include that service. Once you’re in that service, you can filter spans to find the ones you want. For example, to query `service.name` or `trace.id`, you can use the following:

* `service.name = YOUR_SERVICE_NAME`
* `trace.id = YOUR_TRACE_ID`

For more ways to filter and analyze your spans, see our [distributed tracing UI](/docs/understand-dependencies/distributed-tracing/ui-data/understand-use-distributed-tracing-ui) page.
For more ways to filter and analyze your spans, see our [distributed tracing UI page](/docs/understand-dependencies/distributed-tracing/ui-data/understand-use-distributed-tracing-ui).

<Callout variant="tip">
If you prefer to search traces across all New Relic accounts in your organization, you can go outside explorer: **[one.newrelic.com](https://one.newrelic.com) > Apps > Favorites > Distributed tracing.**
</Callout>

### Transactions [#trx]

Use Transactions to identify slow or error transactions that might be causing a spike in the response time of your application. From the transaction summary page, you can get a list of transactions by selecting See transactions table.
Use **Transactions** to identify slow or error transactions that might be causing a spike in your application's response time. To get a list of transactions: From the **Transaction Summary** page, select the transactions table.

### Databases
### Databases [#databases]

The **Databases** page shows an application's database and cache data. The page shows individual database transactions as a sortable table, and shows operations, throughput, and response time as charts.

### Externals
### Externals [#externals]

Externals capture calls to out-of-process services such as web services, resources in the cloud, and other network entities.

### Errors [#errors]

Externals captures calls to out-of-process services such as web services, resources in the cloud, and other network entities.
On the **Errors** page, you can see total errors as well as charts showing error count and error rate.

### Errors
### Logs [#logs]

On this page, you can see total errors, as well as charts showing error count and error rate.
The **Logs** page displays logs from your application. For more information about how to associate log data to your application in New Relic, see our [OpenTelemetry and logging documentation](/docs/integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-logs).

### Metrics Explorer [#metric-explorer]
### Metrics explorer [#metric-explorer]

For selected OpenTelemetry languages, you can see information about your metrics in this section. Also, if you are using the Prometheus exporter with OpenTelemetry, you can view your metric data here.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Log management's features include:

## Bring in your logging data [#integrate-logs]

You can bring your log data into New Relic using a [compatible log forwarding plugin](/docs/enable-new-relic-logs#compatibility-requirements):
You can bring your log data into New Relic using a [compatible log forwarding plugin](/docs/enable-new-relic-logs#compatibility-requirements), or with [OpenTelemetry](/docs/integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-and-logging).

* Forward your logs [using our Infrastructure agent](https://docs.newrelic.com/docs/logs/enable-new-relic-logs/1-enable-logs/forward-your-logs-using-new-relic-infrastructure-agent) or our [Kubernetes plugin](/docs/logs/enable-logs/enable-logs/kubernetes-plugin-logs).
* Use our plugins for well-known log forwarders, like [Fluentd](/docs/logs/enable-logs/enable-logs/fluentd-plugin-logs), [Fluent Bit](/docs/logs/enable-logs/enable-logs/fluent-bit-plugin-logs), and [Logstash](/docs/logs/enable-logs/enable-logs/logstash-plugin-logs).
Expand Down
8 changes: 6 additions & 2 deletions src/nav/integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ pages:
path: /docs/integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-architecture-recipes
- title: View your OpenTelemetry data
path: /docs/integrations/open-source-telemetry-integrations/opentelemetry/view-your-opentelemetry-data-new-relic
- title: Advanced configuration
path: /docs/integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-advanced-configuration
- title: Advanced topics
pages:
- title: Endpoint configuration
path: /docs/integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-advanced-configuration
- title: Send logs to New Relic
path: /docs/integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-logs
- title: Troubleshooting
path: /docs/integrations/open-source-telemetry-integrations/troubleshooting/troubleshoot-opentelemetry-exporter
- title: Dropwizard
Expand Down

0 comments on commit f9769b3

Please sign in to comment.