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

Re-add AWS CloudWatch source #131

Merged
merged 9 commits into from
Apr 1, 2025
Merged

Re-add AWS CloudWatch source #131

merged 9 commits into from
Apr 1, 2025

Conversation

ParthaI
Copy link
Contributor

@ParthaI ParthaI commented Mar 25, 2025

Example query results

Results
Add example SQL query results here (please include the input queries as well)

@ParthaI ParthaI self-assigned this Mar 25, 2025
@ParthaI ParthaI marked this pull request as draft March 25, 2025 17:09
@ParthaI ParthaI force-pushed the re-add-cloudwatch-source branch from d514484 to 39a8b11 Compare March 31, 2025 06:33
@graza-io graza-io marked this pull request as ready for review March 31, 2025 15:48
// It ensures that the required LogGroupName field is provided and not empty.
func (c *AwsCloudWatchSourceConfig) Validate() error {
if c.LogGroupName == "" {
return fmt.Errorf("log group is required and cannot be empty")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be the hcl field name log_group_name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it would be more appropriate to use the HCL field name. Updated the statement

// AWS CloudWatch Logs client
client *cloudwatchlogs.Client
// List of errors encountered during collection
errorList []error
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't seem to be using this, we instantiate it in Init func but never append to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used the errorList property to collect all the errors during the collection.

// getClient initializes and returns an AWS CloudWatch Logs client
// It uses the provided region or falls back to the default region
func (s *AwsCloudWatchSource) getClient(ctx context.Context) (*cloudwatchlogs.Client, error) {
tempRegion := defaultCloudwatchRegion
Copy link
Contributor

Choose a reason for hiding this comment

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

tempRegion? I'd just call it region

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use region instead

Comment on lines 179 to 184
isFirst := true

for _, state := range s.LogStreams {
if isFirst {
earliestTime = state.GetStartTime()
isFirst = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using a bool, you can check the index of the iteration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Comment on lines 200 to 205
isFirst := true

for _, state := range s.LogStreams {
if isFirst {
latestTime = state.GetEndTime()
isFirst = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of bool, could use index of iteration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


// GetFromTimeForStream returns the start time for a specific log stream.
// If the stream doesn't exist in the state, returns zero time.
func (s *CloudWatchCollectionState) GetFromTimeForStream(logStreamName string) time.Time {
Copy link
Contributor

Choose a reason for hiding this comment

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

You're pulling StartTime, GetStartTimeForStream

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


// GetToTimeForStream returns the end time for a specific log stream.
// If the stream doesn't exist in the state, returns zero time.
func (s *CloudWatchCollectionState) GetToTimeForStream(logStreamName string) time.Time {
Copy link
Contributor

Choose a reason for hiding this comment

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

You're pulling EndTime, GetEndTimeForStream

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@graza-io graza-io merged commit 912c6c3 into main Apr 1, 2025
1 check failed
@graza-io graza-io deleted the re-add-cloudwatch-source branch April 1, 2025 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants