首页 > 系统相关 >Filbeat采集nginx-ingress日志

Filbeat采集nginx-ingress日志

时间:2022-08-17 09:56:10浏览次数:60  
标签:ingress log filebeat nginx var type Filbeat name

 

  一、创建configmap配置文件

  注:filebeat6以上版本需要将prospectors改为inputs,paths下指定的nginx-ingress日志路径匹配模式以及hosts指定的kafka地址需要根据实际修改,document_type和topic需要是kafka中存在的

[root@localhost ~]# cat >> filebeat-config.yaml <<EOF
> apiVersion: v1
> data:
> filebeat.yml: |
> filebeat.prospectors:
> - input_type: log
> paths:
> - "/var/log/containers/nginx-ingress-ingress-nginx-controller-*_ingress-nginx_controller-*.log"
> symlinks: true
> json.message_key: log
> json.keys_under_root: true
> json.add_error_key: true
> multiline.pattern: '^\s'
> multiline.match: after
> document_type: k8s-logs
> fields:
> POD_NAME: 'nginx-ingress'
> fields_under_root: true
> exclude_lines: ['\.(xml|gif|jpg|jpeg|png|bmp|swf|woff|woff2|ttf|js|css|svg|ico)']
>
>
> output.kafka:
> hosts: ["kafka-service:9092"]
> topic: "k8s-logs"
> required_acks: 1
> kind: ConfigMap
> metadata:
> name: filebeat-configmap
> namespace: middleware
> EOF

 

  二、创建configmap

[root@develop-k8s-worker02 ~]# kubectl apply -f filebeat-config.yaml

 

  三、创建filebeat的daemonset配置文件

[root@localhost ~]# cat >> filebeat.yaml <<EOF
> apiVersion: apps/v1
> kind: DaemonSet
> metadata:
>   labels:
>     app: filebeat
>   name: filebeat
>   namespace: middleware
> spec:
>   revisionHistoryLimit: 10
>   selector:
>     matchLabels:
>       app: filebeat
>   template:
>     metadata:
>       labels:
>         app: filebeat
>     spec:
>       containers:
>       - image: elastic/filebeat:5.6.14
>         imagePullPolicy: Always
>         name: filebeat
>         resources:
>           limits:
>             cpu: 200m
>             memory: 200Mi
>           requests:
>             cpu: 100m
>             memory: 100Mi
>         terminationMessagePath: /dev/termination-log
>         terminationMessagePolicy: File
>         volumeMounts:
>         - mountPath: /etc/filebeat/
>           name: config
>           readOnly: true
>         - mountPath: /var/log/containers
>           name: varlog
>         - mountPath: /var/log/pods
>           name: varlogpods
>           readOnly: true
>         - mountPath: /var/lib/docker/containers
>           name: varlibdockercontainers
>         - mountPath: /var/host/log
>           name: volume-1621230243442
>       dnsPolicy: ClusterFirst
>       imagePullSecrets:
>       - name: gaqmt
>       restartPolicy: Always
>       schedulerName: default-scheduler
>       securityContext: {}
>       terminationGracePeriodSeconds: 30
>       tolerations:
>       - effect: NoSchedule
>         key: node-role.kubernetes.io/master
>         operator: Exists
>       volumes:
>       - configMap:
>           defaultMode: 420
>           items:
>           - key: filebeat.yml
>             path: filebeat.yml
>           name: filebeat-configmap
>         name: config
>       - hostPath:
>           path: /var/log/containers
>           type: ""
>         name: varlog
>       - hostPath:
>           path: /var/log/pods
>           type: ""
>         name: varlogpods
>       - hostPath:
>           path: /var/lib/docker/containers
>           type: ""
>         name: varlibdockercontainers
>       - hostPath:
>           path: /var/log
>           type: ""
>         name: volume-1621230243442
>   updateStrategy:
>     rollingUpdate:
>       maxUnavailable: 1
>     type: RollingUpdate
> EOF

 

  四、创建filebeat的pod

[root@localhost ~]# kubectl apply -f filebeat.yaml

 

标签:ingress,log,filebeat,nginx,var,type,Filbeat,name
From: https://www.cnblogs.com/shareHistory/p/16593927.html

相关文章

  • nginx升级
    nginx升级升级背景:Nginx是一款轻量级Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器。Nginx存在漏洞,该漏洞允许攻击者从DNS服务器伪造UDP数据包造成1-byte的内......
  • Nginx
    Nginx反向代理反向代理:请求ip80转发到ip8080;根据访问的路径跳转到不同端口的服务中。Nginx负载均衡分配服务器策略1、轮询(默认)每个请求按时间顺序逐一分配到不同的后......
  • goaccess-nginx
    GoAccessgoaccess-快速网络日志分析器和交互式查看器。描述:goaccess是一个免费的(MIT许可)和开源实时网络日志分析器和交互式查看器,可以在*nix系统中的终端或通过浏......
  • nginx ngx_http_addition_module 模块openresty content_by_lua 不能生效的原因
    nginx的ngx_http_addition_module模块也是一个修改content的好东西,对于openresty我们经常使用content_by_lua阶段处理但是经过分析ngx_http_addition_module源码的......
  • 教你如何在云服务器上安装并配置web服务器(这里以nginx服务器为例,操作系统linux)
    前言:这里以gitbash工具为例,当然你可以直接用puTTY或者Xshell链接到服务器,用FileZilla上传文件。一、连接服务器sshroot@你的远程ip地址。二、查看版本uname-a三......
  • nginx环境下配置https域名你知道吗?
    拿到的证书分两个文件,一个是xxx.crt,一个是xxx.key,分别对应公钥和私钥。1.假设我们的nginx安装目录是:/etc/nginx/,在目录下创建一个新目录,姑且命名为cert,把两个证书文件扔到......
  • 4、编译安装nginx,实现多域名 https
    4、编译安装nginx,实现多域名https 一、编译安装nginx1.源码包下载https://nginx.org/en/download.html2.编译安装[root@CentOS8~]#yum-yinstallgccpcre-devel......
  • nginx 一些简单访问控制模块
    nginx已经内置了一些简单的访问控制模块,利用好这些模块我们可以提升系统的安全几个比较有用的标准模块基本都是利用了access阶段的能力limit_except限制请求方法的(......
  • Nginx学习笔记
    Nginx简介Nginx(enginex)是一个高性能的HTTP和反向代理web服务器,Nginx和Apache的区别Apache和Nginx最核心的区别在于apache是同步多进程模型,一个连接对应一个进程;......
  • 【Linux】yum源安装nginx服务
    前言centos通过yum命令安装nginx服务,并开放监听端口、设置开机自启等1、配置yum源并进行安装如有其他版本需求的,可以跳转官网nginx:Linuxpackages,选取适合自......