sumologic-query 1.3.4 → 1.4.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +48 -0
  3. data/README.md +85 -270
  4. data/lib/sumologic/cli/commands/base_command.rb +0 -20
  5. data/lib/sumologic/cli/commands/discover_source_metadata_command.rb +59 -0
  6. data/lib/sumologic/cli/commands/export_content_command.rb +20 -0
  7. data/lib/sumologic/cli/commands/get_content_command.rb +20 -0
  8. data/lib/sumologic/cli/commands/get_dashboard_command.rb +20 -0
  9. data/lib/sumologic/cli/commands/get_lookup_command.rb +20 -0
  10. data/lib/sumologic/cli/commands/get_monitor_command.rb +20 -0
  11. data/lib/sumologic/cli/commands/list_apps_command.rb +22 -0
  12. data/lib/sumologic/cli/commands/list_collectors_command.rb +1 -1
  13. data/lib/sumologic/cli/commands/list_dashboards_command.rb +22 -0
  14. data/lib/sumologic/cli/commands/list_fields_command.rb +27 -0
  15. data/lib/sumologic/cli/commands/list_folders_command.rb +55 -0
  16. data/lib/sumologic/cli/commands/list_health_events_command.rb +22 -0
  17. data/lib/sumologic/cli/commands/list_monitors_command.rb +27 -0
  18. data/lib/sumologic/cli/commands/list_sources_command.rb +2 -9
  19. data/lib/sumologic/cli/commands/search_command.rb +56 -18
  20. data/lib/sumologic/cli.rb +319 -1
  21. data/lib/sumologic/client.rb +225 -8
  22. data/lib/sumologic/configuration.rb +27 -9
  23. data/lib/sumologic/http/client.rb +76 -11
  24. data/lib/sumologic/http/connection_pool.rb +7 -5
  25. data/lib/sumologic/http/response_handler.rb +65 -1
  26. data/lib/sumologic/metadata/app.rb +34 -0
  27. data/lib/sumologic/metadata/collector.rb +5 -6
  28. data/lib/sumologic/metadata/collector_source_fetcher.rb +7 -3
  29. data/lib/sumologic/metadata/content.rb +95 -0
  30. data/lib/sumologic/metadata/dashboard.rb +104 -0
  31. data/lib/sumologic/metadata/field.rb +49 -0
  32. data/lib/sumologic/metadata/folder.rb +89 -0
  33. data/lib/sumologic/metadata/health_event.rb +35 -0
  34. data/lib/sumologic/metadata/loggable.rb +32 -0
  35. data/lib/sumologic/metadata/lookup_table.rb +34 -0
  36. data/lib/sumologic/metadata/models.rb +30 -0
  37. data/lib/sumologic/metadata/monitor.rb +113 -0
  38. data/lib/sumologic/metadata/source.rb +8 -15
  39. data/lib/sumologic/metadata/source_metadata_discovery.rb +155 -0
  40. data/lib/sumologic/search/job.rb +17 -1
  41. data/lib/sumologic/search/message_fetcher.rb +4 -1
  42. data/lib/sumologic/search/record_fetcher.rb +125 -0
  43. data/lib/sumologic/utils/worker.rb +18 -4
  44. data/lib/sumologic/version.rb +1 -1
  45. data/lib/sumologic.rb +26 -0
  46. metadata +26 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72c4c0c9c57655df15506b9be19a21de47398ba2a2aedaae8e8d22d3efbd0873
4
- data.tar.gz: 9cd38107b915187cb699e32305c8af8e6a970c2ea24c2b2340a443cc0a0e2637
3
+ metadata.gz: 5822fc268d1979e97d6993b7f233b720049f832c4d5d921a75c32ecccc16ce68
4
+ data.tar.gz: f9e1cde6a138f45d70ec4ed2e06b22f87faf9500a6cb4fb7274fe8df787bcba1
5
5
  SHA512:
6
- metadata.gz: a073e490f4714e8f11c8c495775937dd42bb420535c38d82137a71a940b4b9db2b9fe33d4e6ec4b7745385a7661ec657db5472b9761dbecc110fb473efca757f
7
- data.tar.gz: 3a9aa83222b99b34fbcdceb45f2e1cdd126c29d28ba4a93db818ea34438b366f7a7b5eb0290f7986e0a9ef9d5deaed95465cca45a72468ec432ec5d6d97a29f4
6
+ metadata.gz: 661862b1dfbc17a5729fbffc54c459e9b2e52a996346b0c028179002c606689096c0a191a26d7bb06d737c197f50324eb86e574289a093c4a392b9248a3e2647
7
+ data.tar.gz: fda3e751c1dc953fa10d878288193ffe060dcd9366e9d18e8cad9d8eeaf8a194e0dcaa1f50ca245fdc5ab20a95c7f1b67809add3dbed2aa28341f68130188ffd
data/CHANGELOG.md CHANGED
@@ -6,6 +6,54 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
6
6
 
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
  and release notes are automatically generated from commit messages.
9
+ ## [1.4.0](https://github.com/patrick204nqh/sumologic-query/compare/v1.3.5...v1.4.0) (2026-02-11)
10
+
11
+ ### 🎉 New Features
12
+
13
+ - add comprehensive skills documentation for Sumo Logic CLI commands
14
+ - add export-content command with async job handling
15
+ - add get-content command for path-based content lookup
16
+ - add get-lookup and list-apps commands
17
+ - add list-health-events and list-fields commands
18
+ - migrate monitors to search API with status/query filters
19
+ - add support for retrieving monitors and dashboards in the CLI, refactor monitor collection logic for improved readability
20
+ - Enhance Sumo Logic CLI with monitors, folders, and dashboards commands
21
+ - implement aggregation queries and enhance error handling for rate limits
22
+
23
+ ### 🐛 Bug Fixes
24
+
25
+ - migrate dashboards from v1 to v2 API
26
+
27
+ ### 🔧 Refactoring
28
+
29
+ - clean design for AI agent readiness (v1.4.0)
30
+
31
+ ### 📚 Documentation
32
+
33
+ - update naming conventions to match actual codebase
34
+ - reorganize into SDLC structure
35
+ - clarify discover-sources as search-based technique
36
+ - revise architecture overview with enhanced clarity on design philosophy, component structure, and key features
37
+
38
+
39
+
40
+ ## [1.3.5](https://github.com/patrick204nqh/sumologic-query/compare/v1.3.4...v1.3.5) (2025-11-19)
41
+
42
+ ### 🎉 New Features
43
+
44
+ - add discover-sources command for dynamic source discovery from logs
45
+ - implement rate limiting configuration and enhance documentation for querying options
46
+
47
+ ### 🔧 Refactoring
48
+
49
+ - improve source discovery logic and enhance debugging output
50
+
51
+ ### 📚 Documentation
52
+
53
+ - update tldr.md with enhanced search options and new commands for querying logs
54
+
55
+
56
+
9
57
  ## [1.3.4](https://github.com/patrick204nqh/sumologic-query/compare/v1.3.3...v1.3.4) (2025-11-19)
10
58
 
11
59
  ### 🎉 New Features
data/README.md CHANGED
@@ -6,351 +6,166 @@
6
6
  [![Downloads](https://img.shields.io/gem/dt/sumologic-query.svg)](https://rubygems.org/gems/sumologic-query)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
 
9
- ## Why This Tool?
9
+ ## Features
10
10
 
11
- - **Intuitive time parsing**: Use relative times like `-1h`, `-30m`, or `now` - no more calculating timestamps!
12
- - **Flexible timezone support**: US, Australian, and IANA timezone formats supported
13
- - **Minimal dependencies**: Uses only Ruby stdlib + Thor for CLI
14
- - **Fast queries**: Efficient polling and automatic pagination
15
- - **Interactive mode**: Explore logs with FZF-powered fuzzy search and preview
16
- - **Simple interface**: Just query, get results, done
17
- - **Read-only**: No write operations, perfect for safe log access
18
- - **Modular architecture**: Clean separation of concerns (HTTP, Search, Metadata)
19
- - **Metadata support**: List collectors and sources alongside log queries
20
-
21
- All existing Ruby Sumo Logic gems are unmaintained (2-9 years dormant). This tool provides a fresh, minimal approach focused on querying logs and metadata.
11
+ - **Simple time parsing** - Use `-1h`, `-30m`, `now` instead of timestamps
12
+ - **Dynamic source discovery** - Find CloudWatch/ECS/Lambda sources from logs
13
+ - **Interactive mode** - Explore logs with FZF fuzzy search
14
+ - **Timezone support** - US, Australian, and IANA formats
15
+ - **Fast & efficient** - Smart polling and pagination
16
+ - **Read-only** - Safe log access with no write operations
22
17
 
23
18
  ## Installation
24
19
 
25
- ### Via RubyGems
26
-
27
20
  ```bash
21
+ # Via RubyGems
28
22
  gem install sumologic-query
29
- ```
30
23
 
31
- ### Via Homebrew
32
-
33
- ```bash
24
+ # Via Homebrew
34
25
  brew tap patrick204nqh/tap
35
26
  brew install sumologic-query
36
27
  ```
37
28
 
38
- ### From Source
39
-
40
- ```bash
41
- git clone https://github.com/patrick204nqh/sumologic-query.git
42
- cd sumologic-query
43
- bundle install
44
- bundle exec rake install
45
- ```
46
-
47
29
  ## Quick Start
48
30
 
49
- ### 1. Set Up Credentials
50
-
51
- Export your Sumo Logic API credentials:
31
+ ### 1. Set Credentials
52
32
 
53
33
  ```bash
54
34
  export SUMO_ACCESS_ID="your_access_id"
55
35
  export SUMO_ACCESS_KEY="your_access_key"
56
- export SUMO_DEPLOYMENT="us2" # Optional: us1, us2 (default), eu, au, etc.
36
+ export SUMO_DEPLOYMENT="us2" # Optional: us1, us2 (default), eu, au
57
37
  ```
58
38
 
59
- **Getting credentials:**
60
- 1. Log in to Sumo Logic
61
- 2. Go to **Administration → Security → Access Keys**
62
- 3. Create a new access key or use existing
63
- 4. Copy the Access ID and Access Key
39
+ Get credentials: Sumo Logic → **Administration → Security → Access Keys**
64
40
 
65
- ### 2. Run Your First Query
41
+ ### 2. Run Queries
66
42
 
67
43
  ```bash
68
- # Search logs from last hour (easy!)
69
- sumo-query search --query 'error' --from '-1h' --to 'now' --limit 10
70
-
71
- # Search logs from last 30 minutes
72
- sumo-query search --query 'error' --from '-30m' --to 'now'
44
+ # Search logs
45
+ sumo-query search -q 'error' -f '-1h' -t 'now' --limit 100
73
46
 
74
- # Or use ISO 8601 format
75
- sumo-query search --query 'error' \
76
- --from '2025-11-13T14:00:00' \
77
- --to '2025-11-13T15:00:00' \
78
- --limit 10
47
+ # Discover dynamic sources (CloudWatch/ECS/Lambda)
48
+ sumo-query discover-sources
79
49
 
80
- # List collectors
50
+ # List collectors and sources
81
51
  sumo-query collectors
82
-
83
- # List sources
84
52
  sumo-query sources
85
53
  ```
86
54
 
87
- ## Usage
55
+ ## Commands
88
56
 
89
- The CLI provides three main commands:
90
-
91
- ### Search Logs
57
+ ### 1. Search Logs
92
58
 
93
59
  ```bash
94
- sumo-query search --query "YOUR_QUERY" \
95
- --from "START_TIME" \
96
- --to "END_TIME" \
97
- [--output FILE] \
98
- [--limit N] \
99
- [--time-zone TZ] \
100
- [--interactive]
60
+ sumo-query search -q "YOUR_QUERY" -f "START" -t "END" [OPTIONS]
101
61
  ```
102
62
 
103
- **Required options:**
104
- - `-q, --query QUERY` - Sumo Logic query string
105
- - `-f, --from TIME` - Start time (ISO 8601 format)
106
- - `-t, --to TIME` - End time (ISO 8601 format)
107
-
108
- **Optional options:**
109
- - `-i, --interactive` - Launch interactive browser with FZF
110
- - `-z, --time-zone TZ` - Time zone (default: UTC)
111
- - `-l, --limit N` - Limit number of messages
112
- - `-o, --output FILE` - Save to file (default: stdout)
113
- - `-d, --debug` - Enable debug output
63
+ **Options:**
64
+ - `-q, --query` - Query string (required)
65
+ - `-f, --from` - Start time (required, e.g., `-1h`, `2025-11-19T14:00:00`)
66
+ - `-t, --to` - End time (required, e.g., `now`)
67
+ - `-z, --time-zone` - Timezone (default: UTC)
68
+ - `-l, --limit` - Max messages to return
69
+ - `-o, --output` - Save to file
70
+ - `-i, --interactive` - Launch FZF browser
71
+ - `-d, --debug` - Debug output
114
72
 
115
- ### Interactive Mode 🚀
73
+ **Interactive Mode** (`-i`): FZF-based browser with fuzzy search, preview, and multi-select. Requires `fzf` ([install](https://github.com/junegunn/fzf#installation)).
116
74
 
117
- Explore your logs interactively with a powerful FZF-based interface:
75
+ ### 2. Discover Dynamic Sources
118
76
 
119
77
  ```bash
120
- # Launch interactive mode - last hour
121
- sumo-query search --query 'error' --from '-1h' --to 'now' --interactive
78
+ sumo-query discover-sources [OPTIONS]
79
+ ```
122
80
 
123
- # Last 30 minutes with shorthand
124
- sumo-query search -q 'error' -f '-30m' -t 'now' -i
81
+ Discovers source names from log data using search aggregation (`* | count by _sourceName, _sourceCategory`). This is not an official Sumo Logic API — it complements `list-sources` by finding runtime sources (CloudWatch, ECS, Lambda streams) that use dynamic `_sourceName` values.
125
82
 
126
- # Or use ISO 8601 format
127
- sumo-query search -q 'error' -f '2025-11-13T14:00:00' -t '2025-11-13T15:00:00' -i
128
- ```
83
+ **Options:**
84
+ - `-f, --from` - Start time (default: `-24h`)
85
+ - `-t, --to` - End time (default: `now`)
86
+ - `--filter` - Filter query (e.g., `_sourceCategory=*ecs*`)
87
+ - `-z, --time-zone` - Timezone (default: UTC)
88
+ - `-o, --output` - Save to file
129
89
 
130
- **Features:**
131
- - 🔍 Fuzzy search across all message fields
132
- - 👁️ Live preview with full JSON details
133
- - 🎨 Color-coded log levels (ERROR, WARN, INFO)
134
- - ⌨️ Keyboard shortcuts for quick actions
135
- - 📋 Multi-select and batch operations
136
- - 💾 Export selected messages
137
-
138
- **Keybindings:**
139
- - `Enter` - Toggle selection (mark/unmark message)
140
- - `Tab` - Open current message in pager (copyable view)
141
- - `Ctrl-S` - Save selected messages to `sumo-selected.txt` and exit
142
- - `Ctrl-Y` - Copy selected messages to clipboard and exit
143
- - `Ctrl-E` - Export selected messages to `sumo-export.jsonl` and exit
144
- - `Ctrl-A` - Select all messages
145
- - `Ctrl-D` - Deselect all messages
146
- - `Ctrl-/` - Toggle preview pane
147
- - `Ctrl-Q` - Quit without saving
148
-
149
- **Requirements:**
150
- - Install FZF: `brew install fzf` (macOS) or `apt-get install fzf` (Linux)
151
- - See: https://github.com/junegunn/fzf#installation
152
-
153
- ### Time Format Examples
154
-
155
- Combine relative times with timezones for powerful queries:
90
+ **Examples:**
156
91
 
157
92
  ```bash
158
- # Last hour in Sydney time
159
- sumo-query search -q 'error' -f '-1h' -t 'now' -z AEST
93
+ # Discover all sources from last 24 hours
94
+ sumo-query discover-sources
160
95
 
161
- # Last 30 minutes in US Eastern time
162
- sumo-query search -q 'error' -f '-30m' -t 'now' -z EST
96
+ # Filter to ECS only
97
+ sumo-query discover-sources --filter '_sourceCategory=*ecs*'
163
98
 
164
- # Last 7 days with output to file (directories auto-created)
165
- sumo-query search -q 'error' -f '-7d' -t 'now' -o logs/weekly/errors.json
99
+ # Last 7 days, save to file
100
+ sumo-query discover-sources -f '-7d' -o sources.json
101
+ ```
166
102
 
167
- # Mix relative and ISO 8601 formats
168
- sumo-query search -q 'error' -f '-24h' -t '2025-11-19T12:00:00'
103
+ ### 3. List Collectors & Sources
169
104
 
170
- # Unix timestamps from last hour to now
171
- sumo-query search -q 'error' -f '1700000000' -t 'now'
105
+ ```bash
106
+ # List collectors
107
+ sumo-query collectors [-o FILE]
108
+
109
+ # List static sources
110
+ sumo-query sources [-o FILE]
172
111
  ```
173
112
 
174
- ### List Collectors
113
+ ## Time Formats
175
114
 
176
115
  ```bash
177
- sumo-query collectors [--output FILE]
178
- ```
116
+ # Relative (recommended)
117
+ -1h, -30m, -7d, now
179
118
 
180
- Lists all collectors in your account with status and metadata.
119
+ # ISO 8601
120
+ 2025-11-19T14:00:00
181
121
 
182
- ### List Sources
122
+ # Unix timestamp
123
+ 1700000000
183
124
 
184
- ```bash
185
- sumo-query sources [--output FILE]
125
+ # Timezones
126
+ UTC, AEST, EST, America/New_York, Australia/Sydney, +10:00
186
127
  ```
187
128
 
188
- Lists all sources from active collectors.
189
-
129
+ See [examples/queries.md](examples/queries.md) for comprehensive query patterns.
190
130
 
191
- ## Ruby Library Usage
131
+ ## Ruby Library
192
132
 
193
133
  ```ruby
194
134
  require 'sumologic'
195
135
 
196
- # Initialize client
197
136
  client = Sumologic::Client.new(
198
137
  access_id: ENV['SUMO_ACCESS_ID'],
199
- access_key: ENV['SUMO_ACCESS_KEY'],
200
- deployment: 'us2'
201
- )
202
-
203
- # Search logs
204
- results = client.search(
205
- query: 'error',
206
- from_time: '2025-11-13T14:00:00',
207
- to_time: '2025-11-13T15:00:00',
208
- time_zone: 'UTC',
209
- limit: 1000
138
+ access_key: ENV['SUMO_ACCESS_KEY']
210
139
  )
211
140
 
212
- # List collectors and sources
213
- collectors = client.list_collectors
214
- sources = client.list_all_sources
215
- ```
141
+ # Search
142
+ client.search(query: 'error', from_time: '-1h', to_time: 'now')
216
143
 
217
- **Time parsing utilities:**
144
+ # Discover sources
145
+ client.discover_dynamic_sources(from_time: '-24h', to_time: 'now')
218
146
 
219
- ```ruby
220
- require 'sumologic/utils/time_parser'
221
-
222
- # Parse relative times and timezones
223
- from_time = Sumologic::Utils::TimeParser.parse('-1h')
224
- timezone = Sumologic::Utils::TimeParser.parse_timezone('AEST')
147
+ # Metadata
148
+ client.list_collectors
149
+ client.list_all_sources
225
150
  ```
226
151
 
227
-
228
- ## Time Formats
229
-
230
- Multiple time formats are supported:
231
-
232
- ```bash
233
- # Relative time (easiest!)
234
- sumo-query search -q 'error' -f '-1h' -t 'now'
235
- sumo-query search -q 'error' -f '-30m' -t 'now'
236
-
237
- # ISO 8601
238
- sumo-query search -q 'error' -f '2025-11-13T14:00:00' -t '2025-11-13T15:00:00'
239
-
240
- # Unix timestamps
241
- sumo-query search -q 'error' -f '1700000000' -t 'now'
242
-
243
- # With timezones
244
- sumo-query search -q 'error' -f '-1h' -t 'now' -z 'AEST'
245
- sumo-query search -q 'error' -f '-1h' -t 'now' -z 'America/New_York'
246
- ```
247
-
248
- **Supported time units:** `s`, `m`, `h`, `d`, `w`, `M`, `now`
249
-
250
- **Supported timezones:** IANA names (`UTC`, `America/New_York`, `Australia/Sydney`), US abbreviations (`EST`, `PST`), Australian abbreviations (`AEST`, `ACST`, `AWST`), UTC offsets (`+10:00`)
251
-
252
- See [examples/time-formats.md](examples/time-formats.md) for comprehensive examples.
253
-
254
- ## Output Format
255
-
256
- Results are returned as JSON:
257
-
258
- ```json
259
- {
260
- "query": "error",
261
- "from": "2025-11-13T14:00:00",
262
- "to": "2025-11-13T15:00:00",
263
- "time_zone": "UTC",
264
- "message_count": 42,
265
- "messages": [
266
- {
267
- "map": {
268
- "_messagetime": "1731506400123",
269
- "_sourceCategory": "prod/api",
270
- "_sourceName": "api-server-01",
271
- "message": "Error processing request: timeout"
272
- }
273
- }
274
- ]
275
- }
276
- ```
277
-
278
- ## Performance
279
-
280
- Query execution time depends on data volume:
281
-
282
- | Messages | Typical Time |
283
- |----------|--------------|
284
- | < 10K | 30-60 seconds |
285
- | 10K-100K | 1-2 minutes |
286
- | 100K+ | 2-5 minutes |
287
-
288
- **Tips for faster queries:**
289
- - Narrow your time range
290
- - Add `_sourceCategory` filters
291
- - Use `--limit` to cap results
292
- - Use aggregation queries instead of raw messages
293
-
294
152
  ## Documentation
295
153
 
296
- - **[Quick Reference (tldr)](docs/tldr.md)** - Concise command examples
297
- - **[Query Examples](examples/queries.md)** - Common query patterns
298
- - **[Time Format Examples](examples/time-formats.md)** - Time parsing and timezone options
299
- - **[Architecture](docs/architecture/)** - Design and architecture decisions
300
-
301
- ## Development
302
-
303
- See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, testing, and contribution guidelines.
304
-
305
- Quick start:
306
-
307
- ```bash
308
- # Clone and install
309
- git clone https://github.com/patrick204nqh/sumologic-query.git
310
- cd sumologic-query
311
- bundle install
312
-
313
- # Run tests (73+ specs including time parser tests)
314
- bundle exec rspec
315
-
316
- # Run linter
317
- bundle exec rubocop
318
-
319
- # Test locally with new time formats
320
- bundle exec bin/sumo-query search --query "error" \
321
- --from "-1h" --to "now"
322
-
323
- # Test with timezone support
324
- bundle exec bin/sumo-query search --query "error" \
325
- --from "-30m" --to "now" --time-zone "AEST"
326
- ```
154
+ - [Query Examples](examples/queries.md) - Query patterns and examples
155
+ - [Quick Reference](docs/tldr.md) - Command cheat sheet
156
+ - [Rate Limiting](docs/rate-limiting.md) - Performance tuning
157
+ - [Architecture](docs/architecture/) - Design decisions
327
158
 
328
159
  ## Contributing
329
160
 
330
- Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
331
-
332
- 1. Fork the repository
333
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
334
- 3. Commit your changes (`git commit -m 'Add amazing feature'`)
335
- 4. Push to the branch (`git push origin feature/amazing-feature`)
336
- 5. Open a Pull Request
161
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
337
162
 
338
163
  ## License
339
164
 
340
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
341
-
342
- ## Support
343
-
344
- - **Issues**: [GitHub Issues](https://github.com/patrick204nqh/sumologic-query/issues)
345
- - **Discussions**: [GitHub Discussions](https://github.com/patrick204nqh/sumologic-query/discussions)
346
- - **Documentation**: [docs/](docs/)
347
-
348
- ## Resources
349
-
350
- - **Sumo Logic API Docs**: https://help.sumologic.com/docs/api/search-job/
351
- - **Query Language**: https://help.sumologic.com/docs/search/
352
- - **Bug Reports**: https://github.com/patrick204nqh/sumologic-query/issues
165
+ MIT License - see [LICENSE](LICENSE) file.
353
166
 
354
- ---
167
+ ## Links
355
168
 
356
- **Note**: This tool provides read-only access to Sumo Logic logs. It does not modify any data or configuration.
169
+ - [Issues](https://github.com/patrick204nqh/sumologic-query/issues)
170
+ - [Sumo Logic API Docs](https://help.sumologic.com/docs/api/search-job/)
171
+ - [Query Language](https://help.sumologic.com/docs/search/)
@@ -31,26 +31,6 @@ module Sumologic
31
31
  puts json_output
32
32
  end
33
33
  end
34
-
35
- def format_collector(collector)
36
- {
37
- id: collector['id'],
38
- name: collector['name'],
39
- collectorType: collector['collectorType'],
40
- alive: collector['alive'],
41
- category: collector['category']
42
- }
43
- end
44
-
45
- def format_source(source)
46
- {
47
- id: source['id'],
48
- name: source['name'],
49
- category: source['category'],
50
- sourceType: source['sourceType'],
51
- alive: source['alive']
52
- }
53
- end
54
34
  end
55
35
  end
56
36
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_command'
4
+ require_relative '../../utils/time_parser'
5
+
6
+ module Sumologic
7
+ class CLI < Thor
8
+ module Commands
9
+ # Handles the discover-source-metadata command execution
10
+ class DiscoverSourceMetadataCommand < BaseCommand
11
+ def execute
12
+ parse_time_options
13
+ log_discovery_info
14
+ results = perform_discovery
15
+
16
+ output_json(results)
17
+ end
18
+
19
+ private
20
+
21
+ def parse_time_options
22
+ # Parse time formats and store both original and parsed values
23
+ @original_from = options[:from]
24
+ @original_to = options[:to]
25
+ @parsed_from = Utils::TimeParser.parse(options[:from])
26
+ @parsed_to = Utils::TimeParser.parse(options[:to])
27
+ @parsed_timezone = Utils::TimeParser.parse_timezone(options[:time_zone])
28
+ rescue Utils::TimeParser::ParseError => e
29
+ warn "Error parsing time: #{e.message}"
30
+ exit 1
31
+ end
32
+
33
+ def log_discovery_info
34
+ warn '=' * 60
35
+ warn 'Discovering Source Metadata'
36
+ warn '=' * 60
37
+ warn "Time Range: #{@original_from} to #{@original_to}"
38
+ if @original_from != @parsed_from || @original_to != @parsed_to
39
+ warn " (Parsed: #{@parsed_from} to #{@parsed_to})"
40
+ end
41
+ warn "Time Zone: #{@parsed_timezone}"
42
+ warn "Filter: #{options[:filter] || 'none (all sources)'}"
43
+ warn '-' * 60
44
+ warn 'Running aggregation query to discover sources...'
45
+ $stderr.puts
46
+ end
47
+
48
+ def perform_discovery
49
+ client.discover_source_metadata(
50
+ from_time: @parsed_from,
51
+ to_time: @parsed_to,
52
+ time_zone: @parsed_timezone,
53
+ filter: options[:filter]
54
+ )
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_command'
4
+
5
+ module Sumologic
6
+ class CLI < Thor
7
+ module Commands
8
+ # Handles the export-content command execution
9
+ class ExportContentCommand < BaseCommand
10
+ def execute
11
+ content_id = options[:content_id]
12
+ warn "Exporting content #{content_id}..."
13
+ result = client.export_content(content_id: content_id)
14
+
15
+ output_json(result)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_command'
4
+
5
+ module Sumologic
6
+ class CLI < Thor
7
+ module Commands
8
+ # Handles the get-content command execution
9
+ class GetContentCommand < BaseCommand
10
+ def execute
11
+ path = options[:path]
12
+ warn "Looking up content at path: #{path}..."
13
+ content = client.get_content(path: path)
14
+
15
+ output_json(content)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_command'
4
+
5
+ module Sumologic
6
+ class CLI < Thor
7
+ module Commands
8
+ # Handles the get-dashboard command execution
9
+ class GetDashboardCommand < BaseCommand
10
+ def execute
11
+ dashboard_id = options[:dashboard_id]
12
+ warn "Fetching dashboard #{dashboard_id}..."
13
+ dashboard = client.get_dashboard(dashboard_id: dashboard_id)
14
+
15
+ output_json(dashboard)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_command'
4
+
5
+ module Sumologic
6
+ class CLI < Thor
7
+ module Commands
8
+ # Handles the get-lookup command execution
9
+ class GetLookupCommand < BaseCommand
10
+ def execute
11
+ lookup_id = options[:lookup_id]
12
+ warn "Fetching lookup table #{lookup_id}..."
13
+ lookup = client.get_lookup(lookup_id: lookup_id)
14
+
15
+ output_json(lookup)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end