Class: Sumologic::Client
- Inherits:
-
Object
- Object
- Sumologic::Client
- Defined in:
- lib/sumologic/client.rb
Overview
Facade for Sumo Logic API operations Coordinates HTTP, Search, and Metadata components
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#discover_source_metadata(from_time:, to_time:, time_zone: 'UTC', **options) ⇒ Hash
Discover source metadata from actual log data Useful for CloudWatch/ECS sources with dynamic _sourceName values.
-
#export_content(content_id:) ⇒ Hash
Export a content item as JSON Handles async job lifecycle: start, poll, fetch result.
-
#folder_tree(folder_id: nil, max_depth: 3) ⇒ Hash
Get folder tree starting from a folder.
-
#get_content(path:) ⇒ Hash
Get a content item by its library path.
-
#get_dashboard(dashboard_id:) ⇒ Hash
Get a specific dashboard by ID.
-
#get_folder(folder_id:) ⇒ Hash
Get a specific folder by ID.
-
#get_lookup(lookup_id:) ⇒ Hash
Get a specific lookup table by ID.
-
#get_monitor(monitor_id:) ⇒ Hash
Get a specific monitor by ID.
-
#initialize(config = nil) ⇒ Client
constructor
rubocop:disable Metrics/MethodLength.
-
#list_all_sources(collector: nil, name: nil, category: nil, limit: nil) ⇒ Array<Hash>
List all sources from all collectors with optional filtering.
-
#list_apps ⇒ Array<Hash>
List available apps from the Sumo Logic app catalog.
-
#list_builtin_fields ⇒ Array<Hash>
List built-in fields.
-
#list_collectors(query: nil, limit: nil) ⇒ Array<Hash>
List collectors with optional filtering.
-
#list_dashboards(limit: 100) ⇒ Array<Hash>
List all dashboards.
-
#list_fields ⇒ Array<Hash>
List custom fields.
-
#list_health_events(limit: 100) ⇒ Array<Hash>
List health events for collectors, sources, and ingest budgets.
-
#list_monitors(query: nil, status: nil, limit: 100) ⇒ Array<Hash>
List monitors with optional status and query filters.
-
#list_sources(collector_id:) ⇒ Array<Hash>
List sources for a specific collector.
-
#personal_folder ⇒ Hash
Get the personal folder for current user.
-
#search(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) ⇒ Array<Hash>
Search logs with query.
-
#search_aggregation(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) ⇒ Array<Hash>
Search with aggregation query (count by, group by, etc.).
-
#search_dashboards(query:, limit: 100) ⇒ Array<Hash>
Search dashboards by title or description.
Constructor Details
#initialize(config = nil) ⇒ Client
rubocop:disable Metrics/MethodLength
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sumologic/client.rb', line 9 def initialize(config = nil) # rubocop:disable Metrics/MethodLength @config = config || Configuration.new @config.validate! # Initialize HTTP layer (v1 API) authenticator = Http::Authenticator.new( access_id: @config.access_id, access_key: @config.access_key ) @http = Http::Client.new( base_url: @config.base_url, authenticator: authenticator, config: @config ) # Initialize HTTP layer for v2 API (Content Library) @http_v2 = Http::Client.new( base_url: @config.base_url_v2, authenticator: authenticator, config: @config ) # Initialize domain components @search = Search::Job.new(http_client: @http, config: @config) @collector = Metadata::Collector.new(http_client: @http) @source = Metadata::Source.new(http_client: @http, collector_client: @collector, config: @config) = Metadata::SourceMetadataDiscovery.new( http_client: @http, search_job: @search, config: @config ) @monitor = Metadata::Monitor.new(http_client: @http) @folder = Metadata::Folder.new(http_client: @http_v2) # Uses v2 API @dashboard = Metadata::Dashboard.new(http_client: @http_v2) @health_event = Metadata::HealthEvent.new(http_client: @http) @field = Metadata::Field.new(http_client: @http) @lookup_table = Metadata::LookupTable.new(http_client: @http) @app = Metadata::App.new(http_client: @http) @content = Metadata::Content.new(http_client: @http_v2) # Uses v2 API end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/sumologic/client.rb', line 7 def config @config end |
Instance Method Details
#discover_source_metadata(from_time:, to_time:, time_zone: 'UTC', **options) ⇒ Hash
Discover source metadata from actual log data Useful for CloudWatch/ECS sources with dynamic _sourceName values
122 123 124 125 126 127 128 129 |
# File 'lib/sumologic/client.rb', line 122 def (from_time:, to_time:, time_zone: 'UTC', **) .discover( from_time: from_time, to_time: to_time, time_zone: time_zone, ** ) end |
#export_content(content_id:) ⇒ Hash
Export a content item as JSON Handles async job lifecycle: start, poll, fetch result
280 281 282 |
# File 'lib/sumologic/client.rb', line 280 def export_content(content_id:) @content.export(content_id) end |
#folder_tree(folder_id: nil, max_depth: 3) ⇒ Hash
Get folder tree starting from a folder
177 178 179 |
# File 'lib/sumologic/client.rb', line 177 def folder_tree(folder_id: nil, max_depth: 3) @folder.tree(folder_id: folder_id, max_depth: max_depth) end |
#get_content(path:) ⇒ Hash
Get a content item by its library path
271 272 273 |
# File 'lib/sumologic/client.rb', line 271 def get_content(path:) @content.get_by_path(path) end |
#get_dashboard(dashboard_id:) ⇒ Hash
Get a specific dashboard by ID
197 198 199 |
# File 'lib/sumologic/client.rb', line 197 def get_dashboard(dashboard_id:) @dashboard.get(dashboard_id) end |
#get_folder(folder_id:) ⇒ Hash
Get a specific folder by ID
168 169 170 |
# File 'lib/sumologic/client.rb', line 168 def get_folder(folder_id:) @folder.get(folder_id) end |
#get_lookup(lookup_id:) ⇒ Hash
Get a specific lookup table by ID
248 249 250 |
# File 'lib/sumologic/client.rb', line 248 def get_lookup(lookup_id:) @lookup_table.get(lookup_id) end |
#get_monitor(monitor_id:) ⇒ Hash
Get a specific monitor by ID
149 150 151 |
# File 'lib/sumologic/client.rb', line 149 def get_monitor(monitor_id:) @monitor.get(monitor_id) end |
#list_all_sources(collector: nil, name: nil, category: nil, limit: nil) ⇒ Array<Hash>
List all sources from all collectors with optional filtering
110 111 112 |
# File 'lib/sumologic/client.rb', line 110 def list_all_sources(collector: nil, name: nil, category: nil, limit: nil) @source.list_all(collector: collector, name: name, category: category, limit: limit) end |
#list_apps ⇒ Array<Hash>
List available apps from the Sumo Logic app catalog
259 260 261 |
# File 'lib/sumologic/client.rb', line 259 def list_apps @app.list end |
#list_builtin_fields ⇒ Array<Hash>
List built-in fields
236 237 238 |
# File 'lib/sumologic/client.rb', line 236 def list_builtin_fields @field.list_builtin end |
#list_collectors(query: nil, limit: nil) ⇒ Array<Hash>
List collectors with optional filtering
91 92 93 |
# File 'lib/sumologic/client.rb', line 91 def list_collectors(query: nil, limit: nil) @collector.list(query: query, limit: limit) end |
#list_dashboards(limit: 100) ⇒ Array<Hash>
List all dashboards
189 190 191 |
# File 'lib/sumologic/client.rb', line 189 def list_dashboards(limit: 100) @dashboard.list(limit: limit) end |
#list_fields ⇒ Array<Hash>
List custom fields
229 230 231 |
# File 'lib/sumologic/client.rb', line 229 def list_fields @field.list end |
#list_health_events(limit: 100) ⇒ Array<Hash>
List health events for collectors, sources, and ingest budgets
218 219 220 |
# File 'lib/sumologic/client.rb', line 218 def list_health_events(limit: 100) @health_event.list(limit: limit) end |
#list_monitors(query: nil, status: nil, limit: 100) ⇒ Array<Hash>
List monitors with optional status and query filters
141 142 143 |
# File 'lib/sumologic/client.rb', line 141 def list_monitors(query: nil, status: nil, limit: 100) @monitor.list(query: query, status: status, limit: limit) end |
#list_sources(collector_id:) ⇒ Array<Hash>
List sources for a specific collector
99 100 101 |
# File 'lib/sumologic/client.rb', line 99 def list_sources(collector_id:) @source.list(collector_id: collector_id) end |
#personal_folder ⇒ Hash
Get the personal folder for current user
160 161 162 |
# File 'lib/sumologic/client.rb', line 160 def personal_folder @folder.personal end |
#search(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) ⇒ Array<Hash>
Search logs with query
58 59 60 61 62 63 64 65 66 |
# File 'lib/sumologic/client.rb', line 58 def search(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) @search.execute( query: query, from_time: from_time, to_time: to_time, time_zone: time_zone, limit: limit ) end |
#search_aggregation(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) ⇒ Array<Hash>
Search with aggregation query (count by, group by, etc.)
76 77 78 79 80 81 82 83 84 |
# File 'lib/sumologic/client.rb', line 76 def search_aggregation(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) @search.execute_aggregation( query: query, from_time: from_time, to_time: to_time, time_zone: time_zone, limit: limit ) end |
#search_dashboards(query:, limit: 100) ⇒ Array<Hash>
Search dashboards by title or description
206 207 208 |
# File 'lib/sumologic/client.rb', line 206 def search_dashboards(query:, limit: 100) @dashboard.search(query: query, limit: limit) end |