Skip to content

Commit 76b06ef

Browse files
authored
Add examples and reorder some processor configurations in schemas (#5216)
* update schemas according to review Signed-off-by: Katherine Shen <katshen@amazon.com> * fix build Signed-off-by: Katherine Shen <katshen@amazon.com> --------- Signed-off-by: Katherine Shen <katshen@amazon.com>
1 parent 539d599 commit 76b06ef

15 files changed

Lines changed: 63 additions & 60 deletions

File tree

data-prepper-plugins/csv-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/csv/CsvProcessorConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class CsvProcessorConfig {
3737
@JsonPropertyDescription("The character separating each column. Default value is <code>,</code>.")
3838
private String delimiter = DEFAULT_DELIMITER;
3939

40-
@JsonProperty("delete_header")
40+
@JsonProperty(value = "delete_header", defaultValue = "true")
4141
@JsonPropertyDescription("If specified, the event header (<code>column_names_source_key</code>) is deleted after the event " +
4242
"is parsed. If there is no event header, no action is taken. Default value is true.")
4343
private Boolean deleteHeader = DEFAULT_DELETE_HEADERS;
@@ -68,6 +68,10 @@ public class CsvProcessorConfig {
6868
})
6969
private List<String> columnNames;
7070

71+
@JsonPropertyDescription("If true, the configured source field will be deleted after the CSV data is parsed into separate fields.")
72+
@JsonProperty
73+
private boolean deleteSource = false;
74+
7175
@JsonProperty("csv_when")
7276
@JsonPropertyDescription("A <a href=\"https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/\">conditional expression</a> such as <code>/some_key == \"test\"</code>. " +
7377
"If specified, the <code>csv</code> processor will only run on events when the expression evaluates to true. ")
@@ -76,10 +80,6 @@ public class CsvProcessorConfig {
7680
})
7781
private String csvWhen;
7882

79-
@JsonPropertyDescription("If true, the configured source field will be deleted after the CSV data is parsed into separate fields.")
80-
@JsonProperty
81-
private boolean deleteSource = false;
82-
8383
/**
8484
* The field of the Event that contains the CSV data to be processed.
8585
*

data-prepper-plugins/date-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/date/DateProcessorConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ public static boolean isValidPattern(final String pattern) {
198198
@JsonProperty("date_when")
199199
@JsonPropertyDescription("Specifies under what condition the <code>date</code> processor should perform matching. " +
200200
"Default is no condition.")
201+
@ExampleValues({
202+
@Example(value = "/some_key == null", description = "Only runs the date processor on the Event if some_key is null or doesn't exist.")
203+
})
201204
private String dateWhen;
202205

203206
@JsonIgnore

data-prepper-plugins/decompress-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/decompress/DecompressProcessorConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public class DecompressProcessorConfig {
3333
@JsonPropertyDescription("The type of decompression to use for the keys in the event. Only <code>gzip</code> is supported.")
3434
@JsonProperty("type")
3535
@NotNull
36+
@ExampleValues({
37+
@Example(value = "gzip", description = "GZIP decompression.")
38+
})
3639
private DecompressionType decompressionType;
3740

3841
@JsonPropertyDescription("A list of strings with which to tag events when the processor fails to decompress the keys inside an event. Defaults to <code>_decompression_failure</code>.")

data-prepper-plugins/grok-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/grok/GrokProcessorConfig.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ public class GrokProcessorConfig {
114114

115115
@JsonProperty(TAGS_ON_TIMEOUT)
116116
@JsonPropertyDescription("The tags to add to the event metadata if the grok match times out.")
117-
@ExampleValues({
118-
@Example(value = "_timeout", description = "Events are tagged with this string if grok match times out.")
119-
})
120117
private List<String> tagsOnTimeout = Collections.emptyList();
121118

119+
@JsonProperty(INCLUDE_PERFORMANCE_METADATA)
120+
@JsonPropertyDescription("A boolean value to determine whether to include performance metadata into event metadata. " +
121+
"If set to true, the events coming out of grok will have new fields such as <code>_total_grok_patterns_attempted</code> and <code>_total_grok_processing_time</code>." +
122+
"You can use this metadata to perform performance testing and tuning of your grok patterns. By default, it is not included.")
123+
private boolean includePerformanceMetadata = false;
124+
122125
@JsonProperty(GROK_WHEN)
123126
@ExampleValues({
124127
@Example(value = "/type == \"ipv4\"", description = "When the IP type is IPV4, the processor will perform matching.")
@@ -127,12 +130,6 @@ public class GrokProcessorConfig {
127130
"If specified, the <code>grok</code> processor will only run on events when the expression evaluates to true. ")
128131
private String grokWhen;
129132

130-
@JsonProperty(INCLUDE_PERFORMANCE_METADATA)
131-
@JsonPropertyDescription("A boolean value to determine whether to include performance metadata into event metadata. " +
132-
"If set to true, the events coming out of grok will have new fields such as <code>_total_grok_patterns_attempted</code> and <code>_total_grok_processing_time</code>." +
133-
"You can use this metadata to perform performance testing and tuning of your grok patterns. By default, it is not included.")
134-
private boolean includePerformanceMetadata = false;
135-
136133
public boolean isBreakOnMatch() {
137134
return breakOnMatch;
138135
}

data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/AddEntryProcessorConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class AddEntryProcessorConfig {
6666
public static class Entry {
6767
@JsonPropertyDescription("The key of the new entry to be added. Some examples of keys include <code>my_key</code>, " +
6868
"<code>myKey</code>, and <code>object/sub_Key</code>. The key can also be a format expression, for example, <code>${/key1}</code> to " +
69-
"use the value of field <code>key1</code> as the key.")
69+
"use the value of field <code>key1</code> as the key. Either one of <code>key</code> or <code>metadata_key</code> is required.")
7070
@AlsoRequired(values = {
7171
@AlsoRequired.Required(name=METADATA_KEY_KEY, allowedValues = {"null"})
7272
})

data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/ConvertEntryTypeProcessorConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ public class ConvertEntryTypeProcessorConfig implements ConverterArguments {
3838
static final String KEYS_KEY = "keys";
3939

4040
@JsonProperty(KEY_KEY)
41-
@JsonPropertyDescription("Key whose value needs to be converted to a different type.")
41+
@JsonPropertyDescription("Key whose value needs to be converted to a different type. Cannot be declared at the same time as <code>keys</code>.")
4242
@AlsoRequired(values = {
4343
@AlsoRequired.Required(name = KEYS_KEY, allowedValues = {"null"})
4444
})
4545
private String key;
4646

4747
@JsonProperty(KEYS_KEY)
48-
@JsonPropertyDescription("List of keys whose values needs to be converted to a different type.")
48+
@JsonPropertyDescription("List of keys whose values needs to be converted to a different type. Cannot be declared at the same time as <code>key</code>.")
4949
@AlsoRequired(values = {
5050
@AlsoRequired.Required(name = KEY_KEY, allowedValues = {"null"})
5151
})

data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/CopyValueProcessorConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ public Entry() {
8686
private List<Entry> entries;
8787

8888
@JsonProperty(FROM_LIST_KEY)
89-
@JsonPropertyDescription("The key of the list of objects to be copied.")
89+
@JsonPropertyDescription("The key of the list of objects to be copied. <code>to_list</code> must also be defined.")
9090
@AlsoRequired(values = {
9191
@AlsoRequired.Required(name = TO_LIST_KEY)
9292
})
9393
private String fromList;
9494

9595
@JsonProperty(TO_LIST_KEY)
96-
@JsonPropertyDescription("The key of the new list to be added.")
96+
@JsonPropertyDescription("The key of the new list to be added. <code>from_list</code> must also be defined.")
9797
@AlsoRequired(values = {
9898
@AlsoRequired.Required(name = FROM_LIST_KEY)
9999
})

data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/ListToMapProcessorConfig.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public String getOptionValue() {
102102
private boolean extractValue = false;
103103

104104
@NotNull
105-
@JsonProperty("flatten")
105+
@JsonProperty(value = "flatten", defaultValue = "false")
106106
@JsonPropertyDescription("When <code>true</code>, values in the generated map output flatten into single items based on " +
107107
"the <code>flattened_element</code>. Otherwise, objects mapped to values from the generated map appear as lists. " +
108108
"Default is <code>false</code>.")
@@ -121,6 +121,9 @@ public String getOptionValue() {
121121
@JsonPropertyDescription("A <a href=\"https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/\">conditional expression</a>, " +
122122
"such as <code>/some-key == \"test\"</code>, that will be evaluated to determine whether the processor will be " +
123123
"run on the event. By default, all events will be processed unless otherwise stated.")
124+
@ExampleValues({
125+
@Example(value = "/some-key == \"test\"", description = "The operation will run when the value of the key is 'test'.")
126+
})
124127
private String listToMapWhen;
125128

126129
public String getSource() {

data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/MapToListProcessorConfig.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,10 @@ public class MapToListProcessorConfig {
6565
@JsonProperty("exclude_keys")
6666
@JsonPropertyDescription("The keys in the source map that will be excluded from processing. Default is an " +
6767
"empty list (<code>[]</code>).")
68-
@ExampleValues({
69-
@Example(value = "[\"key1\"]", description = "When the key is 'key1', the processor will not include this key-value pair in the list and will leave it in the map.")
70-
})
7168
private List<String> excludeKeys = DEFAULT_EXCLUDE_KEYS;
7269

7370
@JsonProperty("tags_on_failure")
7471
@JsonPropertyDescription("A list of tags to add to the event metadata when the event fails to process.")
75-
@ExampleValues({
76-
@Example(value = "[\"_failure\"]", description = "{\"tags\": [\"_failure\"]} will be added to the event’s metadata in the event of a processing failure.")
77-
})
7872
private List<String> tagsOnFailure;
7973

8074
@JsonProperty("map_to_list_when")

data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/RenameKeyProcessorConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public static class Entry {
4343
@JsonProperty(defaultValue = FROM_KEY_REGEX)
4444
@JsonPropertyDescription("The regex pattern of the key of the entry to be renamed. " +
4545
"This field cannot be defined along with <code>from_key</code>.")
46+
@ExampleValues(
47+
@Example(value = "regex", description = "Generic regex string.")
48+
)
4649
@AlsoRequired(values = {
4750
@AlsoRequired.Required(name = FROM_KEY, allowedValues = {"null"})
4851
})

0 commit comments

Comments
 (0)