homebrew-core/Formula/filebeat.rb

98 lines
3.3 KiB
Ruby

class Filebeat < Formula
desc "File harvester to ship log files to Elasticsearch or Logstash"
homepage "https://www.elastic.co/products/beats/filebeat"
url "https://github.com/elastic/beats.git",
tag: "v8.4.2",
revision: "b00a6bca7be493b01a134a6ad8c415f2be297414"
# Outside of the "x-pack" folder, source code in a given file is licensed
# under the Apache License Version 2.0
license "Apache-2.0"
head "https://github.com/elastic/beats.git", branch: "master"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "d63c17ed34356ff28de07a02c63d9944eedc38f6a509c680318a584f380e4103"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "6f435ecfa938b7f9d5bfb0ccca8fd56c26b8e75825ae7e23437c823b3e31bf47"
sha256 cellar: :any_skip_relocation, monterey: "da7f8c16b103c97159d976fe2c21d38fa5f1a34b4fb94aca22792876520066f0"
sha256 cellar: :any_skip_relocation, big_sur: "c71ee6923f997078d1ec20d2e4489635aef5c6f1612a23eb01e294f6314170fc"
sha256 cellar: :any_skip_relocation, catalina: "4be11637cae77d5dbf9af22801ed20422ae16e09a431fb34794f1878f772a804"
sha256 cellar: :any_skip_relocation, x86_64_linux: "b2822ae811e48b16bdabfc3372663bcdfdabdaff56160b49ac4b0c2306a35d3b"
end
depends_on "go" => :build
depends_on "mage" => :build
depends_on "python@3.10" => :build
uses_from_macos "rsync" => :build
def install
# remove non open source files
rm_rf "x-pack"
cd "filebeat" do
# don't build docs because it would fail creating the combined OSS/x-pack
# docs and we aren't installing them anyway
inreplace "magefile.go", "mg.SerialDeps(Fields, Dashboards, Config, includeList, fieldDocs,",
"mg.SerialDeps(Fields, Dashboards, Config, includeList,"
# prevent downloading binary wheels during python setup
system "make", "PIP_INSTALL_PARAMS=--no-binary :all", "python-env"
system "mage", "-v", "build"
system "mage", "-v", "update"
(etc/"filebeat").install Dir["filebeat.*", "fields.yml", "modules.d"]
(etc/"filebeat"/"module").install Dir["build/package/modules/*"]
(libexec/"bin").install "filebeat"
prefix.install "build/kibana"
end
(bin/"filebeat").write <<~EOS
#!/bin/sh
exec #{libexec}/bin/filebeat \
--path.config #{etc}/filebeat \
--path.data #{var}/lib/filebeat \
--path.home #{prefix} \
--path.logs #{var}/log/filebeat \
"$@"
EOS
end
service do
run opt_bin/"filebeat"
end
test do
log_file = testpath/"test.log"
touch log_file
(testpath/"filebeat.yml").write <<~EOS
filebeat:
inputs:
-
paths:
- #{log_file}
scan_frequency: 0.1s
output:
file:
path: #{testpath}
EOS
(testpath/"log").mkpath
(testpath/"data").mkpath
fork do
exec "#{bin}/filebeat", "-c", "#{testpath}/filebeat.yml",
"-path.config", "#{testpath}/filebeat",
"-path.home=#{testpath}",
"-path.logs", "#{testpath}/log",
"-path.data", testpath
end
sleep 1
log_file.append_lines "foo bar baz"
sleep 5
assert_predicate testpath/"meta.json", :exist?
assert_predicate testpath/"registry/filebeat", :exist?
end
end