filebeat配置

下载文件

切换至目录/srv/salt/files/packages

因为线上的操作系统不同,有centos debian

  1. curl -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.6.2-amd64.deb
  2. curl -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.6.2-x86_64.rpm

配置salt sls

  • services/filebeat/config.sls
  • services/filebeat/install.sls
  • services/filebeat/init.sls

以下三个文件配置完成后,提交到gitlab,gitlab会自动执行git runner执行pipeline,执行rsync同步到salt服务器:/srv/salt中

  • config.sls
    filebeat:
      file.managed:
        - name: /etc/filebeat/filebeat.yml
        - source: salt://files/filebeat/filebeat.yml
    
      service.running:
        - restart: True
        - enable: True
        - watch:
          - file: filebeat
 
  • install.sls
    install_filebeat:
      {% if grains['os_family'] == 'Debian' %}
      cmd.run:
        - name: dpkg -i /tmp/filebeat-8.6.2-amd64.deb
        - cwd: /tmp
        - onlyif: test ! -f /usr/bin/filebeat
      filebeat.deb:
        file.managed:
          - name: /tmp/filebeat-8.6.2-amd64.deb
          - source: salt://files/packages/filebeat-8.6.2-amd64.deb
      {% endif %}
    
      {% if grains['os_family'] == 'RedHat' %}
      pkg.installed:
        - sources:
            - filebeat: salt://files/packages/filebeat-8.6.2-x86_64.rpm
      {% endif %}
 
posted @ 2024-08-25 15:25  MacoPlus  阅读(12)  评论(0编辑  收藏  举报