[英]What host and port to use for http plugin for a Logstash container running in K8s pod?
I am receiving this error Error: Cannot assign requested address
in logstash when attempting to set up a pipeline that uses http input plugin. 我收到此错误
Error: Cannot assign requested address
尝试设置使用http输入插件的管道时, Error: Cannot assign requested address
在logstash中Error: Cannot assign requested address
。
I am trying to send data from a Python process to logstash using the Python requests http library. 我正在尝试使用Python请求http库将数据从Python进程发送到logstash。 I am not sure which host and port to use in my logstash http input configs.
我不确定在logstash http输入配置中使用哪个主机和端口。 Should I be using the defaults, the logstash pod ClusterIP service IP, the logstash pod IP, or something else?
我应该使用默认值,logstash Pod ClusterIP服务IP,logstash Pod IP还是其他?
input {
http {
host => "0.0.0.0"
port => 80
}
}
The defaults url is 0.0.0.0:80 but I get a connection error on the Python side. 默认网址为0.0.0.0:80,但在Python端出现连接错误。 I've also tried the url of the Logstash K8s pod that the logstash container is running in and get
Error: Cannot assign requested address
in the logstash container. 我也尝试过运行logstash容器的Logstash K8s pod的URL并得到
Error: Cannot assign requested address
在Logstash容器中Error: Cannot assign requested address
。
Edit: included logstash service details 编辑:包括logstash服务详细信息
Name: central-logstash
Namespace: default
Labels: app=logstash
chart=logstash-1.10.0
heritage=Tiller
release=central-logstash
Annotations: <none>
Selector: app=logstash,release=central-logstash
Type: ClusterIP
IP: 10.110.133.189
Port: beats 5044/TCP
TargetPort: beats/TCP
Endpoints: 192.168.0.79:5044
Session Affinity: None
Events: <none>
As per your information, you are using helm to deploy and the version of the docker image from elastic on the stable chart is the 7.1.1
根据您的信息,您正在使用Helm进行部署,并且稳定图表上来自Elastic的Docker映像版本为
7.1.1
If you check the Dockerfile for that version 如果您检查Dockerfile的那个版本
They create a user logstash here 他们在此处创建用户logstash
And during the Dockerfile definition switch to root but returns at the end to that user, because of that you cannot use port 80
并且在Dockerfile定义期间切换到root用户,但最后返回给该用户,因此您不能使用端口
80
Try to use a different port like 8080
and adjust all other services that need to connect to logstash to use the new port or map that port on the service to use on the services level the 80
port but with the target pointing to the 8080
尝试使用类似
8080
的其他端口,并调整需要连接到logstash的所有其他服务以使用新端口,或将该服务上的该端口映射为在服务级别上使用80
端口,但目标指向8080
I ended up switching to TCP to avoid HTTP headers in my messages. 我最终切换到TCP以避免消息中的HTTP标头。
In my Logstash Helm configuration ( https://github.com/helm/charts/tree/master/stable/logstash ), I set up the service as such: 在我的Logstash Helm配置( https://github.com/helm/charts/tree/master/stable/logstash )中,我将服务设置为:
service:
type: ClusterIP
annotations: {}
ports:
tcp-data:
port: 1514
targetPort: tcp-data
protocol: TCP
tcp-event:
port: 1515
targetPort: tcp-event
protocol: TCP
ports:
- name: tcp-data
containerPort: 1514
protocol: TCP
- name: tcp-event
containerPort: 1515
protocol: TCP
And the tcp plugin: 和tcp插件:
inputs:
data: |-
input {
tcp {
port => 1514
type => json
}
}
event: |-
input {
tcp {
port => 1515
type => json
}
}
And then on the Python side, I was able to use the socket library to send messages to Logstash using the Logstash clusterIP service's IP and port 1514 or 1515. 然后在Python方面,我能够使用套接字库通过Logstash clusterIP服务的IP和端口1514或1515将消息发送到Logstash。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.