Class: CloudWatchLogsInsightsUrlBuilder
- Inherits:
-
Object
- Object
- CloudWatchLogsInsightsUrlBuilder
- Defined in:
- lib/cloudwatch_logs_insights_url_builder.rb,
lib/cloudwatch_logs_insights_url_builder/criteria.rb
Defined Under Namespace
Classes: Criteria
Constant Summary collapse
- STRING_TIME_FORMAT =
'%Y-%m-%dT%T.000Z'.freeze
Instance Attribute Summary collapse
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#log_groups ⇒ Object
Returns the value of attribute log_groups.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#time_type ⇒ Object
Returns the value of attribute time_type.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
Instance Method Summary collapse
-
#initialize(region = 'us-east-1') ⇒ CloudWatchLogsInsightsUrlBuilder
constructor
A new instance of CloudWatchLogsInsightsUrlBuilder.
- #log_insights_url(query) ⇒ Object
Constructor Details
#initialize(region = 'us-east-1') ⇒ CloudWatchLogsInsightsUrlBuilder
Returns a new instance of CloudWatchLogsInsightsUrlBuilder.
9 10 11 12 13 14 15 16 17 |
# File 'lib/cloudwatch_logs_insights_url_builder.rb', line 9 def initialize(region = 'us-east-1') @region = region @time_type = 'RELATIVE' @timezone = 'Local' @unit = 'minutes' @start_time = -86_400 @end_time = 0 @log_groups = [] end |
Instance Attribute Details
#end_time ⇒ Object
Returns the value of attribute end_time.
5 6 7 |
# File 'lib/cloudwatch_logs_insights_url_builder.rb', line 5 def end_time @end_time end |
#log_groups ⇒ Object
Returns the value of attribute log_groups.
5 6 7 |
# File 'lib/cloudwatch_logs_insights_url_builder.rb', line 5 def log_groups @log_groups end |
#start_time ⇒ Object
Returns the value of attribute start_time.
5 6 7 |
# File 'lib/cloudwatch_logs_insights_url_builder.rb', line 5 def start_time @start_time end |
#time_type ⇒ Object
Returns the value of attribute time_type.
5 6 7 |
# File 'lib/cloudwatch_logs_insights_url_builder.rb', line 5 def time_type @time_type end |
#timezone ⇒ Object
Returns the value of attribute timezone.
5 6 7 |
# File 'lib/cloudwatch_logs_insights_url_builder.rb', line 5 def timezone @timezone end |
Instance Method Details
#log_insights_url(query) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cloudwatch_logs_insights_url_builder.rb', line 19 def log_insights_url(query) url = +"https://#{@region}.console.aws.amazon.com/cloudwatch/home?region=#{@region}#logsV2:logs-insights" url << URI.encode_www_form_component('?queryDetail=').gsub('%', '$') start_time = @start_time.is_a?(Time) ? @start_time.strftime(STRING_TIME_FORMAT) : @start_time end_time = @end_time.is_a?(Time) ? @end_time.strftime(STRING_TIME_FORMAT) : @end_time builder = CloudWatchLogsInsightsUrlBuilder::Criteria.new builder.add('end', end_time) builder.add('start', start_time) builder.add('timeType', @time_type) builder.add('unit', 'seconds') if @time_type == 'RELATIVE' builder.add('tz', @timezone) builder.add('editorString', query) builder.add('isLiveTail', false) builder.add('source', @log_groups) if @log_groups.size.positive? url << builder.build url end |