如何使用 EC2 从其他机器访问 logstash http 输入?

How to access logstash http input from other machine with EC2?

我正在尝试在 EC2 计算机中设置 logstash。但是我无法在我的 ec2 实例之外添加数据(例如我的本地电脑)。

我正在尝试这个:

curl -XPUT 'http:/mypublicip:31311/twitter/tweet/1' -d 'hello'

但是,我没有得到任何结果。

当我像这样在 EC2 机器内部尝试时:

curl -XPUT 'http://127.0.0.1:31311/twitter/tweet/1' -d 'hello'

它工作正常。

这是我的安全规则:

Outbound
Type: Custom TCP Rule
Protocol: TCP
Port Range: 31311
Destination: ::/0, 0.0.0.0/0

这是我的 logstash 配置文件:

input
{
  http
  {
    host => "0.0.0.0"
    port => 31311
  }
}

output
{
        elasticsearch
        {
                hosts => ["localhost:9200"]
        }

        stdout
        {
                codec => rubydebug
        }
}

如何解决这个问题?

打开安全组的入站,因为您希望外部机器连接到 EC2 实例。试试这个,看看它是否有效。

进站

Type: Custom TCP Rule
Protocol: TCP
Port Range: 31311
Source: 0.0.0.0/0