├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── DEVELOPER.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── docs └── index.asciidoc ├── lib └── logstash │ └── inputs │ └── cloudwatch.rb ├── logstash-input-cloudwatch.gemspec └── spec ├── inputs └── cloudwatch_spec.rb └── integration └── cloudwatch_spec.rb /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Logstash 2 | 3 | All contributions are welcome: ideas, patches, documentation, bug reports, 4 | complaints, etc! 5 | 6 | Programming is not a required skill, and there are many ways to help out! 7 | It is more important to us that you are able to contribute. 8 | 9 | That said, some basic guidelines, which you are free to ignore :) 10 | 11 | ## Want to learn? 12 | 13 | Want to lurk about and see what others are doing with Logstash? 14 | 15 | * The irc channel (#logstash on irc.freenode.org) is a good place for this 16 | * The [forum](https://discuss.elastic.co/c/logstash) is also 17 | great for learning from others. 18 | 19 | ## Got Questions? 20 | 21 | Have a problem you want Logstash to solve for you? 22 | 23 | * You can ask a question in the [forum](https://discuss.elastic.co/c/logstash) 24 | * Alternately, you are welcome to join the IRC channel #logstash on 25 | irc.freenode.org and ask for help there! 26 | 27 | ## Have an Idea or Feature Request? 28 | 29 | * File a ticket on [GitHub](https://github.com/elastic/logstash/issues). Please remember that GitHub is used only for issues and feature requests. If you have a general question, the [forum](https://discuss.elastic.co/c/logstash) or IRC would be the best place to ask. 30 | 31 | ## Something Not Working? Found a Bug? 32 | 33 | If you think you found a bug, it probably is a bug. 34 | 35 | * If it is a general Logstash or a pipeline issue, file it in [Logstash GitHub](https://github.com/elasticsearch/logstash/issues) 36 | * If it is specific to a plugin, please file it in the respective repository under [logstash-plugins](https://github.com/logstash-plugins) 37 | * or ask the [forum](https://discuss.elastic.co/c/logstash). 38 | 39 | # Contributing Documentation and Code Changes 40 | 41 | If you have a bugfix or new feature that you would like to contribute to 42 | logstash, and you think it will take more than a few minutes to produce the fix 43 | (ie; write code), it is worth discussing the change with the Logstash users and developers first! You can reach us via [GitHub](https://github.com/elastic/logstash/issues), the [forum](https://discuss.elastic.co/c/logstash), or via IRC (#logstash on freenode irc) 44 | Please note that Pull Requests without tests will not be merged. If you would like to contribute but do not have experience with writing tests, please ping us on IRC/forum or create a PR and ask our help. 45 | 46 | ## Contributing to plugins 47 | 48 | Check our [documentation](https://www.elastic.co/guide/en/logstash/current/contributing-to-logstash.html) on how to contribute to plugins or write your own! It is super easy! 49 | 50 | ## Contribution Steps 51 | 52 | 1. Test your changes! [Run](https://github.com/elastic/logstash#testing) the test suite 53 | 2. Please make sure you have signed our [Contributor License 54 | Agreement](https://www.elastic.co/contributor-agreement/). We are not 55 | asking you to assign copyright to us, but to give us the right to distribute 56 | your code without restriction. We ask this of all contributors in order to 57 | assure our users of the origin and continuing existence of the code. You 58 | only need to sign the CLA once. 59 | 3. Send a pull request! Push your changes to your fork of the repository and 60 | [submit a pull 61 | request](https://help.github.com/articles/using-pull-requests). In the pull 62 | request, describe what your changes do and mention any bugs/issues related 63 | to the pull request. 64 | 65 | 66 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Please post all product and debugging questions on our [forum](https://discuss.elastic.co/c/logstash). Your questions will reach our wider community members there, and if we confirm that there is a bug, then we can open a new issue here. 2 | 3 | For all general issues, please provide the following details for fast resolution: 4 | 5 | - Version: 6 | - Operating System: 7 | - Config File (if you have sensitive info, please remove it): 8 | - Sample Data: 9 | - Steps to Reproduce: 10 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thanks for contributing to Logstash! If you haven't already signed our CLA, here's a handy link: https://www.elastic.co/contributor-agreement/ 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | Gemfile.lock 3 | Gemfile.bak 4 | .bundle 5 | vendor 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | import: 2 | - logstash-plugins/.ci:travis/travis.yml@1.x -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.2.4 2 | - Fixed shutdown handling [#43](https://github.com/logstash-plugins/logstash-input-cloudwatch/pull/43) 3 | 4 | ## 2.2.3 5 | - Fixed issue where metric timestamp was being lost due to over-writing by end_time [#38](https://github.com/logstash-plugins/logstash-input-cloudwatch/pull/38) 6 | 7 | ## 2.2.2 8 | - Added ability to use AWS/EC2 namespace without requiring filters [#36](https://github.com/logstash-plugins/logstash-input-cloudwatch/pull/36) 9 | 10 | ## 2.2.1 11 | - Fixed README.md link to request metric support to point to this repo [#34](https://github.com/logstash-plugins/logstash-input-cloudwatch/pull/34) 12 | 13 | ## 2.2.0 14 | - Changed to use the underlying version of the AWS SDK to v2. [#32](https://github.com/logstash-plugins/logstash-input-cloudwatch/pull/32) 15 | - Fixed License definition in gemspec to be valid SPDX identifier [#32](https://github.com/logstash-plugins/logstash-input-cloudwatch/pull/32) 16 | - Fixed fatal error when using secret key attribute in config [#30](https://github.com/logstash-plugins/logstash-input-cloudwatch/issues/30) 17 | 18 | ## 2.1.1 19 | - Docs: Set the default_codec doc attribute. 20 | 21 | ## 2.1.0 22 | - Add documentation for endpoint, role_arn and role_session_name #29 23 | - Reduce info level logging verbosity #27 24 | 25 | ## 2.0.3 26 | - Update gemspec summary 27 | 28 | ## 2.0.2 29 | - Fix some documentation issues 30 | 31 | # 1.1.3 32 | - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash 33 | # 1.1.1 34 | - New dependency requirements for logstash-core for the 5.0 release 35 | ## 1.1.0 36 | - Moved from jrgns/logstash-input-cloudwatch to logstash-plugins 37 | -------------------------------------------------------------------------------- /DEVELOPER.md: -------------------------------------------------------------------------------- 1 | # logstash-input-example 2 | Example input plugin. This should help bootstrap your effort to write your own input plugin! 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash" 6 | use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1" 7 | 8 | if Dir.exist?(logstash_path) && use_logstash_source 9 | gem 'logstash-core', :path => "#{logstash_path}/logstash-core" 10 | gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api" 11 | end 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2020 Elastic and contributors 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Logstash CloudWatch Input Plugins 2 | 3 | Pull events from the Amazon Web Services CloudWatch API. 4 | 5 | To use this plugin, you *must* have an AWS account, and the following policy: 6 | 7 | ```json 8 | { 9 | "Version": "2012-10-17", 10 | "Statement": [ 11 | { 12 | "Sid": "Stmt1444715676000", 13 | "Effect": "Allow", 14 | "Action": [ 15 | "cloudwatch:GetMetricStatistics", 16 | "cloudwatch:ListMetrics" 17 | ], 18 | "Resource": "*" 19 | }, 20 | { 21 | "Sid": "Stmt1444716576170", 22 | "Effect": "Allow", 23 | "Action": [ 24 | "ec2:DescribeInstances" 25 | ], 26 | "Resource": "*" 27 | } 28 | ] 29 | } 30 | ``` 31 | 32 | See the [IAM][3] section on AWS for more details on setting up AWS identities. 33 | 34 | ## Supported Namespaces 35 | 36 | Unfortunately it's not possible to create a "one shoe fits all" solution for fetching metrics from AWS. We need to specifically add support for every namespace. This takes time so we'll be adding support for namespaces as the requests for them come in and we get time to do it. Please check the [`metric support`][1] issues for already requested namespaces, and add your request if it's not there yet. 37 | 38 | ## Configuration 39 | 40 | Just note that the below configuration doesn't contain the AWS API access information. 41 | 42 | ```ruby 43 | input { 44 | cloudwatch { 45 | namespace => "AWS/EC2" 46 | metrics => [ "CPUUtilization" ] 47 | filters => { "tag:Monitoring" => "Yes" } 48 | region => "us-east-1" 49 | } 50 | } 51 | 52 | input { 53 | cloudwatch { 54 | namespace => "AWS/EBS" 55 | metrics => ["VolumeQueueLength"] 56 | filters => { "tag:Monitoring" => "Yes" } 57 | region => "us-east-1" 58 | } 59 | } 60 | 61 | input { 62 | cloudwatch { 63 | namespace => "AWS/RDS" 64 | metrics => ["CPUUtilization", "CPUCreditUsage"] 65 | filters => { "EngineName" => "mysql" } # Only supports EngineName, DatabaseClass and DBInstanceIdentifier 66 | region => "us-east-1" 67 | } 68 | } 69 | ``` 70 | 71 | See AWS Developer Guide for more information on [namespaces and metrics][2]. 72 | 73 | [1]: https://github.com/logstash-plugins/logstash-input-cloudwatch/labels/metric%20support 74 | [2]: http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/aws-namespaces.html 75 | [3]: http://aws.amazon.com/iam/ 76 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "logstash/devutils/rake" 2 | -------------------------------------------------------------------------------- /docs/index.asciidoc: -------------------------------------------------------------------------------- 1 | :plugin: cloudwatch 2 | :type: input 3 | :default_codec: plain 4 | 5 | /////////////////////////////////////////// 6 | START - GENERATED VARIABLES, DO NOT EDIT! 7 | /////////////////////////////////////////// 8 | :version: %VERSION% 9 | :release_date: %RELEASE_DATE% 10 | :changelog_url: %CHANGELOG_URL% 11 | :include_path: ../../../../logstash/docs/include 12 | /////////////////////////////////////////// 13 | END - GENERATED VARIABLES, DO NOT EDIT! 14 | /////////////////////////////////////////// 15 | 16 | [id="plugins-{type}s-{plugin}"] 17 | 18 | === Cloudwatch input plugin 19 | 20 | include::{include_path}/plugin_header.asciidoc[] 21 | 22 | ==== Description 23 | 24 | Pull events from the Amazon Web Services CloudWatch API. 25 | 26 | To use this plugin, you *must* have an AWS account, and the following policy 27 | 28 | Typically, you should setup an IAM policy, create a user and apply the IAM policy to the user. 29 | A sample policy for EC2 metrics is as follows: 30 | [source,json] 31 | { 32 | "Version": "2012-10-17", 33 | "Statement": [ 34 | { 35 | "Sid": "Stmt1444715676000", 36 | "Effect": "Allow", 37 | "Action": [ 38 | "cloudwatch:GetMetricStatistics", 39 | "cloudwatch:ListMetrics" 40 | ], 41 | "Resource": "*" 42 | }, 43 | { 44 | "Sid": "Stmt1444716576170", 45 | "Effect": "Allow", 46 | "Action": [ 47 | "ec2:DescribeInstances" 48 | ], 49 | "Resource": "*" 50 | } 51 | ] 52 | } 53 | 54 | See http://aws.amazon.com/iam/ for more details on setting up AWS identities. 55 | 56 | ===== Configuration examples 57 | [source, ruby] 58 | input { 59 | cloudwatch { 60 | namespace => "AWS/EC2" 61 | metrics => [ "CPUUtilization" ] 62 | filters => { "tag:Group" => "API-Production" } 63 | region => "us-east-1" 64 | } 65 | } 66 | 67 | [source, ruby] 68 | input { 69 | cloudwatch { 70 | namespace => "AWS/EBS" 71 | metrics => ["VolumeQueueLength"] 72 | filters => { "tag:Monitoring" => "Yes" } 73 | region => "us-east-1" 74 | } 75 | } 76 | 77 | [source, ruby] 78 | input { 79 | cloudwatch { 80 | namespace => "AWS/RDS" 81 | metrics => ["CPUUtilization", "CPUCreditUsage"] 82 | filters => { "EngineName" => "mysql" } # Only supports EngineName, DatabaseClass and DBInstanceIdentifier 83 | region => "us-east-1" 84 | } 85 | } 86 | 87 | [source, ruby] 88 | input { 89 | cloudwatch { 90 | namespace => "sqlserver_test2" 91 | metrics => [ "Memory Available Bytes"] 92 | filters => { 93 | InstanceId => "i-xxxxxxxxxxx" 94 | objectname => "Memory" 95 | } 96 | combined => true 97 | interval => 600 98 | period => 300 99 | } 100 | } 101 | 102 | 103 | [id="plugins-{type}s-{plugin}-options"] 104 | ==== Cloudwatch Input Configuration Options 105 | 106 | This plugin supports the following configuration options plus the <> described later. 107 | 108 | [cols="<,<,<",options="header",] 109 | |======================================================================= 110 | |Setting |Input type|Required 111 | | <> |<>|No 112 | | <> |<>|No 113 | | <> |<>|No 114 | | <> |<>|No 115 | | <> |<>|See <> 116 | | <> |<>|No 117 | | <> |<>|No 118 | | <> |<>|No 119 | | <> |<>|No 120 | | <> |<>|No 121 | | <> |<>|No 122 | | <> |<>|No 123 | | <> |<>|No 124 | | <> |<>|No 125 | | <> |<>|No 126 | | <> |<>|No 127 | | <> |<>|No 128 | |======================================================================= 129 | 130 | Also see <> for a list of options supported by all 131 | input plugins. 132 | 133 |   134 | 135 | [id="plugins-{type}s-{plugin}-access_key_id"] 136 | ===== `access_key_id` 137 | 138 | * Value type is <> 139 | * There is no default value for this setting. 140 | 141 | This plugin uses the AWS SDK and supports several ways to get credentials, which will be tried in this order: 142 | 143 | 1. Static configuration, using `access_key_id` and `secret_access_key` params in logstash plugin config 144 | 2. External credentials file specified by `aws_credentials_file` 145 | 3. Environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` 146 | 4. Environment variables `AMAZON_ACCESS_KEY_ID` and `AMAZON_SECRET_ACCESS_KEY` 147 | 5. IAM Instance Profile (available when running inside EC2) 148 | 149 | [id="plugins-{type}s-{plugin}-aws_credentials_file"] 150 | ===== `aws_credentials_file` 151 | 152 | * Value type is <> 153 | * There is no default value for this setting. 154 | 155 | Path to YAML file containing a hash of AWS credentials. 156 | This file will only be loaded if `access_key_id` and 157 | `secret_access_key` aren't set. The contents of the 158 | file should look like this: 159 | 160 | [source,ruby] 161 | ---------------------------------- 162 | :access_key_id: "12345" 163 | :secret_access_key: "54321" 164 | ---------------------------------- 165 | 166 | 167 | [id="plugins-{type}s-{plugin}-combined"] 168 | ===== `combined` 169 | 170 | * Value type is <> 171 | * Default value is `false` 172 | 173 | Use this for namespaces that need to combine the dimensions like S3 and SNS. 174 | 175 | [id="plugins-{type}s-{plugin}-endpoint"] 176 | ===== `endpoint` 177 | 178 | * Value type is <> 179 | * There is no default value for this setting. 180 | 181 | The endpoint to connect to. By default it is constructed using the value of `region`. 182 | This is useful when connecting to S3 compatible services, but beware that these aren't 183 | guaranteed to work correctly with the AWS SDK. 184 | 185 | [id="plugins-{type}s-{plugin}-filters"] 186 | ===== `filters` 187 | 188 | * This setting can be required or optional. See note below. 189 | * Value type is <> 190 | * There is no default value for this setting. 191 | 192 | NOTE: This setting is optional when the namespace is `AWS/EC2`. Otherwise this is a required field. 193 | 194 | Specify the filters to apply when fetching resources. Follow the AWS convention: 195 | 196 | * Instances: { 'instance-id' => 'i-12344321' } 197 | * Tags: { "tag:Environment" => "Production" } 198 | * Volumes: { 'attachment.status' => 'attached' } 199 | 200 | Each namespace uniquely support certain dimensions. Please consult the documentation 201 | to ensure you're using valid filters. 202 | 203 | [id="plugins-{type}s-{plugin}-interval"] 204 | ===== `interval` 205 | 206 | * Value type is <> 207 | * Default value is `900` 208 | 209 | Set how frequently CloudWatch should be queried 210 | 211 | The default, `900`, means check every 15 minutes. Setting this value too low 212 | (generally less than 300) results in no metrics being returned from CloudWatch. 213 | 214 | [id="plugins-{type}s-{plugin}-metrics"] 215 | ===== `metrics` 216 | 217 | * Value type is <> 218 | * Default value is `["CPUUtilization", "DiskReadOps", "DiskWriteOps", "NetworkIn", "NetworkOut"]` 219 | 220 | Specify the metrics to fetch for the namespace. The defaults are AWS/EC2 specific. See http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/aws-namespaces.html 221 | for the available metrics for other namespaces. 222 | 223 | [id="plugins-{type}s-{plugin}-namespace"] 224 | ===== `namespace` 225 | 226 | * Value type is <> 227 | * Default value is `"AWS/EC2"` 228 | 229 | If undefined, LogStash will complain, even if codec is unused. 230 | The service namespace of the metrics to fetch. 231 | 232 | The default is for the EC2 service. See http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/aws-namespaces.html 233 | for valid values. 234 | 235 | [id="plugins-{type}s-{plugin}-period"] 236 | ===== `period` 237 | 238 | * Value type is <> 239 | * Default value is `300` 240 | 241 | Set the granularity of the returned datapoints. 242 | 243 | Must be at least 60 seconds and in multiples of 60. 244 | 245 | [id="plugins-{type}s-{plugin}-proxy_uri"] 246 | ===== `proxy_uri` 247 | 248 | * Value type is <> 249 | * There is no default value for this setting. 250 | 251 | URI to proxy server if required 252 | 253 | [id="plugins-{type}s-{plugin}-region"] 254 | ===== `region` 255 | 256 | * Value type is <> 257 | * Default value is `"us-east-1"` 258 | 259 | The AWS Region 260 | 261 | [id="plugins-{type}s-{plugin}-role_arn"] 262 | ===== `role_arn` 263 | 264 | * Value type is <> 265 | * There is no default value for this setting. 266 | 267 | The AWS IAM Role to assume, if any. 268 | This is used to generate temporary credentials, typically for cross-account access. 269 | See the https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html[AssumeRole API documentation] for more information. 270 | 271 | [id="plugins-{type}s-{plugin}-role_session_name"] 272 | ===== `role_session_name` 273 | 274 | * Value type is <> 275 | * Default value is `"logstash"` 276 | 277 | Session name to use when assuming an IAM role. 278 | 279 | [id="plugins-{type}s-{plugin}-secret_access_key"] 280 | ===== `secret_access_key` 281 | 282 | * Value type is <> 283 | * There is no default value for this setting. 284 | 285 | The AWS Secret Access Key 286 | 287 | [id="plugins-{type}s-{plugin}-session_token"] 288 | ===== `session_token` 289 | 290 | * Value type is <> 291 | * There is no default value for this setting. 292 | 293 | The AWS Session token for temporary credential 294 | 295 | [id="plugins-{type}s-{plugin}-statistics"] 296 | ===== `statistics` 297 | 298 | * Value type is <> 299 | * Default value is `["SampleCount", "Average", "Minimum", "Maximum", "Sum"]` 300 | 301 | Specify the statistics to fetch for each namespace 302 | 303 | [id="plugins-{type}s-{plugin}-use_ssl"] 304 | ===== `use_ssl` 305 | 306 | * Value type is <> 307 | * Default value is `true` 308 | 309 | Make sure we require the V1 classes when including this module. 310 | require 'aws-sdk' will load v2 classes. 311 | Should we require (true) or disable (false) using SSL for communicating with the AWS API 312 | The AWS SDK for Ruby defaults to SSL so we preserve that 313 | 314 | 315 | 316 | [id="plugins-{type}s-{plugin}-common-options"] 317 | include::{include_path}/{type}.asciidoc[] 318 | 319 | :default_codec!: 320 | -------------------------------------------------------------------------------- /lib/logstash/inputs/cloudwatch.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require "logstash/inputs/base" 3 | require "logstash/namespace" 4 | require "logstash/plugin_mixins/aws_config" 5 | require "logstash/util" 6 | require "stud/interval" 7 | require "aws-sdk" 8 | 9 | # Pull events from the Amazon Web Services CloudWatch API. 10 | # 11 | # To use this plugin, you *must* have an AWS account, and the following policy. 12 | # 13 | # Typically, you should setup an IAM policy, create a user and apply the IAM policy to the user. 14 | # 15 | # A sample policy for EC2 metrics is as follows: 16 | # 17 | # [source,json] 18 | # { 19 | # "Version": "2012-10-17", 20 | # "Statement": [ 21 | # { 22 | # "Sid": "Stmt1444715676000", 23 | # "Effect": "Allow", 24 | # "Action": [ 25 | # "cloudwatch:GetMetricStatistics", 26 | # "cloudwatch:ListMetrics" 27 | # ], 28 | # "Resource": "*" 29 | # }, 30 | # { 31 | # "Sid": "Stmt1444716576170", 32 | # "Effect": "Allow", 33 | # "Action": [ 34 | # "ec2:DescribeInstances" 35 | # ], 36 | # "Resource": "*" 37 | # } 38 | # ] 39 | # } 40 | # 41 | # See http://aws.amazon.com/iam/ for more details on setting up AWS identities. 42 | # 43 | # # Configuration Example 44 | # [source, ruby] 45 | # input { 46 | # cloudwatch { 47 | # namespace => "AWS/EC2" 48 | # metrics => [ "CPUUtilization" ] 49 | # filters => { "tag:Group" => "API-Production" } 50 | # region => "us-east-1" 51 | # } 52 | # } 53 | # 54 | # input { 55 | # cloudwatch { 56 | # namespace => "AWS/EBS" 57 | # metrics => ["VolumeQueueLength"] 58 | # filters => { "tag:Monitoring" => "Yes" } 59 | # region => "us-east-1" 60 | # } 61 | # } 62 | # 63 | # input { 64 | # cloudwatch { 65 | # namespace => "AWS/RDS" 66 | # metrics => ["CPUUtilization", "CPUCreditUsage"] 67 | # filters => { "EngineName" => "mysql" } # Only supports EngineName, DatabaseClass and DBInstanceIdentifier 68 | # region => "us-east-1" 69 | # } 70 | # } 71 | # 72 | 73 | class LogStash::Inputs::CloudWatch < LogStash::Inputs::Base 74 | include LogStash::PluginMixins::AwsConfig::V2 75 | 76 | config_name "cloudwatch" 77 | 78 | # If undefined, LogStash will complain, even if codec is unused. 79 | default :codec, "plain" 80 | 81 | # The service namespace of the metrics to fetch. 82 | # 83 | # The default is for the EC2 service. 84 | # 85 | # See http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/aws-namespaces.html 86 | # for valid values. 87 | config :namespace, :validate => :string, :default => 'AWS/EC2' 88 | 89 | # Specify the metrics to fetch for the namespace. The defaults are AWS/EC2 specific. 90 | # 91 | # See http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/aws-namespaces.html 92 | # for the available metrics for other namespaces. 93 | config :metrics, :validate => :array, :default => [ 'CPUUtilization', 'DiskReadOps', 'DiskWriteOps', 'NetworkIn', 'NetworkOut' ] 94 | 95 | # Specify the statistics to fetch for each namespace 96 | config :statistics, :validate => :array, :default => [ 'SampleCount', 'Average', 'Minimum', 'Maximum', 'Sum' ] 97 | 98 | # Set how frequently CloudWatch should be queried 99 | # 100 | # The default, `900`, means check every 15 minutes. Setting this value too low 101 | # (generally less than 300) results in no metrics being returned from CloudWatch. 102 | config :interval, :validate => :number, :default => (60 * 15) 103 | 104 | # Set the granularity of the returned datapoints. 105 | # 106 | # Must be at least 60 seconds and in multiples of 60. 107 | config :period, :validate => :number, :default => (60 * 5) 108 | 109 | # Specify the filters to apply when fetching resources: 110 | # 111 | # Instances: { 'instance-id' => 'i-12344321' } 112 | # Tags: { 'tag:Environment' => 'Production' } 113 | # Volumes: { 'attachment.status' => 'attached' } 114 | # 115 | # This needs to follow the AWS convention of specifiying filters. 116 | # 117 | # Each namespace uniquely supports certain dimensions. Consult the documentation 118 | # to ensure you're using valid filters. 119 | config :filters, :validate => :array 120 | 121 | # Use this for namespaces that need to combine the dimensions like S3 and SNS. 122 | config :combined, :validate => :boolean, :default => false 123 | 124 | def aws_service_endpoint(region) 125 | { region: region } 126 | end 127 | 128 | def register 129 | raise 'Interval needs to be higher than period' unless @interval >= @period 130 | raise 'Interval must be divisible by period' unless @interval % @period == 0 131 | raise "Filters must be defined for when using #{@namespace} namespace" if @filters.nil? && filters_required?(@namespace) 132 | 133 | @last_check = Time.now 134 | end # def register 135 | 136 | def filters_required?(namespace) 137 | case namespace 138 | when 'AWS/EC2' 139 | false 140 | else 141 | true 142 | end 143 | end 144 | 145 | # Runs the poller to get metrics for the provided namespace 146 | # 147 | # @param queue [Array] Logstash queue 148 | def run(queue) 149 | while !stop? 150 | start = Time.now 151 | 152 | @logger.info('Polling CloudWatch API') 153 | 154 | raise 'No metrics to query' unless metrics_for(@namespace).count > 0 155 | 156 | # For every metric 157 | metrics_for(@namespace).each do |metric| 158 | @logger.debug "Polling metric #{metric}" 159 | if @filters.nil? 160 | from_resources(queue, metric) 161 | else 162 | @logger.debug "Filters: #{aws_filters}" 163 | @combined ? from_filters(queue, metric) : from_resources(queue, metric) 164 | end 165 | end 166 | sleep_for = @interval - (Time.now - start) 167 | Stud.stoppable_sleep(sleep_for) { stop? } if sleep_for > 0 168 | end # loop 169 | end # def run 170 | 171 | private 172 | 173 | # Gets metrics from provided resources. 174 | # 175 | # @param queue [Array] Logstash queue 176 | # @param metric [String] Metric name 177 | def from_resources(queue, metric) 178 | # For every dimension in the metric 179 | resources.each_pair do |dimension, dim_resources| 180 | # For every resource in the dimension 181 | dim_resources = *dim_resources 182 | dim_resources.each do |resource| 183 | @logger.debug "Polling resource #{dimension}: #{resource}" 184 | 185 | options = metric_options(@namespace, metric) 186 | options[:dimensions] = [ { name: dimension, value: resource } ] 187 | 188 | datapoints = clients['CloudWatch'].get_metric_statistics(options) 189 | @logger.debug "DPs: #{datapoints.data}" 190 | # For every event in the resource 191 | datapoints[:datapoints].each do |datapoint| 192 | event_hash = datapoint.to_hash.update(options) 193 | event_hash[dimension.to_sym] = resource 194 | event = LogStash::Event.new(cleanup(event_hash)) 195 | decorate(event) 196 | queue << event 197 | end 198 | end 199 | end 200 | end 201 | 202 | # Gets metrics from provided filter options 203 | # 204 | # @param queue [Array] Logstash queue 205 | # @param metric [String] Metric name 206 | def from_filters(queue, metric) 207 | options = metric_options(@namespace, metric) 208 | options[:dimensions] = aws_filters 209 | @logger.debug "Dim: #{options[:dimensions]}" 210 | 211 | datapoints = clients['CloudWatch'].get_metric_statistics(options) 212 | @logger.debug "DPs: #{datapoints.data}" 213 | 214 | datapoints[:datapoints].each do |datapoint| 215 | event_hash = datapoint.to_hash.update(options) 216 | aws_filters.each do |dimension| 217 | event_hash[dimension[:name].to_sym] = dimension[:value] 218 | end 219 | 220 | event = LogStash::Event.new(cleanup(event_hash)) 221 | decorate(event) 222 | queue << event 223 | end 224 | end 225 | 226 | # Cleans up an event to remove unneeded fields and format time 227 | # 228 | # @param event [Hash] Raw event 229 | # 230 | # @return [Hash] Cleaned event 231 | def cleanup(event) 232 | event.delete :statistics 233 | event.delete :dimensions 234 | event[:start_time] = Time.parse(event[:start_time]).utc 235 | event[:end_time] = Time.parse(event[:end_time]).utc 236 | LogStash::Util.stringify_symbols(event) 237 | end 238 | 239 | # Dynamic AWS client instantiator for retrieving the proper client 240 | # for the provided namespace 241 | # 242 | # @return [Hash] 243 | def clients 244 | @clients ||= Hash.new do |client_hash, namespace| 245 | namespace = namespace[4..-1] if namespace[0..3] == 'AWS/' 246 | namespace = 'EC2' if namespace == 'EBS' 247 | cls = Aws.const_get(namespace) 248 | # TODO: Move logger configuration into mixin. 249 | client_hash[namespace] = cls::Client.new(aws_options_hash.merge(:logger => @logger)) 250 | end 251 | end 252 | 253 | # Gets metrics for a provided namespace based on the union of available and 254 | # found metrics 255 | # 256 | # @param namespace [String] Namespace to retrieve metrics for 257 | # 258 | # @return [Hash] 259 | def metrics_for(namespace) 260 | metrics_available[namespace] & @metrics 261 | end 262 | 263 | # Gets available metrics for a given namespace 264 | # 265 | # @return [Hash] 266 | def metrics_available 267 | @metrics_available ||= Hash.new do |metrics_hash, namespace| 268 | metrics_hash[namespace] = [] 269 | 270 | clients['CloudWatch'].list_metrics({ namespace: namespace })[:metrics].each do |metrics| 271 | metrics_hash[namespace].push metrics[:metric_name] 272 | end 273 | metrics_hash[namespace] 274 | end 275 | end 276 | 277 | # Gets options for querying against Cloudwatch for a given metric and namespace 278 | # 279 | # @param namespace [String] Namespace to query in 280 | # @param metric [String] Metric to query for 281 | # 282 | # @return [Hash] 283 | def metric_options(namespace, metric) 284 | { 285 | namespace: namespace, 286 | metric_name: metric, 287 | start_time: (Time.now - @interval).iso8601, 288 | end_time: Time.now.iso8601, 289 | period: @period, 290 | statistics: @statistics 291 | } 292 | end 293 | 294 | # Filters used in querying the AWS SDK for resources 295 | # 296 | # @return [Array] 297 | def aws_filters 298 | @filters.collect do |key, value| 299 | if @combined 300 | { name: key, value: value } 301 | else 302 | value = [value] unless value.is_a? Array 303 | { name: key, values: value } 304 | end 305 | end 306 | end 307 | 308 | # Gets resources based on the provided namespace 309 | # 310 | # @see http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html 311 | # 312 | # @return [Array] 313 | def resources 314 | case @namespace 315 | when 'AWS/EC2' 316 | instances = clients[@namespace].describe_instances(filter_options)[:reservations].collect do |r| 317 | r[:instances].collect{ |i| i[:instance_id] } 318 | end.flatten 319 | 320 | { 'InstanceId' => instances } 321 | when 'AWS/EBS' 322 | volumes = clients[@namespace].describe_volumes(filters: aws_filters)[:volumes].collect do |a| 323 | a[:attachments].collect{ |v| v[:volume_id] } 324 | end.flatten 325 | 326 | @logger.debug "AWS/EBS Volumes: #{volumes}" 327 | 328 | { 'VolumeId' => volumes } 329 | else 330 | @filters 331 | end 332 | end 333 | 334 | def filter_options 335 | @filters.nil? ? {} : { :filters => aws_filters } 336 | end 337 | 338 | end # class LogStash::Inputs::CloudWatch 339 | -------------------------------------------------------------------------------- /logstash-input-cloudwatch.gemspec: -------------------------------------------------------------------------------- 1 | Gem::Specification.new do |s| 2 | s.name = 'logstash-input-cloudwatch' 3 | s.version = '2.2.4' 4 | s.licenses = ['Apache-2.0'] 5 | s.summary = "Pulls events from the Amazon Web Services CloudWatch API " 6 | s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program" 7 | s.authors = ["Jurgens du Toit"] 8 | s.email = 'jrgns@eagerelk.com' 9 | s.homepage = "http://eagerelk.com" 10 | s.require_paths = ["lib"] 11 | 12 | # Files 13 | s.files = Dir[ 14 | '*.gemspec', 15 | '*.md', 16 | 'CONTRIBUTORS', 17 | 'docs/**/*', 18 | 'Gemfile', 19 | 'lib/**/*', 20 | 'LICENSE', 21 | 'NOTICE.TXT', 22 | 'spec/**/*', 23 | 'vendor/**/*', 24 | 'vendor/jar-dependencies/**/*.jar', 25 | 'vendor/jar-dependencies/**/*.rb', 26 | 'VERSION', 27 | ] 28 | 29 | # Tests 30 | s.test_files = s.files.grep(%r{^(test|spec|features)/}) 31 | 32 | # Special flag to let us know this is actually a logstash plugin 33 | s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" } 34 | 35 | # Gem dependencies 36 | s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99" 37 | s.add_runtime_dependency 'logstash-codec-plain' 38 | s.add_runtime_dependency 'stud', '>= 0.0.19' 39 | s.add_runtime_dependency 'logstash-mixin-aws', '>= 4.3.0' 40 | s.add_development_dependency 'logstash-devutils' 41 | end 42 | -------------------------------------------------------------------------------- /spec/inputs/cloudwatch_spec.rb: -------------------------------------------------------------------------------- 1 | require 'logstash/devutils/rspec/spec_helper' 2 | require 'logstash/devutils/rspec/shared_examples' 3 | require 'logstash/inputs/cloudwatch' 4 | require 'aws-sdk' 5 | 6 | describe LogStash::Inputs::CloudWatch do 7 | subject { LogStash::Inputs::CloudWatch.new(config) } 8 | let(:config) { 9 | { 10 | 'access_key_id' => '1234', 11 | 'secret_access_key' => 'secret', 12 | 'metrics' => [ 'CPUUtilization' ], 13 | 'region' => 'us-east-1' 14 | } 15 | } 16 | 17 | 18 | before do 19 | Aws.config[:stub_responses] = true 20 | Thread.abort_on_exception = true 21 | end 22 | 23 | shared_examples_for 'it requires filters' do 24 | context 'without filters' do 25 | it "raises an error" do 26 | expect { subject.register }.to raise_error(StandardError) 27 | end 28 | end 29 | 30 | context 'with filters' do 31 | let (:config) { super().merge('filters' => { 'tag:Monitoring' => 'Yes' })} 32 | 33 | it "registers succesfully" do 34 | expect { subject.register }.to_not raise_error 35 | end 36 | end 37 | end 38 | 39 | shared_examples_for 'it does not require filters' do 40 | context 'without filters' do 41 | it "registers succesfully" do 42 | expect { subject.register }.to_not raise_error 43 | end 44 | end 45 | 46 | context 'with filters' do 47 | let (:config) { super().merge('filters' => { 'tag:Monitoring' => 'Yes' })} 48 | 49 | it "registers succesfully" do 50 | expect { subject.register }.to_not raise_error 51 | end 52 | end 53 | end 54 | 55 | describe 'shutdown' do 56 | let(:metrics) { double("metrics") } 57 | let(:config) { super().merge('namespace' => 'AWS/EC2') } 58 | 59 | before do 60 | allow(subject).to receive(:metrics_for).and_return(metrics) 61 | allow(metrics).to receive(:count).and_return(1) 62 | allow(metrics).to receive(:each).and_return(['DiskWriteBytes']) 63 | end 64 | 65 | it_behaves_like "an interruptible input plugin" 66 | end 67 | 68 | describe '#register' do 69 | 70 | context "EC2 namespace" do 71 | let(:config) { super().merge('namespace' => 'AWS/EC2') } 72 | it_behaves_like 'it does not require filters' 73 | end 74 | 75 | context "EBS namespace" do 76 | let(:config) { super().merge('namespace' => 'AWS/EBS') } 77 | it_behaves_like 'it requires filters' 78 | end 79 | 80 | context "RDS namespace" do 81 | let(:config) { super().merge('namespace' => 'AWS/RDS') } 82 | it_behaves_like 'it requires filters' 83 | end 84 | 85 | end 86 | end 87 | -------------------------------------------------------------------------------- /spec/integration/cloudwatch_spec.rb: -------------------------------------------------------------------------------- 1 | require "logstash/devutils/rspec/spec_helper" 2 | require "logstash/inputs/cloudwatch" 3 | require "aws-sdk" 4 | 5 | describe LogStash::Inputs::CloudWatch, :integration => true do 6 | 7 | let(:settings) { { "access_key_id" => ENV['AWS_ACCESS_KEY_ID'], 8 | "secret_access_key" => LogStash::Util::Password.new(ENV['AWS_SECRET_ACCESS_KEY']), 9 | "region" => ENV["AWS_REGION"] || "us-east-1", 10 | "namespace" => "AWS/S3", 11 | 'filters' => { "BucketName" => "*"}, 12 | 'metrics' => ["BucketSizeBytes","NumberOfObjects"] 13 | 14 | }} 15 | 16 | def metrics_for(settings) 17 | cw = LogStash::Inputs::CloudWatch.new(settings) 18 | cw.register 19 | cw.send('metrics_for', settings['namespace']) 20 | end 21 | 22 | # 23 | it "should not raise a type error when using a password" do 24 | expect{metrics_for(settings)}.not_to raise_error 25 | end 26 | end 27 | --------------------------------------------------------------------------------