-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2734 from alanwest/alanwest/otel-logs
Sending logs from OpenTelemetry
- Loading branch information
Showing
4 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...rations/open-source-telemetry-integrations/opentelemetry/opentelemetry-logs.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters