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

SUMO-247498 Add hashAlgorithm to common source properties #686

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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,
yuting-liu marked this conversation as resolved.
Show resolved Hide resolved
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
Loading