没有'Access-Control-Allow-Origin-http插件logstash
No ‘Access-Control-Allow-Origin- http plugin logstash
我目前正在尝试通过使用 tcp 输入对 Logstash 执行 JavaScript post。
JavaScript Post
xhr = new XMLHttpRequest();
var url = "http://localhost:5043";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/json");
var data = JSON.stringify({"test" : hello});
xhr.send(data);
Logstash 配置文件
input {
tcp {
port => 5043
}
}
filter{
}
output {
stdout {
codec => rubydebug
}
}
控制台输出
{
"message" => "OPTIONS / HTTP/1.1\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.611Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Host: localhost:5043\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.620Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Connection: keep-alive\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.621Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Access-Control-Request-Method: POST\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.622Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Origin: http://atgdev11\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.623Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.626Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Access-Control-Request-Headers: content-type\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.634Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Accept: */*\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.651Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Referer: http://test/Welcome.jsp\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.653Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Accept-Encoding: gzip, deflate, sdch, br\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.719Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Accept-Language: en-US,en;q=0.8\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.720Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
我似乎看不到我的 json 数据 {"test" : 你好} 传递到 logstash 会不会是我的 [=42= 有问题] 文件 ?请帮助
我也试过以下方法:
input {
http {
port => 5043
}
}
我得到以下错误是浏览器:
XMLHttpRequest cannot load http://localhost:5043/. Response to
preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://test/' is therefore not allowed access.
关于我需要看什么,请指导我正确的方向?我对 ELK 堆栈很陌生
谢谢
如果在 tcp
插件中添加 host
会怎么样:
input {
tcp {
host => "localhost"
port => 5043
mode => "server" <-- change if it's a client
}
}
或 您应该在您的 ES yml
中按照此 ticket:
进行以下设置
http.cors.enabled: true
http.cors.allow-origin: "*"
希望对您有所帮助!
我目前正在尝试通过使用 tcp 输入对 Logstash 执行 JavaScript post。
JavaScript Post
xhr = new XMLHttpRequest();
var url = "http://localhost:5043";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/json");
var data = JSON.stringify({"test" : hello});
xhr.send(data);
Logstash 配置文件
input {
tcp {
port => 5043
}
}
filter{
}
output {
stdout {
codec => rubydebug
}
}
控制台输出
{
"message" => "OPTIONS / HTTP/1.1\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.611Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Host: localhost:5043\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.620Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Connection: keep-alive\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.621Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Access-Control-Request-Method: POST\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.622Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Origin: http://atgdev11\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.623Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.626Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Access-Control-Request-Headers: content-type\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.634Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Accept: */*\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.651Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Referer: http://test/Welcome.jsp\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.653Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Accept-Encoding: gzip, deflate, sdch, br\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.719Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
{
"message" => "Accept-Language: en-US,en;q=0.8\r",
"@version" => "1",
"@timestamp" => "2016-12-15T09:58:54.720Z",
"host" => "0:0:0:0:0:0:0:1",
"port" => 55867,
}
我似乎看不到我的 json 数据 {"test" : 你好} 传递到 logstash 会不会是我的 [=42= 有问题] 文件 ?请帮助
我也试过以下方法:
input {
http {
port => 5043
}
}
我得到以下错误是浏览器:
XMLHttpRequest cannot load http://localhost:5043/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://test/' is therefore not allowed access.
关于我需要看什么,请指导我正确的方向?我对 ELK 堆栈很陌生
谢谢
如果在 tcp
插件中添加 host
会怎么样:
input {
tcp {
host => "localhost"
port => 5043
mode => "server" <-- change if it's a client
}
}
或 您应该在您的 ES yml
中按照此 ticket:
http.cors.enabled: true
http.cors.allow-origin: "*"
希望对您有所帮助!