Module: Awspec::Helper::Finder::CloudwatchLogs
- Included in:
- Awspec::Helper::Finder
- Defined in:
- lib/awspec/helper/finder/cloudwatch_logs.rb
Instance Method Summary collapse
- #find_cloudwatch_logs_group(id) ⇒ Object
- #find_cloudwatch_logs_metric_fileter_by_log_group_name(id, filter_name) ⇒ Object
- #find_cloudwatch_logs_stream_by_log_group_name(id, stream_name) ⇒ Object
- #find_cloudwatch_logs_subscription_fileter_by_log_group_name(id, filter_name) ⇒ Object
- #find_tags_by_log_group_name(id) ⇒ Object
- #last_cloudwatch_logs_stream_by_log_group_name(id) ⇒ Object
- #select_all_cloudwatch_logs_log_groups ⇒ Object
Instance Method Details
#find_cloudwatch_logs_group(id) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/awspec/helper/finder/cloudwatch_logs.rb', line 6 def find_cloudwatch_logs_group(id) cloudwatch_logs_client.describe_log_groups({ log_group_name_prefix: id }).log_groups.find do |log_group| log_group.log_group_name == id end end |
#find_cloudwatch_logs_metric_fileter_by_log_group_name(id, filter_name) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/awspec/helper/finder/cloudwatch_logs.rb', line 40 def find_cloudwatch_logs_metric_fileter_by_log_group_name(id, filter_name) cloudwatch_logs_client.describe_metric_filters({ log_group_name: id, filter_name_prefix: filter_name }).metric_filters.find do |filter| filter.filter_name == filter_name end end |
#find_cloudwatch_logs_stream_by_log_group_name(id, stream_name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/awspec/helper/finder/cloudwatch_logs.rb', line 18 def find_cloudwatch_logs_stream_by_log_group_name(id, stream_name) req = { log_group_name: id, log_stream_name_prefix: stream_name } ret = nil loop do res = cloudwatch_logs_client.describe_log_streams(req) res.log_streams.find do |log_stream| if log_stream[:log_stream_name] == stream_name ret = log_stream[:log_stream_name] break end end break if ret.present? break if res.next_token.nil? req[:next_token] = res.next_token end ret end |
#find_cloudwatch_logs_subscription_fileter_by_log_group_name(id, filter_name) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/awspec/helper/finder/cloudwatch_logs.rb', line 49 def find_cloudwatch_logs_subscription_fileter_by_log_group_name(id, filter_name) cloudwatch_logs_client.describe_subscription_filters({ log_group_name: id, filter_name_prefix: filter_name }).subscription_filters.find do |filter| filter.filter_name == filter_name end end |
#find_tags_by_log_group_name(id) ⇒ Object
71 72 73 |
# File 'lib/awspec/helper/finder/cloudwatch_logs.rb', line 71 def (id) cloudwatch_logs_client.(log_group_name: id)[:tags] end |
#last_cloudwatch_logs_stream_by_log_group_name(id) ⇒ Object
14 15 16 |
# File 'lib/awspec/helper/finder/cloudwatch_logs.rb', line 14 def last_cloudwatch_logs_stream_by_log_group_name(id) cloudwatch_logs_client.describe_log_streams({ log_group_name: id }).log_streams.last end |
#select_all_cloudwatch_logs_log_groups ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/awspec/helper/finder/cloudwatch_logs.rb', line 58 def select_all_cloudwatch_logs_log_groups req = {} log_groups = [] loop do res = cloudwatch_logs_client.describe_log_groups(req) log_groups.push(*res.log_groups) break if res.next_token.nil? req[:next_token] = res.next_token end log_groups end |