sumologic-query 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -27
- data/lib/sumologic/client.rb +15 -3
- data/lib/sumologic/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 045b4c6496e38a665e48c98c37beb3fbf95477f8af17f507725ccf882dc63076
|
|
4
|
+
data.tar.gz: fb5d931c84e347065ee258d0da508eaf3d2ab847dd978b33dd33151ee544939e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f943fba2e5cb46fff13aaec60c1a898284ca745f2e357cafb88b68c6d55e8fae29fcb617761c18da7898ef27e1903185b50c076052b33b2b0a1249459caecda
|
|
7
|
+
data.tar.gz: 77c6f9270a9874a442749834c7f89e3ced18769ec89735ceba3746e1a2d2bb37541d32a752f186b673b01e6da67ae82ed67eaa60804255494913d120d1ea19e2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,34 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
All notable changes to this project
|
|
3
|
+
All notable changes to this project are documented in [GitHub Releases](https://github.com/patrick204nqh/sumologic-query/releases).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Releases
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
- Core `Sumologic::Client` class for Search Job API
|
|
13
|
-
- Command-line interface with query, time range, and output options
|
|
14
|
-
- Automatic job polling with 20-second intervals
|
|
15
|
-
- Automatic pagination for large result sets (10K messages per request)
|
|
16
|
-
- Support for multiple Sumo Logic deployments (us1, us2, eu, au)
|
|
17
|
-
- Environment variable configuration (SUMO_ACCESS_ID, SUMO_ACCESS_KEY, SUMO_DEPLOYMENT)
|
|
18
|
-
- Debug mode for troubleshooting (SUMO_DEBUG)
|
|
19
|
-
- JSON output format with metadata
|
|
20
|
-
- Zero external dependencies (stdlib only)
|
|
21
|
-
- Comprehensive error handling and user-friendly messages
|
|
22
|
-
- MIT license
|
|
23
|
-
- Complete documentation and examples
|
|
9
|
+
- [v1.1.0](https://github.com/patrick204nqh/sumologic-query/releases/tag/v1.1.0) - Latest
|
|
10
|
+
- [v1.0.0](https://github.com/patrick204nqh/sumologic-query/releases/tag/v1.0.0) - Initial release
|
|
24
11
|
|
|
25
|
-
|
|
26
|
-
- Query historical logs via Search Job API
|
|
27
|
-
- Time range filtering (ISO 8601 format)
|
|
28
|
-
- Message limiting
|
|
29
|
-
- Timezone support
|
|
30
|
-
- File or stdout output
|
|
31
|
-
- 5-minute default timeout
|
|
32
|
-
- Graceful cleanup of search jobs
|
|
12
|
+
---
|
|
33
13
|
|
|
34
|
-
|
|
14
|
+
**Note:** Release notes are automatically generated from commit messages and pull requests.
|
|
15
|
+
See [GitHub Releases](https://github.com/patrick204nqh/sumologic-query/releases) for detailed changelogs.
|
data/lib/sumologic/client.rb
CHANGED
|
@@ -10,7 +10,9 @@ module Sumologic
|
|
|
10
10
|
# Handles historical log queries with automatic polling and pagination
|
|
11
11
|
class Client
|
|
12
12
|
API_VERSION = 'v1'
|
|
13
|
-
|
|
13
|
+
INITIAL_POLL_INTERVAL = 5 # seconds - start fast for small queries
|
|
14
|
+
MAX_POLL_INTERVAL = 20 # seconds - slow down for large queries
|
|
15
|
+
POLL_BACKOFF_FACTOR = 1.5 # increase interval by 50% each time
|
|
14
16
|
DEFAULT_TIMEOUT = 300 # seconds (5 minutes)
|
|
15
17
|
MAX_MESSAGES_PER_REQUEST = 10_000
|
|
16
18
|
|
|
@@ -94,7 +96,8 @@ module Sumologic
|
|
|
94
96
|
def poll_until_complete(job_id, timeout: DEFAULT_TIMEOUT)
|
|
95
97
|
uri = URI("#{@base_url}/search/jobs/#{job_id}")
|
|
96
98
|
start_time = Time.now
|
|
97
|
-
interval =
|
|
99
|
+
interval = INITIAL_POLL_INTERVAL
|
|
100
|
+
poll_count = 0
|
|
98
101
|
|
|
99
102
|
loop do
|
|
100
103
|
raise TimeoutError, "Search job timed out after #{timeout} seconds" if Time.now - start_time > timeout
|
|
@@ -107,16 +110,25 @@ module Sumologic
|
|
|
107
110
|
data = JSON.parse(response.body)
|
|
108
111
|
|
|
109
112
|
state = data['state']
|
|
110
|
-
|
|
113
|
+
msg_count = data['messageCount']
|
|
114
|
+
rec_count = data['recordCount']
|
|
115
|
+
log_info "Job state: #{state} (#{msg_count} messages, #{rec_count} records) [interval: #{interval}s]"
|
|
111
116
|
|
|
112
117
|
case state
|
|
113
118
|
when 'DONE GATHERING RESULTS'
|
|
119
|
+
elapsed = Time.now - start_time
|
|
120
|
+
log_info "Job completed in #{elapsed.round(1)} seconds after #{poll_count + 1} polls"
|
|
114
121
|
return data
|
|
115
122
|
when 'CANCELLED', 'FORCE PAUSED'
|
|
116
123
|
raise Error, "Search job #{state.downcase}"
|
|
117
124
|
end
|
|
118
125
|
|
|
119
126
|
sleep interval
|
|
127
|
+
poll_count += 1
|
|
128
|
+
|
|
129
|
+
# Adaptive backoff: gradually increase interval for long-running jobs
|
|
130
|
+
# This reduces API calls while maintaining responsiveness for quick jobs
|
|
131
|
+
interval = [interval * POLL_BACKOFF_FACTOR, MAX_POLL_INTERVAL].min
|
|
120
132
|
end
|
|
121
133
|
end
|
|
122
134
|
|
data/lib/sumologic/version.rb
CHANGED