From b47be651937931563be696be6384e26987871752 Mon Sep 17 00:00:00 2001 From: Yuting Liu Date: Tue, 17 Sep 2024 16:33:36 -0700 Subject: [PATCH 1/2] SUMO-247498 Add hashAlgorithm to common source properties --- sumologic/sumologic_sources.go | 9 +++++++++ website/docs/index.html.markdown | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sumologic/sumologic_sources.go b/sumologic/sumologic_sources.go index 504ffcf5..e62083f6 100644 --- a/sumologic/sumologic_sources.go +++ b/sumologic/sumologic_sources.go @@ -25,6 +25,7 @@ type Source struct { ForceTimeZone bool `json:"forceTimeZone"` DefaultDateFormats []DefaultDateFormat `json:"defaultDateFormats,omitempty"` Filters []Filter `json:"filters,omitempty"` + HashAlgorithm string `json:"hashAlgorithm,omitempty"` CutoffTimestamp int `json:"cutoffTimestamp,omitempty"` CutoffRelativeTime string `json:"cutoffRelativeTime,omitempty"` Fields map[string]interface{} `json:"fields,omitempty"` @@ -142,6 +143,12 @@ func resourceSumologicSource() *schema.Resource { }, }, }, + "hash_algorithm": { + Type: schema.TypeString, + Optional: true + Default: nil, + ValidateFunc: validation.StringInSlice([]string{"MD5", "SHA-256"}, false) + }, "cutoff_timestamp": { Type: schema.TypeInt, Optional: true, @@ -234,6 +241,7 @@ func resourceToSource(d *schema.ResourceData) Source { source.ForceTimeZone = d.Get("force_timezone").(bool) source.DefaultDateFormats = getDefaultDateFormats(d) source.Filters = getFilters(d) + source.HashAlgorithm = d.get("hash_algorithm").(string) source.CutoffTimestamp = d.Get("cutoff_timestamp").(int) source.CutoffRelativeTime = d.Get("cutoff_relative_time").(string) source.Fields = d.Get("fields").(map[string]interface{}) @@ -259,6 +267,7 @@ func resourceSumologicSourceRead(d *schema.ResourceData, source Source) error { if err := d.Set("filters", flattenFilters(source.Filters)); err != nil { return fmt.Errorf("error setting filters for resource %s: %s", d.Id(), err) } + d.Set("hash_algorithm", source.HashAlgorithm) d.Set("cutoff_timestamp", source.CutoffTimestamp) d.Set("cutoff_relative_time", source.CutoffRelativeTime) if err := d.Set("fields", source.Fields); err != nil { diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index a7244241..1af04d79 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -126,7 +126,7 @@ The following properties are common to ALL sources and can be used to configure - `force_timezone` - (Optional) Type true to force the source to use a specific time zone, otherwise type false to use the time zone found in the logs. The default setting is false. - `default_date_formats` - (Optional) Define the format for the timestamps present in your log messages. You can specify a locator regex to identify where timestamps appear in log lines. Requires 'automatic_date_parsing' set to True. + `format` - (Required) The timestamp format supplied as a Java SimpleDateFormat, or "epoch" if the timestamp is in epoch format. - + `locator` - (Optional) Regular expression to locate the timestamp within the messages. + + `locator` - (Optional) Regular expression to locate the timestamp within the messages. Usage: ```hcl @@ -155,6 +155,7 @@ The following properties are common to ALL sources and can be used to configure mask = "MaskedID" } ``` +- `hash_algorithm` - (Optional) Define the hash algorithm used for Hash type filters. available values are "MD5" and "SHA-256". The default value will be "MD5". - `cutoff_timestamp` - (Optional) Only collect data more recent than this timestamp, specified as milliseconds since epoch (13 digit). This maps to the `Collection should begin` field on the UI. Example: using `1663786159000` will set the cutoff timestamp to `Wednesday, September 21, 2022 6:49:19 PM GMT` - `cutoff_relative_time` - (Optional) Can be specified instead of cutoffTimestamp to provide a relative offset with respect to the current time.This maps to the `Collection should begin` field on the UI. Example: use -1h, -1d, or -1w to collect data that's less than one hour, one day, or one week old, respectively. - `fields` - (Optional) Map containing key/value pairs. From c27e78326ed320fb3aed7cfb361368165943840e Mon Sep 17 00:00:00 2001 From: Yuting Liu Date: Tue, 24 Sep 2024 16:17:32 -0700 Subject: [PATCH 2/2] SUMO-247498 Fix the compile error --- sumologic/sumologic_sources.go | 10 +++++----- website/docs/index.html.markdown | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sumologic/sumologic_sources.go b/sumologic/sumologic_sources.go index e62083f6..198a16d9 100644 --- a/sumologic/sumologic_sources.go +++ b/sumologic/sumologic_sources.go @@ -144,10 +144,10 @@ func resourceSumologicSource() *schema.Resource { }, }, "hash_algorithm": { - Type: schema.TypeString, - Optional: true - Default: nil, - ValidateFunc: validation.StringInSlice([]string{"MD5", "SHA-256"}, false) + Type: schema.TypeString, + Optional: true, + Default: nil, + ValidateFunc: validation.StringInSlice([]string{"MD5", "SHA-256"}, false), }, "cutoff_timestamp": { Type: schema.TypeInt, @@ -241,7 +241,7 @@ func resourceToSource(d *schema.ResourceData) Source { source.ForceTimeZone = d.Get("force_timezone").(bool) source.DefaultDateFormats = getDefaultDateFormats(d) source.Filters = getFilters(d) - source.HashAlgorithm = d.get("hash_algorithm").(string) + source.HashAlgorithm = d.Get("hash_algorithm").(string) source.CutoffTimestamp = d.Get("cutoff_timestamp").(int) source.CutoffRelativeTime = d.Get("cutoff_relative_time").(string) source.Fields = d.Get("fields").(map[string]interface{}) diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index 1af04d79..01816275 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -155,7 +155,7 @@ The following properties are common to ALL sources and can be used to configure mask = "MaskedID" } ``` -- `hash_algorithm` - (Optional) Define the hash algorithm used for Hash type filters. available values are "MD5" and "SHA-256". The default value will be "MD5". +- `hash_algorithm` - (Optional) Define the hash algorithm used for Hash type filters. Available values are "MD5" and "SHA-256". The default value will be "MD5". - `cutoff_timestamp` - (Optional) Only collect data more recent than this timestamp, specified as milliseconds since epoch (13 digit). This maps to the `Collection should begin` field on the UI. Example: using `1663786159000` will set the cutoff timestamp to `Wednesday, September 21, 2022 6:49:19 PM GMT` - `cutoff_relative_time` - (Optional) Can be specified instead of cutoffTimestamp to provide a relative offset with respect to the current time.This maps to the `Collection should begin` field on the UI. Example: use -1h, -1d, or -1w to collect data that's less than one hour, one day, or one week old, respectively. - `fields` - (Optional) Map containing key/value pairs.