fluent-plugin-cloudwatch-transform 0.0.1
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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/README.md +32 -0
- data/Rakefile +13 -0
- data/fluent-plugin-cloudwatch-transform.gemspec +25 -0
- data/lib/fluent/plugin/out_cloudwatch_transform.rb +57 -0
- data/sample/.DS_Store +0 -0
- data/sample/cloudwatch-transform.conf.sample +8 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_out_cloudwatch_transform.rb +24 -0
- metadata +131 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: a128a6a702a7c924b1de5857dd628c399690f5fb
         | 
| 4 | 
            +
              data.tar.gz: a5d79d61150f9a46b2d7af5b3cbe026ff5e4feab
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: b76caa8fcf852cd23d6c459f2b6c6b01e462e995f0404fc601dbb7e0f94eac0b3a4cb692391d5701b8bc4e51b424317717ca4c2707c7e1905187ac120b1a0bf3
         | 
| 7 | 
            +
              data.tar.gz: b7b32b197a6bdd07b690822e21a853133ecc56e76707b8c879b0094d929d4c651e510ee031a4eee5f98563824e61bce10840f3023d40db350a33da7712056a4e
         | 
    
        data/.DS_Store
    ADDED
    
    | Binary file | 
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            *.gem
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            # Fluent::Plugin::Cloudwatch Transform
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            fluent-plugin-cloudwatch-transform is an output plug-in for [Fluentd](http://fluentd.org)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            These instructions assume you already have fluentd installed. 
         | 
| 8 | 
            +
            If you don't, please run through [quick start for fluentd] (https://github.com/fluent/fluentd#quick-start)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Now after you have fluentd installed you can follow either of the steps below:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            Add this line to your application's Gemfile:
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                gem 'fluent-plugin-cloudwatch-transform'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            Or install it yourself as:
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                $ gem install fluent-plugin-cloudwatch-transform
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            ## Usage
         | 
| 21 | 
            +
            Add the following into your fluentd config.
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            <match alert.cloudwatch.raw.**>
         | 
| 24 | 
            +
             type cloudwatch_transform
         | 
| 25 | 
            +
             tag  alert.cloudwatch.out
         | 
| 26 | 
            +
            </match>
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            <match alert.cloudwatch.out>
         | 
| 29 | 
            +
             type stdout
         | 
| 30 | 
            +
            </match>
         | 
| 31 | 
            +
             | 
| 32 | 
            +
             | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            #!/usr/bin/env rake
         | 
| 2 | 
            +
            require 'bundler'
         | 
| 3 | 
            +
            Bundler::GemHelper.install_tasks
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'rake/testtask'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Rake::TestTask.new(:test) do |test|
         | 
| 8 | 
            +
              test.libs << 'lib' << 'test'
         | 
| 9 | 
            +
              test.pattern = 'test/**/test_*.rb'
         | 
| 10 | 
            +
              test.verbose = true
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            task :default => [:build]
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            Gem::Specification.new do |gem|
         | 
| 5 | 
            +
              gem.name          = "fluent-plugin-cloudwatch-transform"
         | 
| 6 | 
            +
              gem.version       = "0.0.1"
         | 
| 7 | 
            +
              gem.date          = '2015-03-11'
         | 
| 8 | 
            +
              gem.authors       = ["Ling Zhang"]
         | 
| 9 | 
            +
              gem.email         = ["zhangling.ice@gmail.com"]
         | 
| 10 | 
            +
              gem.summary       = %q{Fluentd output plugin for transform cloudwatch alerts }
         | 
| 11 | 
            +
              gem.description   = %q{FLuentd plugin for transform cloudwatch alerts... WIP}
         | 
| 12 | 
            +
              gem.homepage      = 'https://github.com/lingzhang-lyon/fluent-plugin-cloudwatch-transform'
         | 
| 13 | 
            +
              gem.license       = 'MIT'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              gem.files         = `git ls-files`.split($\)
         | 
| 16 | 
            +
              # gem.files         = ["lib/fluent/plugin/out_cloudwatch_transform.rb"]
         | 
| 17 | 
            +
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         | 
| 18 | 
            +
              gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
         | 
| 19 | 
            +
              gem.require_paths = ["lib"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              gem.add_runtime_dependency 'fluentd', '~> 0.10', '>= 0.10.9'
         | 
| 22 | 
            +
              gem.add_development_dependency 'bundler', '~> 1.3'
         | 
| 23 | 
            +
              gem.add_development_dependency 'rake', '~> 0.9', '>= 0.9.2'
         | 
| 24 | 
            +
              gem.add_development_dependency 'rspec', '~> 2.11', '>= 2.11.0'
         | 
| 25 | 
            +
            end
         | 
| @@ -0,0 +1,57 @@ | |
| 1 | 
            +
            module Fluent
         | 
| 2 | 
            +
              class NewrelicOutput < Output
         | 
| 3 | 
            +
                # First, register the plugin. NAME is the name of this plugin
         | 
| 4 | 
            +
                # and identifies the plugin in the configuration file.
         | 
| 5 | 
            +
                Fluent::Plugin.register_output('cloudwatch_transform', self)
         | 
| 6 | 
            +
                
         | 
| 7 | 
            +
                config_param :tag, :string, default:'alert.cloudwatch.out' 
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                # This method is called before starting.
         | 
| 10 | 
            +
                def configure(conf)
         | 
| 11 | 
            +
                  super
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                # This method is called when starting.
         | 
| 15 | 
            +
                def start
         | 
| 16 | 
            +
                  super
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                # This method is called when shutting down.
         | 
| 20 | 
            +
                def shutdown
         | 
| 21 | 
            +
                  super
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                # This method is called when an event reaches Fluentd.
         | 
| 25 | 
            +
                # 'es' is a Fluent::EventStream object that includes multiple events.
         | 
| 26 | 
            +
                # You can use 'es.each {|time,record| ... }' to retrieve events.
         | 
| 27 | 
            +
                # 'chain' is an object that manages transactions. Call 'chain.next' at
         | 
| 28 | 
            +
                # appropriate points and rollback if it raises an exception.
         | 
| 29 | 
            +
                #
         | 
| 30 | 
            +
                # NOTE! This method is called by Fluentd's main thread so you should not write slow routine here. It causes Fluentd's performance degression.
         | 
| 31 | 
            +
                def emit(tag, es, chain)
         | 
| 32 | 
            +
                  tag_parts = tag.split('.')
         | 
| 33 | 
            +
                  last_tag = tag_parts[tag_parts.size-1]
         | 
| 34 | 
            +
                  chain.next
         | 
| 35 | 
            +
                  es.each {|time,record|
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                		newhash = Hash.new
         | 
| 38 | 
            +
                		# though there is just one key-value pair in cloudwatch alert record, we use a loop to add context for it.
         | 
| 39 | 
            +
                		record.each_pair do |singlekey, singlevalue|
         | 
| 40 | 
            +
                				newhash["event_name"] = singlekey
         | 
| 41 | 
            +
                        newhash["value"] = singlevalue.to_s
         | 
| 42 | 
            +
                        newhash["raw"] ={singlekey => singlevalue}
         | 
| 43 | 
            +
                    end
         | 
| 44 | 
            +
                    # add more information for the cloudwatch alert
         | 
| 45 | 
            +
                    timestamp = Engine.now # Should be receive_time_input
         | 
| 46 | 
            +
                    newhash['receive_time_input']=timestamp.to_s
         | 
| 47 | 
            +
                    newhash["application_name"] = last_tag
         | 
| 48 | 
            +
                    newhash["intermediary_source"] = "cloudwatch"
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                    #log the transformed message and emit it
         | 
| 51 | 
            +
                    $log.info "Tranformed message  #{newhash}"
         | 
| 52 | 
            +
                		Fluent::Engine.emit @tag, time.to_i, newhash
         | 
| 53 | 
            +
                  }
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
            end
         | 
    
        data/sample/.DS_Store
    ADDED
    
    | Binary file | 
    
        data/test/helper.rb
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'bundler'
         | 
| 3 | 
            +
            begin
         | 
| 4 | 
            +
              Bundler.setup(:default, :development)
         | 
| 5 | 
            +
            rescue Bundler::BundlerError => e
         | 
| 6 | 
            +
              $stderr.puts e.message
         | 
| 7 | 
            +
              $stderr.puts "Run `bundle install` to install missing gems"
         | 
| 8 | 
            +
              exit e.status_code
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
            require 'test/unit'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         | 
| 13 | 
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         | 
| 14 | 
            +
            require 'fluent/test'
         | 
| 15 | 
            +
            unless ENV.has_key?('VERBOSE')
         | 
| 16 | 
            +
              nulllogger = Object.new
         | 
| 17 | 
            +
              nulllogger.instance_eval {|obj|
         | 
| 18 | 
            +
                def method_missing(method, *args)
         | 
| 19 | 
            +
                  # pass
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              }
         | 
| 22 | 
            +
              $log = nulllogger
         | 
| 23 | 
            +
            end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            require 'fluent/plugin/out_cloudwatch_transform'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            class Test::Unit::TestCase
         | 
| 28 | 
            +
            end
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            require 'helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class SnmpTrapInputTest < Test::Unit::TestCase
         | 
| 4 | 
            +
              def setup
         | 
| 5 | 
            +
                Fluent::Test.setup
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              CONFIG = %[
         | 
| 9 | 
            +
                host 0
         | 
| 10 | 
            +
                port 1062
         | 
| 11 | 
            +
                tag alert.snmptrap
         | 
| 12 | 
            +
              ]
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def create_driver(conf=CONFIG)
         | 
| 15 | 
            +
                Fluent::Test::InputTestDriver.new(Fluent::SnmpTrapInput).configure(conf)
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              def test_configure
         | 
| 19 | 
            +
                d = create_driver('')
         | 
| 20 | 
            +
                assert_equal "0".to_i, d.instance.host
         | 
| 21 | 
            +
                assert_equal "1062".to_i, d.instance.port
         | 
| 22 | 
            +
                assert_equal 'alert.snmptrap', d.instance.tag
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,131 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: fluent-plugin-cloudwatch-transform
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Ling Zhang
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-03-11 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: fluentd
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ~>
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0.10'
         | 
| 20 | 
            +
                - - '>='
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 0.10.9
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ~>
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '0.10'
         | 
| 30 | 
            +
                - - '>='
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 0.10.9
         | 
| 33 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            +
              name: bundler
         | 
| 35 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 | 
            +
                requirements:
         | 
| 37 | 
            +
                - - ~>
         | 
| 38 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            +
                    version: '1.3'
         | 
| 40 | 
            +
              type: :development
         | 
| 41 | 
            +
              prerelease: false
         | 
| 42 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 | 
            +
                requirements:
         | 
| 44 | 
            +
                - - ~>
         | 
| 45 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            +
                    version: '1.3'
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            +
              name: rake
         | 
| 49 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ~>
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '0.9'
         | 
| 54 | 
            +
                - - '>='
         | 
| 55 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 56 | 
            +
                    version: 0.9.2
         | 
| 57 | 
            +
              type: :development
         | 
| 58 | 
            +
              prerelease: false
         | 
| 59 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 60 | 
            +
                requirements:
         | 
| 61 | 
            +
                - - ~>
         | 
| 62 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 63 | 
            +
                    version: '0.9'
         | 
| 64 | 
            +
                - - '>='
         | 
| 65 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 66 | 
            +
                    version: 0.9.2
         | 
| 67 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 68 | 
            +
              name: rspec
         | 
| 69 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 70 | 
            +
                requirements:
         | 
| 71 | 
            +
                - - ~>
         | 
| 72 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 73 | 
            +
                    version: '2.11'
         | 
| 74 | 
            +
                - - '>='
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: 2.11.0
         | 
| 77 | 
            +
              type: :development
         | 
| 78 | 
            +
              prerelease: false
         | 
| 79 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 80 | 
            +
                requirements:
         | 
| 81 | 
            +
                - - ~>
         | 
| 82 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 83 | 
            +
                    version: '2.11'
         | 
| 84 | 
            +
                - - '>='
         | 
| 85 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 86 | 
            +
                    version: 2.11.0
         | 
| 87 | 
            +
            description: FLuentd plugin for transform cloudwatch alerts... WIP
         | 
| 88 | 
            +
            email:
         | 
| 89 | 
            +
            - zhangling.ice@gmail.com
         | 
| 90 | 
            +
            executables: []
         | 
| 91 | 
            +
            extensions: []
         | 
| 92 | 
            +
            extra_rdoc_files: []
         | 
| 93 | 
            +
            files:
         | 
| 94 | 
            +
            - .DS_Store
         | 
| 95 | 
            +
            - .gitignore
         | 
| 96 | 
            +
            - Gemfile
         | 
| 97 | 
            +
            - README.md
         | 
| 98 | 
            +
            - Rakefile
         | 
| 99 | 
            +
            - fluent-plugin-cloudwatch-transform.gemspec
         | 
| 100 | 
            +
            - lib/fluent/plugin/out_cloudwatch_transform.rb
         | 
| 101 | 
            +
            - sample/.DS_Store
         | 
| 102 | 
            +
            - sample/cloudwatch-transform.conf.sample
         | 
| 103 | 
            +
            - test/helper.rb
         | 
| 104 | 
            +
            - test/plugin/test_out_cloudwatch_transform.rb
         | 
| 105 | 
            +
            homepage: https://github.com/lingzhang-lyon/fluent-plugin-cloudwatch-transform
         | 
| 106 | 
            +
            licenses:
         | 
| 107 | 
            +
            - MIT
         | 
| 108 | 
            +
            metadata: {}
         | 
| 109 | 
            +
            post_install_message: 
         | 
| 110 | 
            +
            rdoc_options: []
         | 
| 111 | 
            +
            require_paths:
         | 
| 112 | 
            +
            - lib
         | 
| 113 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
              requirements:
         | 
| 115 | 
            +
              - - '>='
         | 
| 116 | 
            +
                - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                  version: '0'
         | 
| 118 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 119 | 
            +
              requirements:
         | 
| 120 | 
            +
              - - '>='
         | 
| 121 | 
            +
                - !ruby/object:Gem::Version
         | 
| 122 | 
            +
                  version: '0'
         | 
| 123 | 
            +
            requirements: []
         | 
| 124 | 
            +
            rubyforge_project: 
         | 
| 125 | 
            +
            rubygems_version: 2.0.14
         | 
| 126 | 
            +
            signing_key: 
         | 
| 127 | 
            +
            specification_version: 4
         | 
| 128 | 
            +
            summary: Fluentd output plugin for transform cloudwatch alerts
         | 
| 129 | 
            +
            test_files:
         | 
| 130 | 
            +
            - test/helper.rb
         | 
| 131 | 
            +
            - test/plugin/test_out_cloudwatch_transform.rb
         |