From 2c7c039c51e5386bc435eea9e72fd1d38ca5f84b Mon Sep 17 00:00:00 2001 From: mcube8 Date: Thu, 18 Jan 2024 03:46:09 +0530 Subject: [PATCH] [chore] [exporter/alertmanagerexporter] Add exporter to components (#30230) Add Alertmanager Exporter to Components Third PR - Update buildconfig and components **Link to tracking Issue:** [#23659](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/23569) **Testing:** Unit tests for exporter **Documentation:** Readme and Sample Configs to use Alertmanager exporter --------- Co-authored-by: Alex Boten --- .../alertmanagerexporter_add_builder.yaml | 27 +++++++++++++++++++ cmd/otelcontribcol/builder-config.yaml | 2 ++ cmd/otelcontribcol/components.go | 2 ++ cmd/otelcontribcol/exporters_test.go | 17 ++++++++++++ cmd/otelcontribcol/go.mod | 3 +++ .../generated_component_test.go | 2 -- exporter/alertmanagerexporter/metadata.yaml | 10 ++++++- 7 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 .chloggen/alertmanagerexporter_add_builder.yaml diff --git a/.chloggen/alertmanagerexporter_add_builder.yaml b/.chloggen/alertmanagerexporter_add_builder.yaml new file mode 100644 index 000000000000..87973e2a11c4 --- /dev/null +++ b/.chloggen/alertmanagerexporter_add_builder.yaml @@ -0,0 +1,27 @@ +# 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: alertmanagerexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Add Alertmanager exporter to builder config" + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [23569] + +# (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] \ No newline at end of file diff --git a/cmd/otelcontribcol/builder-config.yaml b/cmd/otelcontribcol/builder-config.yaml index efdc933b97fa..f2292acac7de 100644 --- a/cmd/otelcontribcol/builder-config.yaml +++ b/cmd/otelcontribcol/builder-config.yaml @@ -47,6 +47,7 @@ exporters: - gomod: go.opentelemetry.io/collector/exporter/loggingexporter v0.92.1-0.20240117180253-4371e14440ee - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.92.1-0.20240117180253-4371e14440ee - gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.92.1-0.20240117180253-4371e14440ee + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alertmanagerexporter v0.92.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.92.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.92.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter v0.92.0 @@ -312,6 +313,7 @@ replaces: - github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver => ../../receiver/redisreceiver - github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension => ../../extension/basicauthextension - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/influxdbexporter => ../../exporter/influxdbexporter + - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alertmanagerexporter => ../../exporter/alertmanagerexporter - github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter => ../../exporter/alibabacloudlogserviceexporter - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger => ../../pkg/translator/jaeger - github.com/open-telemetry/opentelemetry-collector-contrib/internal/docker => ../../internal/docker diff --git a/cmd/otelcontribcol/components.go b/cmd/otelcontribcol/components.go index b2a6ca7a6bf7..d7bdbfabc6b0 100644 --- a/cmd/otelcontribcol/components.go +++ b/cmd/otelcontribcol/components.go @@ -26,6 +26,7 @@ import ( routingconnector "github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector" servicegraphconnector "github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector" spanmetricsconnector "github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector" + alertmanagerexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alertmanagerexporter" alibabacloudlogserviceexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter" awscloudwatchlogsexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter" awsemfexporter "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter" @@ -342,6 +343,7 @@ func components() (otelcol.Factories, error) { loggingexporter.NewFactory(), otlpexporter.NewFactory(), otlphttpexporter.NewFactory(), + alertmanagerexporter.NewFactory(), alibabacloudlogserviceexporter.NewFactory(), awscloudwatchlogsexporter.NewFactory(), awsemfexporter.NewFactory(), diff --git a/cmd/otelcontribcol/exporters_test.go b/cmd/otelcontribcol/exporters_test.go index 22a67e4f98aa..c892e1ceff60 100644 --- a/cmd/otelcontribcol/exporters_test.go +++ b/cmd/otelcontribcol/exporters_test.go @@ -21,6 +21,7 @@ import ( "go.opentelemetry.io/collector/exporter/otlpexporter" "go.opentelemetry.io/collector/exporter/otlphttpexporter" + "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alertmanagerexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter" @@ -264,6 +265,22 @@ func TestDefaultExporters(t *testing.T) { }, skipLifecycle: true, }, + { + exporter: "alertmanager", + getConfigFn: func() component.Config { + cfg := expFactories["alertmanager"].CreateDefaultConfig().(*alertmanagerexporter.Config) + cfg.HTTPClientSettings = confighttp.HTTPClientSettings{ + Endpoint: "http://" + endpoint, + } + cfg.GeneratorURL = "opentelemetry-collector" + cfg.DefaultSeverity = "info" + // disable queue/retry to validate passing the test data synchronously + cfg.QueueSettings.Enabled = false + cfg.BackoffConfig.Enabled = false + return cfg + }, + expectConsumeErr: true, + }, { exporter: "alibabacloud_logservice", getConfigFn: func() component.Config { diff --git a/cmd/otelcontribcol/go.mod b/cmd/otelcontribcol/go.mod index f69f6cfaef73..77194e4f465d 100644 --- a/cmd/otelcontribcol/go.mod +++ b/cmd/otelcontribcol/go.mod @@ -11,6 +11,7 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.92.0 github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector v0.92.0 github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.92.0 + github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alertmanagerexporter v0.92.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.92.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter v0.92.0 github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter v0.92.0 @@ -919,6 +920,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/basi replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/influxdbexporter => ../../exporter/influxdbexporter +replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alertmanagerexporter => ../../exporter/alertmanagerexporter + replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter => ../../exporter/alibabacloudlogserviceexporter replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger => ../../pkg/translator/jaeger diff --git a/exporter/alertmanagerexporter/generated_component_test.go b/exporter/alertmanagerexporter/generated_component_test.go index c1db5f9edc71..2c0ed39676a1 100644 --- a/exporter/alertmanagerexporter/generated_component_test.go +++ b/exporter/alertmanagerexporter/generated_component_test.go @@ -100,8 +100,6 @@ func TestComponentLifecycle(t *testing.T) { } }) - assert.NoError(t, err) - err = c.Shutdown(context.Background()) require.NoError(t, err) }) diff --git a/exporter/alertmanagerexporter/metadata.yaml b/exporter/alertmanagerexporter/metadata.yaml index e1f5b45fb52d..2173931ed4c4 100644 --- a/exporter/alertmanagerexporter/metadata.yaml +++ b/exporter/alertmanagerexporter/metadata.yaml @@ -9,4 +9,12 @@ status: active: [jpkrohling, sokoide, mcube8] tests: - config: \ No newline at end of file + config: + endpoint: http://localhost:0 + generator_url: opentelemetry-collector + severity: info + sending_queue: + enabled: false + retry_on_failure: + enabled: false + expect_consumer_error: true \ No newline at end of file