I have a question about Logstash http
input plugin:
What is the format of URL for sending POST request to Logstash so Logstash can receive JSON message via http
plugin?
Is it something like this: server_name:tcp_port/index
?
I have a question about Logstash http
input plugin:
What is the format of URL for sending POST request to Logstash so Logstash can receive JSON message via http
plugin?
Is it something like this: server_name:tcp_port/index
?
Is it something like this: server_name:tcp_port/index ?
Yes, and the "index" part in your example can be any string. The plugin will grab all HTTP requests sent to the port.
@magnusbaeck Thank you.
I am trying to send HTTP request with Java:
HttpClient httpClient = HttpClientBuilder.create().build();
try {
HttpPost request = new HttpPost("http://host_name:31311/test");
StringEntity params = new StringEntity("{\"field\":\"value\"}");
request.addHeader("content-type", "application/json");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
} catch (Exception ex) {
}
But the data was not sent to Logstash for some reason.
Do you have any ideas what is wrong in this approach?
So what happens? Does the code raise any exceptions or does the program think things are okay?
Testing and debugging things like this with a tool like curl is recommended.
Actually, yes. There is the following exception thrown:
org.apache.http.conn.HttpHostConnectException: Connect to host_name:31311 [host_name] failed: Connection timed out: connect
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:140)
I am on Windows, I tried command open host_name 31311
but I got this:
Connecting To host_name...Could not open connection to the host on port 31311: Connect failed
This is strange, because I am able to send data via HTTP request from another app from the same machine.
Do you have any thoughts about that?
Firewall issue maybe, I don't know.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.