简体   繁体   English

在K8s pod中运行的Logstash容器的http插件要使用什么主机和端口?

[英]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.

相关问题 k8s API 通过pod内部的python访问 - k8s API Access through python inside the pod Python k8s 客户端:调用 list_namespaced_pod 时,是否可以在作业名称查询中使用通配符? - Python k8s client: is there a way to use wildcards on job-name query, when calling list_namespaced_pod? Pod 到 pod 通信不适用于 k8s 中的 Python 套接字 - Pod-to-pod communication doens't work with Python socket in k8s 在 K8S 上运行的 Mongo 副本集出现奇怪(和随机)错误 - Strange (and random) error in Mongo replicaset running on K8S 从运行的 python 实例中读取 k8s 部署标签 - Read k8s deployment labels from running python instance 为什么我不能在 k8s pod 中杀死 python3 进程? - Why I cannot kill python3 process in k8s pod? 有没有办法以编程方式在部署到GKE的k8s容器内检索应用程序默认API密钥? - Is there a way to retrieve the Application Default API key programmatically inside a k8s pod deployed to GKE? 如何在 python k8s 客户端中以 root 身份运行“connect_get_namespaced_pod_exec” - How to run 'connect_get_namespaced_pod_exec' as root in python k8s client 如何在python中使用K8S env变量 - How to use K8S env variable in python k8s cronjob 未运行更新的代码,但手动创建此作业有效 - k8s cronjob not running updated codes, but manual create this job works
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM