Skip to content

Commit

Permalink
[exporter/sematext] New component: Sematext Exporter (#37161)
Browse files Browse the repository at this point in the history
#### Description
First PR of New component: Sematext Exporter.

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
#36465

---------

Co-authored-by: Andrzej Stencel <[email protected]>
  • Loading branch information
AkhigbeEromo and andrzej-stencel authored Jan 31, 2025
1 parent 94415c9 commit 24dd011
Show file tree
Hide file tree
Showing 20 changed files with 596 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .chloggen/sematextexporter-new-component.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use this changelog template to create an entry for release notes.
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: new_component
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: exporter/sematext
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add a new component for exporting metrics and logs to Sematext"
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36465]
# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ exporter/prometheusremotewriteexporter/ @open-telemetry
exporter/pulsarexporter/ @open-telemetry/collector-contrib-approvers @dmitryax @dao-jun
exporter/rabbitmqexporter/ @open-telemetry/collector-contrib-approvers @swar8080 @atoulme
exporter/sapmexporter/ @open-telemetry/collector-contrib-approvers @dmitryax @atoulme
exporter/sematextexporter/ @open-telemetry/collector-contrib-approvers @AkhigbeEromo
exporter/sentryexporter/ @open-telemetry/collector-contrib-approvers @AbhiPrasad
exporter/signalfxexporter/ @open-telemetry/collector-contrib-approvers @dmitryax @crobert-1
exporter/splunkhecexporter/ @open-telemetry/collector-contrib-approvers @atoulme @dmitryax
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ body:
- exporter/pulsar
- exporter/rabbitmq
- exporter/sapm
- exporter/sematext
- exporter/sentry
- exporter/signalfx
- exporter/splunkhec
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ body:
- exporter/pulsar
- exporter/rabbitmq
- exporter/sapm
- exporter/sematext
- exporter/sentry
- exporter/signalfx
- exporter/splunkhec
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ body:
- exporter/pulsar
- exporter/rabbitmq
- exporter/sapm
- exporter/sematext
- exporter/sentry
- exporter/signalfx
- exporter/splunkhec
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/unmaintained.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ body:
- exporter/pulsar
- exporter/rabbitmq
- exporter/sapm
- exporter/sematext
- exporter/sentry
- exporter/signalfx
- exporter/splunkhec
Expand Down
1 change: 1 addition & 0 deletions cmd/githubgen/allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
abhishek-at-cloudwerx
AkhigbeEromo
Caleb-Hurshman
cemdk
dlopes7
Expand Down
1 change: 1 addition & 0 deletions exporter/sematextexporter/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
59 changes: 59 additions & 0 deletions exporter/sematextexporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Sematext Exporter
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [development]: metrics, logs |
| Distributions | [] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aexporter%2Fsematext%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aexporter%2Fsematext) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aexporter%2Fsematext%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aexporter%2Fsematext) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@AkhigbeEromo](https://www.github.com/AkhigbeEromo) |

[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development
<!-- end autogenerated section -->

This exporter supports sending metrics to [Sematext Cloud](https://sematext.com/) in Influx line protocol format and logs using the Bulk Index Api format.

## Configuration

The following configuration options are supported:
* `timeout` (default = 5s) Timeout for requests
* `region` Region specifies the Sematext region the user is operating in; must be one of:
* `US`
* `EU`
* `retry_on_failure` [details here](https://github.com/open-telemetry/opentelemetry-collector/blob/v0.25.0/exporter/exporterhelper/README.md#configuration)
* `enabled` (default = true)
* `initial_interval` (default = 5s) Time to wait after the first failure before retrying
* `max_interval` (default = 30s) Upper bound on backoff interval
* `max_elapsed_time` (default = 120s) Maximum amount of time (including retries) spent trying to send a request/batch
* `metrics.app_token` specifies the token of the Sematext Monitoring App to which metrics data will be sent. It must be a valid UUID string in the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. For example: `2046e37c-4fac-45f6-831d-922d43fde759`.
* `logs.app_token` specifies the token of the Sematext Logs App to which logs data will be sent. It must be a valid UUID string in the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. For example: `9604e37c-49ac-49f6-831d-922d43fde759`.
* `metrics.payload_max_lines` (default = 1_000) Maximum number of lines allowed per HTTP POST request
* `metrics.payload_max_bytes` (default = 300_000) Maximum number of bytes allowed per HTTP POST request
* `metrics.metrics_schema` (default = telegraf-prometheus-v2) The chosen metrics schema to write
* `metrics.sending_queue` [details here](https://github.com/open-telemetry/opentelemetry-collector/blob/v0.25.0/exporter/exporterhelper/README.md#configuration)
* `enabled` (default = true)
* `num_consumers` (default = 10) The number of consumers from the queue
* `queue_size` (default = 1000) Maximum number of batches allowed in queue at a given time


The full list of settings exposed for this exporter are documented in [config.go](config.go).

Example:
```yaml
timeout: 500ms
region: US
retry_on_failure:
enabled: true
initial_interval: 1s
max_interval: 3s
max_elapsed_time: 10s
metrics:
app_token: 2064e37c-4fac-45f6-831d-922d43fde759
sending_queue:
enabled: true
num_consumers: 3
queue_size: 10
payload_max_lines: 100
payload_max_bytes: 1000
logs:
app_token: 9064e37c-4gac-49f6-831d-922l43fse759
```
6 changes: 6 additions & 0 deletions exporter/sematextexporter/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package sematextexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sematextexporter"

type Config struct{}
7 changes: 7 additions & 0 deletions exporter/sematextexporter/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

// Package sematextexporter sends metrics and logs to sematext cloud.
package sematextexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sematextexporter"
67 changes: 67 additions & 0 deletions exporter/sematextexporter/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

package sematextexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sematextexporter"

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sematextexporter/internal/metadata"
)

// NewFactory creates a factory for the Sematext metrics exporter.
func NewFactory() exporter.Factory {
return exporter.NewFactory(
metadata.Type,
createDefaultConfig,
exporter.WithMetrics(createMetricsExporter, metadata.MetricsStability),
exporter.WithLogs(createLogsExporter, metadata.LogsStability),
)
}

func createDefaultConfig() component.Config {
cfg := &Config{}
return cfg
}

func createMetricsExporter(
ctx context.Context,
set exporter.Settings,
config component.Config,
) (exporter.Metrics, error) {
cfg := config.(*Config)

return exporterhelper.NewMetrics(
ctx,
set,
cfg,
func(_ context.Context, _ pmetric.Metrics) error {
return nil
},
)
}

func createLogsExporter(
ctx context.Context,
set exporter.Settings,
config component.Config,
) (exporter.Logs, error) {
cfg := config.(*Config)

return exporterhelper.NewLogs(
ctx,
set,
cfg,
func(_ context.Context, _ plog.Logs) error {
return nil
},
)
}
141 changes: 141 additions & 0 deletions exporter/sematextexporter/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions exporter/sematextexporter/generated_package_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 24dd011

Please sign in to comment.