使用IAM EC2将Windows Logstash输出到AWS SQS角色“无法访问SQS队列”

时间:2015-02-20 20:52:26

标签: elasticsearch windows-server-2008 logstash amazon-sqs amazon-iam

我觉得我在这里遗漏了一些东西,因为Interwebs上的任何人似乎都没有任何问题。我有一个Windows Server 2008 R2 EC2实例设置,其IAM角色允许sqs:SendMessage。我使用AWS CLI和命令aws sqs send-message在命令行上成功发送了一条消息。当我尝试使用Logstash-1.4.2时,出现以下错误:

Unable to access SQS queue 'Dev-ELK-LogstashBuffer': The specified queue does not exist or you do not have access to it. {:level=>:error}
Failed to flush outgoing items {:outgoing_count=>1, :exception=>#<NoMethodError: undefined method `batch_send' for nil:NilClass>, :backtrace=>
["C:/logstash/logstash-1.4.2/lib/logstash/outputs/sqs.rb:131:in `flush'", 
"C:/logstash/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/stud-0.0.17/lib/stud/buffer.rb:219:in `buffer_flush'", 
"org/jruby/RubyHash.java:1339:in `each'", 
"C:/logstash/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/stud-0.0.17/lib/stud/buffer.rb:216:in `buffer_flush'", 
"C:/logstash/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/stud-0.0.17/lib/stud/buffer.rb:159:in `buffer_receive'", 
"C:/logstash/logstash-1.4.2/lib/logstash/outputs/sqs.rb:123:in `receive'", 
"C:/logstash/logstash-1.4.2/lib/logstash/outputs/base.rb:86:in `handle'", 
"(eval):129:in `initialize'", 
"org/jruby/RubyProc.java:271:in `call'", 
"C:/logstash/logstash-1.4.2/lib/logstash/pipeline.rb:266:in `output'", 
"C:/logstash/logstash-1.4.2/lib/logstash/pipeline.rb:225:in `outputworker'", 
"C:/logstash/logstash-1.4.2/lib/logstash/pipeline.rb:152:in `start_outputs'"], 
:level=>:warn}

这是logstash的输出配置:

output {
    sqs {
        queue => "Dev-ELK-LogstashBuffer"
        region  => "us-west-2"
        use_ssl => true
    }

    stdout { codec => rubydebug }
}

我可以直接使用elasticsearch输出,但尝试在我的服务器和elasticsearch集群之间添加消息队列缓冲区。

谢谢!

1 个答案:

答案 0 :(得分:1)

正确的IAM政策:

{
    "Statement":[
        {
            "Resource": [
                "arn:aws:sqs:us-west-2:1111111:Dev-ELK-LogstashBuffer"
            ],
            "Action":[
                "sqs:SendMessage",
                "sqs:GetQueueAttributes",
                "sqs:GetQueueUrl",
                "sqs:ListQueues",
                "sqs:ChangeMessageVisibility"
            ],
            "Effect":"Allow"
        }
    ],
    "Version":"2012-10-17"
}