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

OpenSearch Exporter #23045

Closed

Conversation

MaxKsyunz
Copy link
Contributor

@MaxKsyunz MaxKsyunz commented Jun 2, 2023

Adding collector exporter for OpenSearch. Currently only sends traces to OpenSearch. Supports simple schema for observability.

Here's a demo of it all working together using examples/demo app.

OpenSearch.Otel.Exporter.mp4

References

Resolves #7905.

@github-actions github-actions bot added cmd/configschema configschema command cmd/otelcontribcol otelcontribcol command cmd/oteltestbedcol labels Jun 2, 2023
@atoulme atoulme added the Sponsor Needed New component seeking sponsor label Jun 2, 2023
MaxKsyunz and others added 5 commits June 2, 2023 13:51
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
MaxKsyunz added 2 commits June 3, 2023 02:57
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 5, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@MaxKsyunz MaxKsyunz changed the title [WIP] OpenSearch Exporter OpenSearch Exporter Jun 8, 2023
// encodeModel tries to keep the event as close to the original open telemetry semantics as is.
// No fields will be mapped by default.
//
// Field deduplication and dedotting of attributes is supported by the encodeModel.
Copy link
Contributor

Choose a reason for hiding this comment

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

What is dedotting?

Choose a reason for hiding this comment

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

Have a look at exporter/opensearchexporter/internal/objmodel/objmodel.go. This explains a lot about it. In short, this is something, that is required for OpenSearch due to its interpretation of dots in field names (keys).

Copy link

@KarstenSchnitter KarstenSchnitter left a comment

Choose a reason for hiding this comment

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

Thanks for this great contribution. It seems you have implemented traces and logs. Can you adjust the README.md to reflect this?

I am concerned about the compatibility between the data generated with this exporter when compared with using DataPrepper for the same job. There is real nice support for traces in OpenSearch Dashboards with the observability plugin, which builds on the data model provided by DataPrepper. Will this be useable with the OpenTelemetry OpenSearch exporter as well?

A particular feature of the DataPrepper approach we like, is the common handling of attributes and resource attributes, which can be shared between traces and logs. Having the name schema allows to create dashboards and visualisations in OpenSearch feeding from different indices for logs, traces, and metrics utilising common filters. This should also be able with the exported of this PR. As I understand it, the different naming schemes will render indices created by the OpenTelemetry Collector and DataPrepper incompatible with regards to filtering, e.g. by trace id or service name. Can this be improved?

- `traces_index`: The
[index](https://opensearch.org/docs/latest/opensearch/index-data/)
or [datastream](https://opensearch.org/docs/latest/opensearch/data-streams/)
name to publish trace events to. The default value is `traces-generic-default`. Note: To better differentiate between log indexes and traces indexes, `index` option are deprecated and replaced with below `logs_index`

Choose a reason for hiding this comment

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

Why does this not point to otel-v1-apm-span-000001 or similar, which would be used by DataPrepper to provide data for the OpenSearch Observability Trace plugin? Is there some kind of incompatibility between the data?

Copy link
Contributor

Choose a reason for hiding this comment

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

data-prepper is currently also undergoing the movement to data-stream so that both ingestion concepts would use the same mechanism

In addition the catalog repository recently added enables the consolidation and sharing of knowledge and physical mapping for all the plugins across the org

| Status | |
| ------------------------ |---------------|
| Stability | [development] |
| Supported pipeline types | traces |

Choose a reason for hiding this comment

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

The example below contains a configuration for logs besides the traces pipeline. How does this relate to this field, which states, that only traces is supported?

- `read_buffer_size` (default=0): Read buffer size.
- `write_buffer_size` (default=0): Write buffer size used when.
- `timeout` (default=90s): HTTP request time limit.
- `headers` (optional): Headers to be send with each HTTP request.

Choose a reason for hiding this comment

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

Does the exported use compression, e.g. gzip, by default? Can this be added as a setting?


// Headers allows users to configure optional HTTP headers that
// will be send with each HTTP request.
Headers map[string]string `mapstructure:"headers,omitempty"`

Choose a reason for hiding this comment

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

Wouldn't it be better to use a secure string for the header values, as they could contain sensitive information similar to the password of the AuthenticationSettings?

Comment on lines 32 to 33
- `mapping`: Events are encoded to JSON. The `mapping` allows users to
configure additional mapping rules.

Choose a reason for hiding this comment

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

Config validation looks for particular values none, no, and sso. Can you add documentation for these values, so that it is clear, what they mean?

},
want: Document{[]field{{"a", IntValue(1)}, {"z", IntValue(26)}}},
},
"sorting is stable": {

Choose a reason for hiding this comment

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

Is this a required quality, as long as the sorting provides the same result given the same input?

// encodeModel tries to keep the event as close to the original open telemetry semantics as is.
// No fields will be mapped by default.
//
// Field deduplication and dedotting of attributes is supported by the encodeModel.

Choose a reason for hiding this comment

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

Have a look at exporter/opensearchexporter/internal/objmodel/objmodel.go. This explains a lot about it. In short, this is something, that is required for OpenSearch due to its interpretation of dots in field names (keys).

Comment on lines 65 to 75
document.AddTimestamp("@timestamp", span.StartTimestamp()) // We use @timestamp in order to ensure that we can index if the default data stream logs template is used.
document.AddTimestamp("EndTimestamp", span.EndTimestamp())
document.AddTraceID("TraceId", span.TraceID())
document.AddSpanID("SpanId", span.SpanID())
document.AddSpanID("ParentSpanId", span.ParentSpanID())
document.AddString("Name", span.Name())
document.AddString("Kind", traceutil.SpanKindStr(span.Kind()))
document.AddInt("TraceStatus", int64(span.Status().Code()))
document.AddString("Link", spanLinksToString(span.Links()))
document.AddAttributes("Attributes", span.Attributes())
document.AddAttributes("Resource", resource.Attributes())

Choose a reason for hiding this comment

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

This looks very different to the structure DataPrepper would generate. This is important, since the OpenSearch Observability Trace Analytics build on that data model. Here is an example from an OpenSearch index:

"_source": {
    "kind": "SPAN_KIND_INTERNAL",
    "traceId": "eaa69f00b4ab63fd618eadffb00e60d7",
    "spanId": "75d7d735cb2b4972",
    "parentSpanId": "84f4ad4086932693",
    "traceState": "",
    "traceGroup": null,
    "serviceName": "sample",
    "name": "LogController.generateLog",
    "startTime": "2023-06-09T14:32:34.444486691Z",
    "endTime": "2023-06-09T14:32:34.446411315Z",
    "durationInNanos": 1924624,
    "status.code": 0,
    "events": [],
    "droppedEventsCount": 0,
    "traceGroupFields": {
      "endTime": null,
      "durationInNanos": null,
      "statusCode": null
    },
    "links": [],
    "droppedLinksCount": 0,
    "instrumentationScope.version": "1.25.0-alpha",
    "instrumentationScope.name": "io.opentelemetry.spring-webmvc-3.1",
    "resource.attributes.process@pid": 7,
    "resource.attributes.host@arch": "amd64",
    "resource.attributes.telemetry@sdk@version": "1.25.0",
    "resource.attributes.service@name": "sample",
    "resource.attributes.process@runtime@name": "Java(TM) SE Runtime Environment",
    "resource.attributes.os@type": "linux",
    "resource.attributes.telemetry@sdk@language": "java",
    "resource.attributes.host@name": "18232480-822d-40e2-5ded-ebb2",
    "resource.attributes.process@runtime@version": "8.1.094",
    "resource.attributes.telemetry@sdk@name": "opentelemetry",
    "resource.attributes.telemetry@auto@version": "1.25.0",
    "resource.attributes.os@description": "Linux 5.19.0-41-generic",
    "span.attributes.thread@id": 36,
    "span.attributes.thread@name": "http-nio-8080-exec-8",
    "droppedAttributesCount": 0
  }

How does the two naming schemes align in OpenSearch. Is there already support for both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KarstenSchnitter yes this was based on the elastic exporter. I will be changing the schema shortly.

Choose a reason for hiding this comment

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

@KarstenSchnitter could you please open a DataPrepper issue to make any necessary changes?

Choose a reason for hiding this comment

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

@kkondaka what would be the concrete changes required in DataPrepper? It is not clear to me, what naming would be preferable. Some are just capitalization, some are specific to DataPrepper (extra serviceName and traceGroup) and others dilute understanding of the original OTel fields like @timestamp and TraceStatus (to a lesser extend). Attributes is in plural, where Link and Resource are not.

I would prefer to not change the names in DataPrepper, since we use it in production. If this is necessary for alignment between the two tools, so be it.

Choose a reason for hiding this comment

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

@KarstenSchnitter we definitely do not want to make any changes that would break any existing deployment. We may want to add new fields and slowly deprecate old ones


case resp.Status == 0 && err != nil:
// Encoding error. We didn't even attempt to send the event
logger.Error("Drop docs: failed to add docs to the bulk request buffer.",

Choose a reason for hiding this comment

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

I am not sure on the severity of dropped docs. Since the collector remains running and connecting to OpenSearch, I would see this with a lower severity. My thinking is, that dropping some of the docs is less severe as dropping all of them due to misconfiguration or network partition. Especially indexing errors (further down) can occur due to conflicts within a particular document.

Choose a reason for hiding this comment

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

Does this instrumentation expose metrics on the number of dropped docs? This would really help observability of the Collector.

return multierr.Combine(errs...)
}

func (e *opensearchTracesExporter) pushTraceRecord(ctx context.Context, resource pcommon.Resource, span ptrace.Span) error {

Choose a reason for hiding this comment

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

Do you plan adding support for service maps as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Service map is not planned currently in this exporter - we are thinking of using the existing OTEL contribute service graph processor and consolidate that functionality with data prepper

@jpkrohling
Copy link
Member

Note that this component has NOT been accepted yet. There are no sponsors for this component. Until you find an sponsor who can commit to review and co-own this component, this is not going to be accepted.

#7905 (comment)

MaxKsyunz added 3 commits June 12, 2023 18:59
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
…porter

Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>

# Conflicts:
#	cmd/otelcontribcol/builder-config.yaml
#	cmd/otelcontribcol/go.mod
#	cmd/otelcontribcol/go.sum
#	cmd/oteltestbedcol/builder-config.yaml
#	cmd/oteltestbedcol/go.mod
#	cmd/oteltestbedcol/go.sum
@MaxKsyunz
Copy link
Contributor Author

Note that this component has NOT been accepted yet. There are no sponsors for this component. Until you find an sponsor who can commit to review and co-own this component, this is not going to be accepted.

#7905 (comment)

Yes, very true.

How can I get in touch with maintainer group to begin looking for a sponsor?

@MaxKsyunz
Copy link
Contributor Author

Thanks for this great contribution. It seems you have implemented traces and logs. Can you adjust the README.md to reflect this?

I am concerned about the compatibility between the data generated with this exporter when compared with using DataPrepper for the same job. There is real nice support for traces in OpenSearch Dashboards with the observability plugin, which builds on the data model provided by DataPrepper. Will this be useable with the OpenTelemetry OpenSearch exporter as well?

A particular feature of the DataPrepper approach we like, is the common handling of attributes and resource attributes, which can be shared between traces and logs. Having the name schema allows to create dashboards and visualisations in OpenSearch feeding from different indices for logs, traces, and metrics utilising common filters. This should also be able with the exported of this PR. As I understand it, the different naming schemes will render indices created by the OpenTelemetry Collector and DataPrepper incompatible with regards to filtering, e.g. by trace id or service name. Can this be improved?

Thank you for a thorough review @KarstenSchnitter.

Yes, this schema is odd -- I'll replace it shortly. FWIW I started with it because that's what elasticsearchexporter emits.

The end-goal of this PR is to export otel signals to OpenSearch in a schema compatible with OpenTelemetry standard. The specific schema is here.

This is part of a larger effort to improve OpenSearch Observability plugin. See here for details.

switch candidate {
case "none":
case "no":
case "sso":

Choose a reason for hiding this comment

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

We changed the naming convention from SSO to SS4O to avoid confusion with single sign on, can we change all the references to SS4O?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, coming up.

Copy link
Contributor

@YANG-DB YANG-DB Jun 13, 2023

Choose a reason for hiding this comment

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

@MaxKsyunz plz update to the current location of the Observability mapping schema

MaxKsyunz added 5 commits June 13, 2023 10:50
…porter

# Conflicts:
#	cmd/otelcontribcol/go.mod
#	cmd/otelcontribcol/go.sum
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
@YANG-DB
Copy link
Contributor

YANG-DB commented Jun 17, 2023

@KarstenSchnitter has raised many important concerns regarding compatibility between simple schema and data-prepper traces.

Recently @kkondaka and myself worked together for data-prepper & SimpleSchema to share the same structure for Metrics (this has already been released in the latest data-prepper version).
We are very much in favour of following this process for traces as well, since traces was completed prior to simple schema arriving there are few (minor) differences that we will consolidate in the next versions.

Regarding logs - the recent announcement by OTEL and ECS for converging both protocols into one is a large step forward that we at OpenSearch would very much like to adopt. This is why we are currently postponing the Logs support in the exporter until OpenTelemetry will release the first stable version we can reference and follow.

This will be probably true for data-prepper as well and therefore I think we need to continue our current work on traces and wait for the consolidated logs protocol to be published.

Regarding Observability-Dashboards and trace analytics dialog - we are adding support for custom selection of trace index source so that the user can select the source of the trace data.

Since there is already a large overlap between data-prepper and simple schema - they both would work similarly

@jpkrohling
Copy link
Member

This is why we are currently postponing the Logs support in the exporter until OpenTelemetry will release the first stable version we can reference and follow.

Isn't the ECS merger only about semantic conventions? I think that work has completed already.

@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 Jul 12, 2023
@MaxKsyunz
Copy link
Contributor Author

Continued in separate PRs as per contributor guidelines.

@MaxKsyunz MaxKsyunz closed this Jul 12, 2023
codeboten pushed a commit that referenced this pull request Jul 21, 2023
Adding initial set-up for OpenSearch exporter addition. Future PRs will
include adding functionality to the exporter, code coverage and e2e
tests.

Broken up for easier review.

[New component
proposal.](#23611)

Start of resolution of
#7905.

Will come in future PR to 80+% coverage.


Break-up of
#23045

---------

Signed-off-by: Max Ksyunz <max.ksyunz@improving.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd/configschema configschema command cmd/otelcontribcol otelcontribcol command cmd/oteltestbedcol Sponsor Needed New component seeking sponsor Stale testbed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenSearch exporter support
8 participants