我有一个kuberenetes集群,我正在尝试从集群中的容器收集日志。我正在使用Filebeat收集日志并将其发送到 Elasticsearch ,然后在Kibana中显示。我部署了Kibana和 Elasticsearch ,效果很好。我正在使用DaemonSet部署FileBeat。
这是我用来部署Filebeat的YAML文件。
我从这里使用 list 文件进行部署并进行了一些修改。

https://www.elastic.co/guide/en/beats/filebeat/master/running-on-kubernetes.html

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-config
  namespace: kube-system
  labels:
    k8s-app: filebeat
data:
  filebeat.yml: |-
    filebeat.config:
      inputs:
      - type: log
        # Mounted `filebeat-inputs` configmap:
        paths: /var/lib/docker/containers/*/*.log
        # Reload inputs configs as they change:
        reload.enabled: false
        json.message_key: log
        json.keys_under_root: true
    output.elasticsearch:
      hosts: ['x.x.x.x:9200']
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-inputs
  namespace: kube-system
  labels:
    k8s-app: filebeat
data:
  kubernetes.yml: |-
    - type: docker
      containers.ids:
      - "*"
      processors:
        - add_kubernetes_metadata:
            in_cluster: true
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: filebeat
  namespace: kube-system
  labels:
    k8s-app: filebeat
spec:
  template:
    metadata:
      labels:
        k8s-app: filebeat
    spec:
      serviceAccountName: filebeat
      terminationGracePeriodSeconds: 30
      containers:
      - name: filebeat
        image: docker.elastic.co/beats/filebeat:6.3.1
        args: [
          "-c", "/etc/filebeat.yml",
          "-e",
        ]
        env:
        - name: ELASTICSEARCH_HOST
          value: X.x.x.x
        - name: ELASTICSEARCH_PORT
          value: "9200"
          value:
        securityContext:
          runAsUser: 0
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - name: config
          mountPath: /etc/filebeat.yml
          readOnly: true
          subPath: filebeat.yml
        - name: inputs
          mountPath: /usr/share/filebeat/inputs.d
          readOnly: true
        - name: data
          mountPath: /usr/share/filebeat/data
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
      volumes:
      - name: config
        configMap:
          defaultMode: 0600
          name: filebeat-config
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers
      - name: inputs
        configMap:
          defaultMode: 0600
          name: filebeat-inputs
      # data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart
      - name: data
        hostPath:
          path: /var/lib/filebeat-data
          type: DirectoryOrCreate
---

我检查了运行Filebeat的Pod,它存储了日志。但是不知何故,它不会发布到 Elasticsearch 中。我的确切配置是什么才能使其发布到Elasticsearch。我现在坚持了几天,没有选择了。任何帮助将不胜感激。

最佳答案

您的filebeat配置未选择任何输入类型。

filebeat.yaml文件输入路径必须指向您的filebeats-inputs.yaml而不是日志位置。依次委托(delegate)给docker输入类型。默认的container.path是/ var / lib / docker / containers。

https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-docker.html

关于elasticsearch - 无法使FileBeat发布到Elastic Search,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51506082/

10-13 05:26