97 lines
3.2 KiB
Ruby
97 lines
3.2 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: "v7.16.2",
|
|
revision: "3c518f4d17a15dc85bdd68a5a03d5af51d9edd8e"
|
|
# 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"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "c9ecfbb9c7837cc1ce5f65b8adb41031fb90891f5be7eedcf802f4a189ab86de"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "0a0df9c5275eb5683fe33dbabf2161b91c416910e56de6a889813150ea1930c6"
|
|
sha256 cellar: :any_skip_relocation, monterey: "e498103bba38650fbe8fb0ff8d9f22ba18445a5548734c92c023fe9ecd362318"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "10187ae885ffcaa080740873686d8c9eac01cc2d44ead0da0b43194d006d0dff"
|
|
sha256 cellar: :any_skip_relocation, catalina: "460859fd866a199593d680daf874223d4666d998967035eec8eeddd5b82e8479"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "09a3a48d7fe41353d2db46c8829d338d25150f41d4f5013b680a79038d5970b8"
|
|
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/"filebeat", :exist?
|
|
end
|
|
end
|