Skip to content

Commit

Permalink
Merge pull request #686 from SumoLogic/yuting-SUMO-247498-fix-hashAlr…
Browse files Browse the repository at this point in the history
…ogithm

SUMO-247498 Add hashAlgorithm to common source properties
  • Loading branch information
yuting-liu authored Sep 26, 2024
2 parents ec0fcb0 + c27e783 commit 113a3db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions sumologic/sumologic_sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{})
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 113a3db

Please sign in to comment.