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

[exporter/opensearch] Send logs to Opensearch #26475

Merged
merged 13 commits into from
Oct 27, 2023

Conversation

jaehnri
Copy link
Contributor

@jaehnri jaehnri commented Sep 5, 2023

Description:

Implementation of exporter to OpenSearch using opensearch-go library. As of now, this PR was heavily inspired by https://github.com/dbason/opentelemetry-collector-contrib/tree/opensearch-exporter/exporter/opensearchexporter.

By default, requests sent adhere to the OpenSearch Catalog schema for logs, but allows users to export using the Elastic Common Schema as well.

This PR also:

  • enables users to define the bulk_action between create and index
  • enables users to define the logs index without necessarily adhering to the new index naming conventions through the LogsIndex config.

Tracking Issue:

23611

Testing:

Integration

  • Successful round-trip to HTTP endpoint,
  • Permanent error during round-trip,
  • Retryable error response for first request, followed by successful response on retry,
  • Two retriable error responses, followed by successful response on second retry.

Manual

  • Authentication using configtls.TLSSetting (ca_file, cert_file, key_file)
  • Tested in EKS and K3s clusters running opni.

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Sep 28, 2023
@jaehnri jaehnri force-pushed the opensearch-logs-exporter branch 2 times, most recently from 54e12e8 to 59e1793 Compare October 2, 2023 19:30
@jaehnri
Copy link
Contributor Author

jaehnri commented Oct 2, 2023

@Aneurysm9 @bryan-aguilar friendly pinging for review here so the PR isn't closed for inactivity. Thanks!

@bryan-aguilar
Copy link
Contributor

Pinging @MitchellGale @MaxKsyunz @YANG-DB as opensearch exporter codeowners.

@bryan-aguilar
Copy link
Contributor

i have ran the integration tests, please check their success status and respond to any failures.

@jaehnri jaehnri force-pushed the opensearch-logs-exporter branch 2 times, most recently from e714108 to 9001616 Compare October 2, 2023 21:53
@jaehnri
Copy link
Contributor Author

jaehnri commented Oct 2, 2023

There were some issues regarding the changelog that should be addressed now. Can you run them again, please? Thanks!

@mikaylathompson
Copy link

This PR would be extremely useful for our use case as the client in the elasticsearch exporter blocks working with opensearch clusters.

If there's anything I can do to help push this PR across the finish line, please let me know. It looks like it's code complete and the tests are passing.

@sumobrian
Copy link

This PR is exactly what we need to adopt this package for an AWS solutions project. @Aneurysm9 is there anything that is preventing this PR from being merged?

@bryan-aguilar
Copy link
Contributor

This PR is still awaiting approval from code owners @sumobrian

@atoulme
Copy link
Contributor

atoulme commented Oct 22, 2023

Tagging code owners: @Aneurysm9 @MitchellGale @MaxKsyunz @YANG-DB

@YANG-DB
Copy link
Contributor

YANG-DB commented Oct 22, 2023

Thanks for your support
We will push this to get merged ASAP

@jaehnri jaehnri force-pushed the opensearch-logs-exporter branch from 9001616 to cf3ac2c Compare October 23, 2023 10:50
@jaehnri
Copy link
Contributor Author

jaehnri commented Oct 23, 2023

@atoulme @YANG-DB @bryan-aguilar rebased to fix conflicts. It should be good to go now.

@YANG-DB
Copy link
Contributor

YANG-DB commented Oct 23, 2023

@Aneurysm9 - can you please review
Thanks 👍

Copy link
Member

@Aneurysm9 Aneurysm9 left a comment

Choose a reason for hiding this comment

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

I have reviewed primarily for structure and consistency with collector style and expectations. The notes here are not blocking as they do not affect the public API, but should be addressed before moving out of the development stage.

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package opensearchexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter"
Copy link
Member

Choose a reason for hiding this comment

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

Nothing here is exported, which is a good thing. Please consider moving this to an internal package to minimize the likelihood of accidental changes to visibility increasing the public API surface area.

return exporterhelper.NewLogsExporter(ctx, set, cfg,
le.pushLogData,
exporterhelper.WithStart(le.Start),
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: true}),
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary? If the exporter can avoid mutating data it can save a copy operation if it is used in a pipeline with multiple exporters.

// Ingest Node is used. But either way, we try to present only well formed
// document to OpenSearch.

// nolint:errcheck
Copy link
Member

Choose a reason for hiding this comment

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

Can this be scoped to specific statements? Even if that requires duplication it's preferable to not allowing further unchecked errors to be introduced without discussion.

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package opensearchexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opensearchexporter"
Copy link
Member

Choose a reason for hiding this comment

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

This may also be a candidate for moving to an internal package.

Links []ssoSpanLinks `json:"links,omitempty"`
Name string `json:"name"`
ParentSpanID string `json:"parentSpanId"`
Resource map[string]string `json:"resource,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Resource attributes can be more than just strings. How does this handle non-string-valued resource attributes?

@Aneurysm9 Aneurysm9 added the ready to merge Code review completed; ready to merge by maintainers label Oct 23, 2023
@jaehnri
Copy link
Contributor Author

jaehnri commented Oct 24, 2023

For note: I will address the comments in another PR, including a refactor in the bulk indexer structure.

@YANG-DB
Copy link
Contributor

YANG-DB commented Oct 26, 2023

Hi
Since the PR is labeled ready for merge - does it need another manual signoff or is it merged automatically??

@bryan-aguilar
Copy link
Contributor

An @open-telemetry/collector-contrib-maintainer will come by and merge it when they get a chance. It is not done automatically.

@bryan-aguilar
Copy link
Contributor

@jaehnri, please address merge conflicts though as that will prevent a maintainer from merging it in.

jaehnri and others added 12 commits October 26, 2023 20:31
@jaehnri jaehnri force-pushed the opensearch-logs-exporter branch from 1d2d4a9 to 85b840c Compare October 26, 2023 23:32
@jaehnri
Copy link
Contributor Author

jaehnri commented Oct 26, 2023

@bryan-aguilar, done it.

@mx-psi
Copy link
Member

mx-psi commented Oct 27, 2023

I have reviewed primarily for structure and consistency with collector style and expectations. The notes here are not blocking as they do not affect the public API, but should be addressed before moving out of the development stage.

@jaehnri can you create a tracking issue for addressing the changes in @Aneurysm9's review? I will merge this now, but please link the issue here once you have created it :)

@mx-psi mx-psi merged commit e8b0e2a into open-telemetry:main Oct 27, 2023
82 checks passed
@github-actions github-actions bot added this to the next release milestone Oct 27, 2023
djaglowski added a commit that referenced this pull request Oct 27, 2023
@jaehnri
Copy link
Contributor Author

jaehnri commented Oct 27, 2023

@mx-psi, here it is: #28666

jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this pull request Nov 12, 2023
## Description: <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
Implementation of exporter to OpenSearch using opensearch-go library. As
of now, this PR was heavily inspired by
https://github.com/dbason/opentelemetry-collector-contrib/tree/opensearch-exporter/exporter/opensearchexporter.

By default, requests sent adhere to the OpenSearch Catalog [schema for
logs](https://github.com/opensearch-project/opensearch-catalog/tree/main/schema/observability/logs),
but allows users to export using the Elastic Common Schema as well.

This PR also:
- enables users to define the `bulk_action` between `create` and `index`
- enables users to define the logs index without necessarily adhering to
the new [index naming
conventions](opensearch-project/observability#1405)
through the `LogsIndex` config.

## Tracking Issue: 


[23611](open-telemetry#23611)

## Testing: <Describe what testing was performed and which tests were
added.>

### Integration
- Successful round-trip to HTTP endpoint,
- Permanent error during round-trip,
- Retryable error response for first request, followed by successful
response on retry,
- Two retriable error responses, followed by successful response on
second retry.

### Manual
- Authentication using `configtls.TLSSetting` (`ca_file`, `cert_file`,
`key_file`)
- Tested in EKS and K3s clusters running
[opni](https://github.com/rancher/opni).

---------

Signed-off-by: João Henri <[email protected]>
Signed-off-by: João Henri <[email protected]>
jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this pull request Nov 12, 2023
RoryCrispin pushed a commit to ClickHouse/opentelemetry-collector-contrib that referenced this pull request Nov 24, 2023
## Description: <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
Implementation of exporter to OpenSearch using opensearch-go library. As
of now, this PR was heavily inspired by
https://github.com/dbason/opentelemetry-collector-contrib/tree/opensearch-exporter/exporter/opensearchexporter.

By default, requests sent adhere to the OpenSearch Catalog [schema for
logs](https://github.com/opensearch-project/opensearch-catalog/tree/main/schema/observability/logs),
but allows users to export using the Elastic Common Schema as well.

This PR also:
- enables users to define the `bulk_action` between `create` and `index`
- enables users to define the logs index without necessarily adhering to
the new [index naming
conventions](opensearch-project/observability#1405)
through the `LogsIndex` config.

## Tracking Issue: 


[23611](open-telemetry#23611)

## Testing: <Describe what testing was performed and which tests were
added.>

### Integration
- Successful round-trip to HTTP endpoint,
- Permanent error during round-trip,
- Retryable error response for first request, followed by successful
response on retry,
- Two retriable error responses, followed by successful response on
second retry.

### Manual
- Authentication using `configtls.TLSSetting` (`ca_file`, `cert_file`,
`key_file`)
- Tested in EKS and K3s clusters running
[opni](https://github.com/rancher/opni).

---------

Signed-off-by: João Henri <[email protected]>
Signed-off-by: João Henri <[email protected]>
RoryCrispin pushed a commit to ClickHouse/opentelemetry-collector-contrib that referenced this pull request Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/opensearch ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants