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

Add DLQ support to CloudWatchLogs sink #5542

Merged
merged 3 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@


import com.fasterxml.jackson.annotation.JsonIgnore;
import org.opensearch.dataprepper.model.event.EventHandle;
import org.apache.commons.lang3.StringUtils;
import org.opensearch.dataprepper.model.event.EventHandle;
import org.opensearch.dataprepper.model.configuration.PluginSetting;

import java.time.Instant;
import java.time.ZoneId;
Expand Down Expand Up @@ -122,6 +122,16 @@ public String toString() {
'}';
}

public static DlqObject createDlqObject(PluginSetting pluginSetting, EventHandle eventHandle, Object failedData) {
return DlqObject.builder()
.withEventHandle(eventHandle)
.withFailedData(failedData)
.withPluginName(pluginSetting.getName())
.withPipelineName(pluginSetting.getPipelineName())
.withPluginId(pluginSetting.getName())
.build();
}

public static Builder builder() {
return new Builder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.dataprepper.model.failures;

import org.opensearch.dataprepper.model.configuration.PluginSetting;
import org.opensearch.dataprepper.model.event.EventHandle;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
Expand All @@ -18,6 +19,8 @@
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

import java.util.HashMap;
import java.util.Map;
import static java.util.UUID.randomUUID;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
Expand All @@ -31,6 +34,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
import static org.mockito.ArgumentMatchers.any;

public class DlqObjectTest {
Expand Down Expand Up @@ -119,6 +123,24 @@ public void test_invalid_failedData() {
failedData = null;
assertThrows(NullPointerException.class, this::createTestObject);
}

@Test
public void test_createDlqObject() {
final String testName = randomUUID().toString();
final String testPipelineName = randomUUID().toString();
PluginSetting pluginSetting = mock(PluginSetting.class);
when(pluginSetting.getName()).thenReturn(testName);
when(pluginSetting.getPipelineName()).thenReturn(testPipelineName);
eventHandle = mock(EventHandle.class);
Map<String, Object> data = new HashMap<>();
DlqObject dlqObject = DlqObject.createDlqObject(pluginSetting, eventHandle, data);
assertThat(dlqObject, is(notNullValue()));
assertThat(dlqObject.getEventHandle(), is(eventHandle));
assertThat(dlqObject.getFailedData(), is(data));
assertThat(dlqObject.getPluginName(), is(testName));
assertThat(dlqObject.getPipelineName(), is(testPipelineName));

}
}

@Nested
Expand Down
3 changes: 3 additions & 0 deletions data-prepper-plugins/cloudwatch-logs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ configurations {
dependencies {
implementation project(':data-prepper-plugins:aws-plugin-api')
implementation project(path: ':data-prepper-plugins:common')
implementation project(path: ':data-prepper-plugins:failures-common')
implementation 'io.micrometer:micrometer-core'
implementation 'com.fasterxml.jackson.core:jackson-core'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
implementation 'software.amazon.awssdk:cloudwatch'
implementation 'software.amazon.awssdk:cloudwatchlogs'
implementation 'software.amazon.awssdk:s3'
implementation libs.commons.lang3
implementation 'org.projectlombok:lombok:1.18.26'
implementation 'org.hibernate.validator:hibernate-validator:8.0.0.Final'
Expand Down Expand Up @@ -66,6 +68,7 @@ task integrationTest(type: Test) {
systemProperty 'tests.cloudwatch.log_stream', System.getProperty('tests.cloudwatch.log_stream')
systemProperty 'tests.aws.region', System.getProperty('tests.aws.region')
systemProperty 'tests.aws.role', System.getProperty('tests.aws.role')
systemProperty 'tests.s3.bucket', System.getProperty('tests.s3.bucket')
filter {
includeTestsMatching '*IT'
}
Expand Down
Loading
Loading