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

Init Elasticsearch exporter #2324

Merged
merged 14 commits into from
Feb 18, 2021

Conversation

urso
Copy link

@urso urso commented 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 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.

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.
@urso urso requested a review from a team February 10, 2021 23:18
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 10, 2021

CLA Signed

The committers are authorized under a signed CLA.

@codecov
Copy link

codecov bot commented Feb 10, 2021

Codecov Report

Merging #2324 (9255024) into main (ffce884) will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2324      +/-   ##
==========================================
- Coverage   90.63%   90.61%   -0.02%     
==========================================
  Files         400      400              
  Lines       19895    19955      +60     
==========================================
+ Hits        18031    18082      +51     
- Misses       1411     1418       +7     
- Partials      453      455       +2     
Flag Coverage Δ
integration 69.33% <ø> (+0.06%) ⬆️
unit 89.43% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
exporter/elasticexporter/config.go 71.79% <0.00%> (-28.21%) ⬇️
exporter/signalfxexporter/dimensions/requests.go 82.35% <0.00%> (-9.81%) ⬇️
exporter/elasticexporter/factory.go 91.17% <0.00%> (-8.83%) ⬇️
exporter/elasticexporter/exporter.go 86.40% <0.00%> (+10.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ffce884...9255024. Read the comment docs.

@@ -77,6 +77,6 @@ nodes will automatically be used for load balancing.
```yaml
exporters:
elasticsearch:
urls:
endpoints:
- "https://localhost:9200"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does a deployment typically look like? Is it common to have TLS for one server, but not for another? Do they have different sets of certs, or would a client only need one CA that works for all clients? I'm asking because endpoints are typically only host:port, without the protocol part, using TLS by default.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it common to have TLS for one server, but not for another?

No, when using TLS one would want to have TLS for the complete cluster.

Do they have different sets of certs, or would a client only need one CA that works for all clients?

Ideally one CA cert.

I'm asking because endpoints are typically only host:port, without the protocol part, using TLS by default.

The exporter also accepts localhost:9200, but I'm not sure if TLS will be automatically enabled or disabled by default. I assume the client library will expand this to http://localhost:9200 if tls is not explicitely configured.

I took otlphttpexporter as example, which also uses a full URL in its example:

exporters:
  otlphttp:
    endpoint: https://example.com:55681/v1/traces

same for zipkin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bogdandrutu ^

Interesting, the one from OTLP should have been named URL then, instead of Endpoint. Looks good to me then!

jpkrohling
jpkrohling previously approved these changes Feb 16, 2021
Comment on lines 44 to 45
// Workers configures the number of workers publishing bulk requests.
Workers int `mapstructure:"workers"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider "num_workers" to be consistent with NumConsumers in our sending_queue helper.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
Done

Comment on lines 137 to 138
// Max configures how often an HTTP request is retried before it is assumed to be failed.
Max int `mapstructure:"max"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MaxRequests? If I were to add this to https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/exporterhelper/queued_retry.go#L58 that would probably be a more consistent name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Updated field name and configuration name to max_requests.

Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One typo in the doc. Other than that, LGTM.

@@ -10,7 +10,7 @@ This exporter supports sending OpenTelemetry logs to [Elasticsearch](https://www
[ID](https://www.elastic.co/guide/en/cloud/current/ec-cloud-id.html) of the
Elastic Cloud Cluster to publish events to. The `cloudid` can be used instead
of `endpoints`.
- `workers` (optional): Number of workers publishing bulk requests concurrently.
- `nuym_workers` (optional): Number of workers publishing bulk requests concurrently.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `nuym_workers` (optional): Number of workers publishing bulk requests concurrently.
- `num_workers` (optional): Number of workers publishing bulk requests concurrently.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thank you.

@jpkrohling jpkrohling dismissed their stale review February 18, 2021 09:55

Typo in the doc

@bogdandrutu bogdandrutu merged commit b5500c8 into open-telemetry:main Feb 18, 2021
@urso urso deleted the init-elasticssearch-exporter branch February 21, 2021 13:40
kisieland referenced this pull request in kisieland/opentelemetry-collector-contrib Mar 16, 2021
* fixing flaky deb package job

* using waitgroup instead of sleep

* moving wait in the same line as docker cp

Co-authored-by: Azfaar Qureshi <[email protected]>
pmatyjasek-sumo referenced this pull request 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
ljmsc referenced this pull request in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
jpkrohling pushed a commit that referenced this pull request Jul 8, 2024
**Description:**

Remove exporter/elasticsearch config fields & mentions in the README.
Nothing has ever used this config.
They were added in
#2324,
but were not used.

If one _were_ to add fields to all documents, then I think that should
be done with a processor.

**Link to tracking Issue:**

N/A

**Testing:**

N/A

**Documentation:**

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

Successfully merging this pull request may close these issues.

4 participants