Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging support to the Elasticsearch exporter #1800

Closed
rakyll opened this issue Dec 11, 2020 · 11 comments
Closed

Add logging support to the Elasticsearch exporter #1800

rakyll opened this issue Dec 11, 2020 · 11 comments
Assignees

Comments

@rakyll
Copy link
Contributor

rakyll commented Dec 11, 2020

This issue is moved here from #1630 as a tracking bug.

@cyrille-leclerc Let me know if anyone is already working on this. This future is on our TODO list and we can help if no one is actively working on it.

@cyrille-leclerc
Copy link
Member

Thanks Janaa. I'll clarify by midweek how we are moving forward on on adding logs support to the Elastic exporter.

@MarkSeufert
Copy link

Currently working on a logs Elasticsearch exporter for the C++ repo, it'd be useful to see how the collector defines the mapping between OTEL log fields to Elasticsearch so that we can stay consistent.

@cyrille-leclerc
Copy link
Member

cyrille-leclerc commented Dec 17, 2020

Thanks for your patience @rakyll and @MarkSeufert.

Elastic plans to work on the OpenTelemetry Collector exporter toward Elasticsearch right now and it should not be a long task.

@rakyll we would like to verify with you one point please: the PR #1801 you initiated connects to Elastic APM Server rather than connecting to Elasticsearch (see the line of code here).
Our proposal in #1630 is to add an exporter toward Elasticsearch directly, not going through Elastic APM Server.
Our rationale is:

  • we want to simplify onboarding of Elasticsearch users who may have not installed Elastic APM Server, who are using plain Elasticsearch,
  • Elastic APM Server doesn't have a logs HTTP intake and we don't plan to introduce one because we plan to instead add native support for the OpenTelemetry Protocol on APM Server (alongside the existing Elastic APM HTTP Protocol and the Jaeger protocol).

@rakyll we guess that you also have in mind the addition of a direct exporter toward Elasticsearch, is this correct?

If we are aligned on this vision, we can start implementing with no delay.

Moreover, @MarkSeufert highlighted an important point: a clear and documented mapping between OpenTelemetry Semantic Conventions and the Elasticsearch data model: Elastic Common Schema.

The specification work started a while ago on https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/logs/data-model.md#elastic-common-schema .

We have designed proof of concept to have clarity on this mapping, we propose to use the Pull Requests of this Elasticsearch exporter to validate with the OpenTelemetry community the mapping decisions. Would this work for you?

@rakyll
Copy link
Contributor Author

rakyll commented Dec 31, 2020

@cyrille-leclerc would you be interested in contributing an exporter. We can help you to validate the scheme mapping. Sorry for opening #1801. I was just looking into Elastic for the first time and wanted to draft a change to note I was looking into it but didn't have time. I'd be happy if you can take over.

@andrewhsu andrewhsu added enhancement New feature or request and removed feature request labels Jan 6, 2021
@urso
Copy link

urso commented Jan 11, 2021

As has been pointed out by @cyrille-leclerc, the current elastic exporter does not ingest data right into Elasticsearch, but forwards metrics and traces to the Elastic APM Server. The APM server applies some additional processing before indexing traces and metrics as documents in Elasticsearch.

In addition to forwarding APM-Server, we plan to add a second "mode" to the elastic exporter. For now we will support indexing only logs directly, but it would be nice to add metrics as a follow up later. We will introduce new settings like elasticsearch_url, api_key and similar that configure the Elasticsearch endpoint. Elasticsearch and APM Server endpoints are configured, the APM takes precedence if it is available for said event types.

We expect events to be published to follow the OpenTelemetry Semantics. The OTel Semantics to ECS mapping hasn't been maintained for some time. In the process we will look for required updates and add support for users to configure the mapping.

I hope to have an initial PR ready soon.

@rakyll
Copy link
Contributor Author

rakyll commented Jan 11, 2021

cc @alolita

urso pushed a commit to urso/opentelemetry-collector-contrib that referenced this issue Feb 10, 2021
This is the first step in adding the Elasticsearch exporter. Initially
we will only support the Logs exporter interface, and potentially will
add metrics in the future as well.

This change only provides some boilerplate initializing the exporter.
But the exporter is not yet usable (or part of) any opentelemetry
collector distribution.

The elasticsearch exporter is based on the official
[go-elasticsearch](https://github.com/elastic/go-elasticsearch) client.
We will use the BulkIndexer provided by the client for event publishing.
The client and BulkIndexer provide some support for retrying already.
The Elasticsearch Bulk API can report errors at the HTTP level, but uses
selective ACKs for individual events. This allows us to retry only
failed events and/or reject events that can not be indexed (e.g. due to
an mapping error). The 429 error code might even inidcate that we should
backoff a little before retrying.

**Link to tracking Issue:** open-telemetry#1800

**Testing:** Only configuration loading and validation tests have been
added so far. The exporter currently panics when trying to publish
events. More unit and integration tests will be added in the future.

**Documentation:** All settings that will be available initially are
documented in the README.md file.
bogdandrutu pushed a commit that referenced this issue Feb 18, 2021
* Init Elasticsearch exporter

This is the first step in adding the Elasticsearch exporter. Initially
we will only support the Logs exporter interface, and potentially will
add metrics in the future as well.

This change only provides some boilerplate initializing the exporter.
But the exporter is not yet usable (or part of) any opentelemetry
collector distribution.

The elasticsearch exporter is based on the official
[go-elasticsearch](https://github.com/elastic/go-elasticsearch) client.
We will use the BulkIndexer provided by the client for event publishing.
The client and BulkIndexer provide some support for retrying already.
The Elasticsearch Bulk API can report errors at the HTTP level, but uses
selective ACKs for individual events. This allows us to retry only
failed events and/or reject events that can not be indexed (e.g. due to
an mapping error). The 429 error code might even inidcate that we should
backoff a little before retrying.

**Link to tracking Issue:** #1800

**Testing:** Only configuration loading and validation tests have been
added so far. The exporter currently panics when trying to publish
events. More unit and integration tests will be added in the future.

**Documentation:** All settings that will be available initially are
documented in the README.md file.

* Rename urls setting to endpoints

* fix lint

* Add factory and exporter initialization tests

* Lint checks

* Error lint

* Fix import order

* fix typo

* Do not "shadow" err in a deferred func

* review

* fix typo in exporter_test.go

* use const for environmant variable name in tests

* fix format after gorename

* typo
pmatyjasek-sumo referenced this issue in pmatyjasek-sumo/opentelemetry-collector-contrib Apr 28, 2021
* Init Elasticsearch exporter

This is the first step in adding the Elasticsearch exporter. Initially
we will only support the Logs exporter interface, and potentially will
add metrics in the future as well.

This change only provides some boilerplate initializing the exporter.
But the exporter is not yet usable (or part of) any opentelemetry
collector distribution.

The elasticsearch exporter is based on the official
[go-elasticsearch](https://github.com/elastic/go-elasticsearch) client.
We will use the BulkIndexer provided by the client for event publishing.
The client and BulkIndexer provide some support for retrying already.
The Elasticsearch Bulk API can report errors at the HTTP level, but uses
selective ACKs for individual events. This allows us to retry only
failed events and/or reject events that can not be indexed (e.g. due to
an mapping error). The 429 error code might even inidcate that we should
backoff a little before retrying.

**Link to tracking Issue:** #1800

**Testing:** Only configuration loading and validation tests have been
added so far. The exporter currently panics when trying to publish
events. More unit and integration tests will be added in the future.

**Documentation:** All settings that will be available initially are
documented in the README.md file.

* Rename urls setting to endpoints

* fix lint

* Add factory and exporter initialization tests

* Lint checks

* Error lint

* Fix import order

* fix typo

* Do not "shadow" err in a deferred func

* review

* fix typo in exporter_test.go

* use const for environmant variable name in tests

* fix format after gorename

* typo
tigrannajaryan pushed a commit that referenced this issue May 20, 2021
**Description:** The change adds support for encoding OpenTelemetry log records to JSON.
The encoder tries to remove duplicate entries in case the attribute map
(which is an array if key value pairs) contains duplicates.

Mixed style attributes, with key names having dots and other fields
having attribute maps as value will be normalized, such that the JSON
encoding will be either completely flat, or values are properly merged
into a single JSON object (when dedot is enabled). The normalization
helps with deduplication, and (not yet implemented) dedot support will
allow us to present a well formated JSON event if Ingest Node is used
(The dedotting in Elasticsearch does happen after Ingest Node).

Next:
- Dedotting support
- Custom (configurable) field mapping
- `publishLogs` unit testing
- Integration tests

**Link to tracking Issue:** #1800

**Testing:**
The internal document type with field deduplication is fully tested (89%) via unit tests.

The change also hooks up `publishLogs`, but this functionality is not covered by tests yet, as the PR has already grown quite a bit (I tested locally with a custom otel collector distribution). I would like to add additional tests in a separate PR, to keep focused on the JSON encoding only here.
@ilaif
Copy link

ilaif commented Jun 20, 2021

Hey guys, what's the status of the exporter? Couldn't determine if it's "released" yet. Didn't find any documentation.
Thanks!

@maitdaddy1
Copy link

Hello All!
Any status on the exporter? I think this is a major win for the community if /when its released

tigrannajaryan pushed a commit that referenced this issue Aug 12, 2021
Add dedot support to Elasticsearch exporter. With all fields being sorted we iterate over the keys and dedot while serializing the document to JSON.

**Link to tracking Issue:** #1800 

**Testing:** Unit tests for dedot and flat serialization have been added.

**Documentation:** The dedot setting has already been documented. This PR adds the missing feature.
@vincentfree
Copy link
Contributor

I have tried to add the component locally, logs and traces seem to work but the thing that I need which is metrics is still not there. Any update on the timelines and if I can contribute?

@amccool
Copy link

amccool commented Dec 9, 2021

ILoggerProvider implementation using rx.net and batching https://github.com/amccool/AM.Extensions.Logging.ElasticSearch

ljmsc referenced this issue in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
* Changes stdout to expose the actual tracerProvider

This enables flushing and stopping the exporter.

* updated changelog

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <[email protected]>

Co-authored-by: Tyler Yahn <[email protected]>
@codeboten
Copy link
Contributor

The logs exporter is currently shipped as part of the contrib distribution: https://github.com/open-telemetry/opentelemetry-collector-releases/blob/main/distributions/otelcol-contrib/manifest.yaml

Closing the original issue. If there are additional enhancement requests, please open separate items for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants