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/awss3]: add marshaller for Sumo Logic Installed Collector format #23212

Closed
aboguszewski-sumo opened this issue Jun 7, 2023 · 6 comments
Labels
enhancement New feature or request exporter/awss3

Comments

@aboguszewski-sumo
Copy link
Member

Component(s)

exporter/awss3

Is your feature request related to a problem? Please describe.

We would like to add a marshaller to the S3 exporter that will export the data in the format of deprecated Sumo Logic Installed Collector. An example use case is to send the data to S3 in order to send them to Sumo Logic later when needed.

Describe the solution you'd like

A reasonable solution would be to add an additional config option:

exporters:
  awss3:
    ## default = json
    marshaller: {json, sumologic_ic, ...}

It is already partially supported in the code (see paragraph "additional context").

Describe alternatives you've considered

An alternative would be to use this extension: #28686
However, it's still very early in the development phase and no code has been merged yet, so we can't use it now.

Additional context

Current implementation of the exporter allows to add other marshallers:

func NewMarshaler(mType MarshalerType, logger *zap.Logger) (marshaler, error) {

MarshalerName MarshalerType `mapstructure:"marshaler"`

There is a PoC for logs here: https://github.com/SumoLogic/sumologic-otel-collector/blob/sumo_ic_marshaler/pkg/translator/sumoicmarshaler/sumo_ic_marshaler.go but it will undergo some changes before merging it to contrib repo (adding support for metrics and traces etc.).

@aboguszewski-sumo aboguszewski-sumo added enhancement New feature or request needs triage New item requiring triage labels Jun 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2023

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@ledor473
Copy link
Contributor

ledor473 commented Jun 7, 2023

I was about to file something similar so I'll add my thoughts here.

Currently, the exporter/awss3 only supports OtlpJSON and there's no way to extend it aside from forking it. In comparison, the exporter/kafka is better structured to allow for extending it if you are building your own OTel Collector:

  • It exports the Trace / Metrics / Logs marshaler interfaces so they can be implemented outside of this package:
    // TracesMarshaler marshals traces into Message array.
    type TracesMarshaler interface {
    // Marshal serializes spans into sarama's ProducerMessages
    Marshal(traces ptrace.Traces, topic string) ([]*sarama.ProducerMessage, error)
    // Encoding returns encoding name
    Encoding() string
    }
    // MetricsMarshaler marshals metrics into Message array
    type MetricsMarshaler interface {
    // Marshal serializes metrics into sarama's ProducerMessages
    Marshal(metrics pmetric.Metrics, topic string) ([]*sarama.ProducerMessage, error)
    // Encoding returns encoding name
    Encoding() string
    }
    // LogsMarshaler marshals logs into Message array
    type LogsMarshaler interface {
    // Marshal serializes logs into sarama's ProducerMessages
    Marshal(logs plog.Logs, topic string) ([]*sarama.ProducerMessage, error)
    // Encoding returns encoding name
    Encoding() string
    }
  • It provides a set of default implementation(s) (in the case of awss3 it could likely stay OtlpJSON only for now):
    func NewFactory(options ...FactoryOption) exporter.Factory {
    f := &kafkaExporterFactory{
    tracesMarshalers: tracesMarshalers(),
    metricsMarshalers: metricsMarshalers(),
    logsMarshalers: logsMarshalers(),
    }
  • It provides a way to register other Marshaler that are custom-built:
    // WithTracesMarshalers adds tracesMarshalers.
    func WithTracesMarshalers(tracesMarshalers ...TracesMarshaler) FactoryOption {
    return func(factory *kafkaExporterFactory) {
    for _, marshaler := range tracesMarshalers {
    factory.tracesMarshalers[marshaler.Encoding()] = marshaler
    }
    }
    }
    // WithMetricsMarshalers adds additional metric marshalers to the exporter factory.
    func WithMetricsMarshalers(metricMarshalers ...MetricsMarshaler) FactoryOption {
    return func(factory *kafkaExporterFactory) {
    for _, marshaler := range metricMarshalers {
    factory.metricsMarshalers[marshaler.Encoding()] = marshaler
    }
    }
    }
    // WithLogMarshalers adds additional log marshalers to the exporter factory.
    func WithLogsMarshalers(logsMarshalers ...LogsMarshaler) FactoryOption {
    return func(factory *kafkaExporterFactory) {
    for _, marshaler := range logsMarshalers {
    factory.logsMarshalers[marshaler.Encoding()] = marshaler
    }
    }
    }

These little details make it so we can build a custom Marshaler, instantiate it, and wire it in the existing exporter without changing the exporter's code. I believe this would be the simplest approach while the Encoding Extension is being worked on

@atoulme
Copy link
Contributor

atoulme commented Jun 7, 2023

Sure, this sounds like a valid enhancement. We eventually want to support the encoding extension. See #21152 and #28686

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2023

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

  • needs: Github issue template generation code needs this to generate the corresponding labels.
  • exporter/awss3: @atoulme @pdelewski

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Aug 7, 2023
@aboguszewski-sumo
Copy link
Member Author

Current issue status:
#23649 is ready to merge and covers the "marshaler" part. However, there are some changes needed regarding the path of the uploaded files: we'd like to be able to modify its format. That will probably be addressed in another issue.

mx-psi pushed a commit that referenced this issue Aug 7, 2023
…ctor format (#23649)

**Description:** This PR adds a new marshaller for `awss3` exporter. It
exports logs in the format of Sumo Logic Installed Collector. Metrics
and traces are not supported - creating an exporter for them will result
in an error.
Currently, nested typed (eg. map inside a map) might not be supported
correctly - I have to confirm the IC's behavior with them, but I wanted
to create the PR so that it can be reviewed early.

**Link to tracking Issue:** #23212

**Testing:** Unit tests and manual e2e tests. Some automatic e2e tests
will come later, but they will not be part of this repo, they will be a
test for integrating the ingest with Sumo Logic's backend.

**Documentation:** Readme updated.

---------

Signed-off-by: Katarzyna Kujawa <[email protected]>
Co-authored-by: Katarzyna Kujawa <[email protected]>
@github-actions github-actions bot removed the Stale label Aug 8, 2023
@crobert-1 crobert-1 removed the needs triage New item requiring triage label Sep 13, 2023
@atoulme
Copy link
Contributor

atoulme commented Sep 28, 2023

The PR was merged, the work is done - new issues to follow on encoding. We can close this issue.

@atoulme atoulme closed this as completed Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request exporter/awss3
Projects
None yet
Development

No branches or pull requests

4 participants