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

Adding defaultValue to the @JsonProperty for processors. #5080

Merged
merged 1 commit into from
Oct 17, 2024
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 @@ -23,7 +23,7 @@
"Then, the processor performs an action on each group, helping reduce unnecessary log volume and " +
"creating aggregated logs over time.")
public class AggregateProcessorConfig {
static int DEFAULT_GROUP_DURATION_SECONDS = 180;
static final int DEFAULT_GROUP_DURATION_SECONDS = 180;

@JsonPropertyDescription("An unordered list by which to group events. Events with the same values as these keys are put into the same group. " +
"If an event does not contain one of the <code>identification_keys</code>, then the value of that key is considered to be equal to <code>null</code>. " +
Expand All @@ -39,7 +39,7 @@ public class AggregateProcessorConfig {
private PluginModel aggregateAction;

@JsonPropertyDescription("The amount of time that a group should exist before it is concluded automatically. Supports ISO_8601 notation strings (\"PT20.345S\", \"PT15M\", etc.) as well as simple notation for seconds (\"60s\") and milliseconds (\"1500ms\"). Default value is 180s.")
@JsonProperty("group_duration")
@JsonProperty(value = "group_duration", defaultValue = DEFAULT_GROUP_DURATION_SECONDS + "s")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need string conversion of DEFAULT_GROUP_DURATION_SECONDS here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value itself is 180s because it is a duration value.

private Duration groupDuration = Duration.ofSeconds(DEFAULT_GROUP_DURATION_SECONDS);

@JsonPropertyDescription("When <code>local_mode</code> is set to true, the aggregation is performed locally on each node instead of forwarding events to a specific node based on the <code>identification_keys</code> using a hash function. Default is false.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ public class CountAggregateActionConfig {

@JsonPropertyDescription("Format of the aggregated event. Specifying <code>otel_metrics</code> outputs aggregate events in OTel metrics SUM type with count as value. " +
"Specifying <code>raw</code> outputs aggregate events as with the <code>count_key</code> field as a count value and includes the <code>start_time_key</code> and <code>end_time_key</code> keys.")
@JsonProperty("output_format")
@JsonProperty(value = "output_format", defaultValue = "otel_metrics")
OutputFormat outputFormat = OutputFormat.OTEL_METRICS;

@JsonPropertyDescription("Metric name to be used when the OTel metrics format is used. The default value is <code>count</code>.")
@JsonProperty("metric_name")
@JsonProperty(value = "metric_name", defaultValue = SUM_METRIC_NAME)
String metricName = SUM_METRIC_NAME;

@JsonPropertyDescription("The key in the aggregate event that will have the count value. " +
"This is the count of events in the aggregation. Default name is <code>aggr._count</code>.")
@JsonProperty("count_key")
@JsonProperty(value = "count_key", defaultValue = DEFAULT_COUNT_KEY)
String countKey = DEFAULT_COUNT_KEY;

@JsonPropertyDescription("The key in the aggregate event that will have the start time of the aggregation. " +
"Default name is <code>aggr._start_time</code>.")
@JsonProperty("start_time_key")
@JsonProperty(value = "start_time_key", defaultValue = DEFAULT_START_TIME_KEY)
String startTimeKey = DEFAULT_START_TIME_KEY;

@JsonPropertyDescription("The key in the aggregate event that will have the end time of the aggregation. " +
"Default name is <code>aggr._end_time</code>.")
@JsonProperty("end_time_key")
@JsonProperty(value = "end_time_key", defaultValue = DEFAULT_END_TIME_KEY)
String endTimeKey = DEFAULT_END_TIME_KEY;

@JsonPropertyDescription("List of unique keys to count.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class HistogramAggregateActionConfig {
String key;

@JsonPropertyDescription("Format of the aggregated event. otel_metrics is the default output format which outputs in OTel metrics SUM type with count as value. Other options is - raw - which generates a JSON object with the count_key field as a count value and the start_time_key field with aggregation start time as value.")
@JsonProperty("output_format")
@JsonProperty(value = "output_format", defaultValue = "otel_metrics")
OutputFormat outputFormat = OutputFormat.OTEL_METRICS;

@JsonPropertyDescription("The name of units for the values in the key. For example, bytes, traces etc")
Expand All @@ -48,11 +48,11 @@ public class HistogramAggregateActionConfig {
String units;

@JsonPropertyDescription("Metric name to be used when otel format is used.")
@JsonProperty("metric_name")
@JsonProperty(value = "metric_name", defaultValue = HISTOGRAM_METRIC_NAME)
String metricName = HISTOGRAM_METRIC_NAME;

@JsonPropertyDescription("Key prefix used by all the fields created in the aggregated event. Having a prefix ensures that the names of the histogram event do not conflict with the field names in the event.")
@JsonProperty("generated_key_prefix")
@JsonProperty(value = "generated_key_prefix", defaultValue = DEFAULT_GENERATED_KEY_PREFIX)
String generatedKeyPrefix = DEFAULT_GENERATED_KEY_PREFIX;

@JsonPropertyDescription("A list of buckets (values of type double) indicating the buckets in the histogram.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class RateLimiterAggregateActionConfig {

@JsonPropertyDescription("Indicates what action the <code>rate_limiter</code> takes when the number of events received is greater than the number of events allowed per second. " +
"Default value is block, which blocks the processor from running after the maximum number of events allowed per second is reached until the next second. Alternatively, the drop option drops the excess events received in that second. Default is block")
@JsonProperty("when_exceeds")
@JsonProperty(value = "when_exceeds", defaultValue = "block")
RateLimiterMode whenExceedsMode = RateLimiterMode.BLOCK;

public int getEventsPerSecond() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public class CsvProcessorConfig {
static final String DEFAULT_QUOTE_CHARACTER = "\""; // double quote
static final Boolean DEFAULT_DELETE_HEADERS = true;

@JsonProperty("source")
@JsonProperty(value = "source", defaultValue = DEFAULT_SOURCE)
@JsonPropertyDescription("The field in the event that will be parsed. Default value is <code>message</code>.")
@NotBlank
private String source = DEFAULT_SOURCE;

@JsonProperty("delimiter")
@JsonProperty(value = "delimiter", defaultValue = DEFAULT_DELIMITER)
@JsonPropertyDescription("The character separating each column. Default value is <code>,</code>.")
private String delimiter = DEFAULT_DELIMITER;

Expand All @@ -40,7 +40,7 @@ public class CsvProcessorConfig {
"is parsed. If there is no event header, no action is taken. Default value is true.")
private Boolean deleteHeader = DEFAULT_DELETE_HEADERS;

@JsonProperty("quote_character")
@JsonProperty(value = "quote_character", defaultValue = DEFAULT_QUOTE_CHARACTER)
@JsonPropertyDescription("The character used as a text qualifier for a single column of data. " +
"Default value is <code>\"</code>.")
private String quoteCharacter = DEFAULT_QUOTE_CHARACTER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ public static boolean isValidPattern(final String pattern) {
"Can be used with both <code>match</code> and <code>from_time_received</code>. Default is <code>@timestamp</code>.")
private String destination = DEFAULT_DESTINATION;

@JsonProperty("output_format")
@JsonPropertyDescription("Determines the format of the timestamp added to an event. " +
"Default is <code>yyyy-MM-dd'T'HH:mm:ss.SSSXXX</code>.")
@JsonProperty(value = "output_format", defaultValue = DEFAULT_OUTPUT_FORMAT)
@JsonPropertyDescription("Determines the format of the timestamp added to an event.")
private String outputFormat = DEFAULT_OUTPUT_FORMAT;

@JsonProperty("to_origination_metadata")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class DropEventProcessorConfig {
private String dropWhen;

@JsonPropertyDescription("Specifies how exceptions are handled when an exception occurs while evaluating an event. Default value is <code>skip</code>, which drops the event so that it is not sent to further processors or sinks.")
@JsonProperty("handle_failed_events")
@JsonProperty(value = "handle_failed_events", defaultValue = "skip")
private HandleFailedEventsOption handleFailedEventsOption = HandleFailedEventsOption.SKIP;

public String getDropWhen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public class EntryConfig {
@NotEmpty
private String source;

@JsonPropertyDescription("The key of the target field in which to set the geolocation data. Default is <code>geo</code>.")
@JsonProperty("target")
@JsonPropertyDescription("The key of the target field in which to set the geolocation data.")
@JsonProperty(value = "target", defaultValue = DEFAULT_TARGET)
private String target = DEFAULT_TARGET;

@JsonPropertyDescription("The list of geolocation fields to include in the target object. By default, this is all the fields provided by the configured databases. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class GrokProcessorConfig {
"<code>pattern_directories</code>. Default is <code>*</code>.")
private String patternsFilesGlob = DEFAULT_PATTERNS_FILES_GLOB;

@JsonProperty(TIMEOUT_MILLIS)
@JsonProperty(value = TIMEOUT_MILLIS, defaultValue = "30000")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to reuse DEFAULT_TIMEOUT_MILLIS in the defaultValue?

@JsonPropertyDescription("The maximum amount of time during which matching occurs. " +
"Setting to <code>0</code> prevents any matching from occurring. Default is <code>30000</code>.")
private int timeoutMillis = DEFAULT_TIMEOUT_MILLIS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ public class KeyValueProcessorConfig {
@JsonPropertyDescription("The source field to parse for key-value pairs. The default value is <code>message</code>.")
private String source = DEFAULT_SOURCE;

@JsonProperty(defaultValue = DEFAULT_DESTINATION)
@JsonPropertyDescription("The destination field for the structured data. The destination will be a structured map with the key value pairs extracted from the source. " +
"If <code>destination</code> is set to <code>null</code>, the parsed fields will be written to the root of the event. " +
"The default value is <code>parsed_message</code>.")
private String destination = DEFAULT_DESTINATION;

@JsonProperty("field_split_characters")
@JsonProperty(value = "field_split_characters", defaultValue = DEFAULT_FIELD_SPLIT_CHARACTERS)
@JsonPropertyDescription("A string of characters specifying the delimiter that separates key-value pairs. " +
"Special regular expression characters such as <code>[</code> and <code>]</code> must be escaped with <code>\\\\</code>. " +
"This field cannot be defined along with <code>field_delimiter_regex</code>. " +
Expand All @@ -55,7 +56,7 @@ public class KeyValueProcessorConfig {
"If this option is not defined, the <code>key_value</code> processor will parse the source using <code>field_split_characters</code>.")
private String fieldDelimiterRegex;

@JsonProperty("value_split_characters")
@JsonProperty(value = "value_split_characters", defaultValue = DEFAULT_VALUE_SPLIT_CHARACTERS)
@JsonPropertyDescription("A string of characters specifying the delimiter that separates keys from their values within a key-value pair. " +
"Special regular expression characters such as <code>[</code> and <code>]</code> must be escaped with <code>\\\\</code>. " +
"This field cannot be defined along with <code>key_value_delimiter_regex</code>. " +
Expand Down Expand Up @@ -137,7 +138,7 @@ public class KeyValueProcessorConfig {
"The default configuration is <code>false</code> which retains those grouping characters.")
private boolean removeBrackets;

@JsonProperty("value_grouping")
@JsonProperty(value = "value_grouping", defaultValue = "false")
@JsonPropertyDescription("Specifies whether to group values using predefined grouping delimiters. " +
"If this flag is enabled, then the content between the delimiters is considered to be one entity and " +
"they are not parsed as key-value pairs. The following characters are used a group delimiters: " +
Expand All @@ -163,13 +164,13 @@ public class KeyValueProcessorConfig {
"when writing parsed fields to the event. Default is <code>true</code>.")
private boolean overwriteIfDestinationExists = true;

@JsonProperty("drop_keys_with_no_value")
@JsonProperty(value = "drop_keys_with_no_value", defaultValue = "false")
@JsonPropertyDescription("Specifies whether keys should be dropped if they have a null value. Default is <code>false</code>. " +
"For example, if <code>drop_keys_with_no_value</code> is set to <code>true</code>, " +
"then <code>{\"key1=value1&amp;key2\"}</code> parses to <code>{\"key1\": \"value1\"}</code>.")
private boolean dropKeysWithNoValue = false;

@JsonProperty("strict_grouping")
@JsonProperty(value = "strict_grouping", defaultValue = "false")
@JsonPropertyDescription("When enabled, groups with unmatched end characters yield errors. " +
"The event is ignored after the errors are logged. " +
"Specifies whether strict grouping should be enabled when the <code>value_grouping</code> " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class ConvertEntryTypeProcessorConfig implements ConverterArguments {
@JsonPropertyDescription("List of keys whose values needs to be converted to a different type.")
private List<String> keys;

@JsonProperty("type")
@JsonPropertyDescription("Target type for the values. Default value is <code>integer.</code>")
@JsonProperty(value = "type", defaultValue = "integer")
@JsonPropertyDescription("Target type for the values. Default value is <code>integer</code>.")
private TargetType type = TargetType.INTEGER;

@JsonProperty("null_values")
Expand All @@ -37,7 +37,7 @@ public class ConvertEntryTypeProcessorConfig implements ConverterArguments {
/**
* Optional scale value used only in the case of BigDecimal converter
*/
@JsonProperty("scale")
@JsonProperty(value = "scale", defaultValue = "0")
@JsonPropertyDescription("Modifies the scale of the <code>big_decimal</code> when converting to a <code>big_decimal</code>. The default value is 0.")
private int scale = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public String getOptionValue() {
private boolean flatten = false;

@NotNull
@JsonProperty("flattened_element")
@JsonProperty(value = "flattened_element", defaultValue = "first")
@JsonPropertyDescription("The element to keep, either <code>first</code> or <code>last</code>, when <code>flatten</code> is set to <code>true</code>.")
private FlattenedElement flattenedElement = FlattenedElement.FIRST;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public class MapToListProcessorConfig {
@JsonPropertyDescription("The target for the generated list.")
private String target;

@JsonProperty("key_name")
@JsonProperty(value = "key_name", defaultValue = DEFAULT_KEY_NAME)
@JsonPropertyDescription("The name of the field in which to store the original key. Default is <code>key</code>.")
private String keyName = DEFAULT_KEY_NAME;

@JsonProperty("value_name")
@JsonProperty(value = "value_name", defaultValue = DEFAULT_VALUE_NAME)
@JsonPropertyDescription("The name of the field in which to store the original value. Default is <code>value</code>.")
private String valueName = DEFAULT_VALUE_NAME;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
@JsonClassDescription("Obfuscates data by masking data. Without any configuration this will replace text with <code>***</code>")
@JsonPropertyOrder
public class MaskActionConfig {
private static final String DEFAULT_MASK_CHARACTER = "*";
private static final int DEFAULT_MASK_LENGTH = 3;

@JsonProperty("mask_character")
@JsonProperty(value = "mask_character", defaultValue = DEFAULT_MASK_CHARACTER)
@Pattern(regexp = "[*#!%&@]", message = "Valid characters are *, #, $, %, &, ! and @")
@JsonPropertyDescription("The character to use to mask text. By default, this is <code>*</code>")
private String maskCharacter = "*";
private String maskCharacter = DEFAULT_MASK_CHARACTER;

@JsonProperty("mask_character_length")
@JsonProperty(value = "mask_character_length", defaultValue = "" + DEFAULT_MASK_LENGTH)
@Min(1)
@Max(10)
@JsonPropertyDescription("The length of the character mask to apply. By default, this is three characters.")
private int maskCharacterLength = 3;
private int maskCharacterLength = DEFAULT_MASK_LENGTH;

public MaskActionConfig() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@JsonPropertyOrder
public class OneWayHashActionConfig {

public static final String DEFAULT_FORMAT = "SHA-512";
@JsonProperty("salt")
@JsonPropertyDescription("Salt value to use when generating hash. If not specified, salt will be randomly generated by the processor.")
@Size(min = 16, message = "Minimum size of salt string is 16.")
Expand All @@ -34,10 +35,10 @@ public class OneWayHashActionConfig {
@EventKeyConfiguration(EventKeyFactory.EventAction.GET)
private EventKey saltKey;

@JsonProperty("format")
@Pattern(regexp = "SHA-512", message = "Valid values: <code>SHA-512</code>")
@JsonProperty(value = "format", defaultValue = DEFAULT_FORMAT)
@Pattern(regexp = DEFAULT_FORMAT, message = "Valid values: <code>SHA-512</code>")
@JsonPropertyDescription("Format of one way hash to generate. Default to <code>SHA-512</code>.")
private String format = "SHA-512";
private String format = DEFAULT_FORMAT;

public OneWayHashActionConfig(){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class OtelMetricsRawProcessorConfig {
@JsonPropertyDescription("Whether or not to calculate exponential histogram buckets. Default value is <code>true</code>.")
private Boolean calculateExponentialHistogramBuckets = true;

@JsonProperty(defaultValue = "" + DEFAULT_EXPONENTIAL_HISTOGRAM_MAX_ALLOWED_SCALE)
@JsonPropertyDescription("Maximum allowed scale in exponential histogram calculation. By default, the maximum allowed scale is <code>10</code>.")
private Integer exponentialHistogramMaxAllowedScale = DEFAULT_EXPONENTIAL_HISTOGRAM_MAX_ALLOWED_SCALE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
public class OTelLogsInputCodecConfig {
static final OTelLogsFormatOption DEFAULT_FORMAT = OTelLogsFormatOption.JSON;

@JsonProperty("format")
@JsonPropertyDescription("Specifies the format of the OTel logs. Default is <code>json</code>.")
@JsonProperty(value = "format", defaultValue = "json")
@JsonPropertyDescription("Specifies the format of the OTel logs.")
@NotNull
private OTelLogsFormatOption format = DEFAULT_FORMAT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ public class OtelTraceRawProcessorConfig {
static final Duration DEFAULT_TRACE_ID_TTL = Duration.ofSeconds(15L);
static final long MAX_TRACE_ID_CACHE_SIZE = 1_000_000L;

@JsonProperty("trace_flush_interval")
@JsonProperty(value = "trace_flush_interval", defaultValue = "180")
@JsonPropertyDescription("Represents the time interval in seconds to flush all the descendant spans without any " +
"root span. Default is <code>180</code>.")
private long traceFlushInterval = DEFAULT_TG_FLUSH_INTERVAL_SEC;

@JsonProperty("trace_group_cache_ttl")
@JsonProperty(value = "trace_group_cache_ttl", defaultValue = "PT15S")
@JsonPropertyDescription("Represents the time-to-live to cache a trace group details. " +
"The value may be an ISO 8601 notation such as <code>PT1M30S</code> or a duration and unit such as <code>45s</code>. " +
"Default is 15 seconds.")
private Duration traceGroupCacheTimeToLive = DEFAULT_TRACE_ID_TTL;

@JsonProperty("trace_group_cache_max_size")
@JsonProperty(value = "trace_group_cache_max_size", defaultValue = "1000000")
@JsonPropertyDescription("Represents the maximum size of the cache to store the trace group details from root spans. " +
"Default is <code>1000000</code>.")
private long traceGroupCacheMaxSize = MAX_TRACE_ID_CACHE_SIZE;
Expand Down
Loading
Loading