87 lines
2.8 KiB
Ruby
87 lines
2.8 KiB
Ruby
class Metricbeat < Formula
|
|
desc "Collect metrics from your systems and services"
|
|
homepage "https://www.elastic.co/beats/metricbeat"
|
|
url "https://github.com/elastic/beats.git",
|
|
tag: "v8.4.2",
|
|
revision: "b00a6bca7be493b01a134a6ad8c415f2be297414"
|
|
license "Apache-2.0"
|
|
head "https://github.com/elastic/beats.git", branch: "master"
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "81a625ba0f4d3fac7d678a1fb3ac3d7af2b635e5915b71314501de64e04daf56"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "c67152ee7f69a2b6cbe0f0c9a37d3c06ddf302e95bbec49532aa3626fe938919"
|
|
sha256 cellar: :any_skip_relocation, monterey: "3ff523716bcddd3b499491003b3def8a66fc8ed87c1b71d56dd5007cc1414c74"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "3f397072631968bed68d459c4b4878b1a0048daa0f384e679c959d035d428e6f"
|
|
sha256 cellar: :any_skip_relocation, catalina: "944cfed3ea508931476d303ef02fe265fa79929e78c7eac1e9ed442457c0baf8"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "f826119f7bc900aeb03c427b25ecedd979e2a932deb88572b2221c0b81784ccc"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "mage" => :build
|
|
depends_on "python@3.10" => :build
|
|
|
|
def install
|
|
# remove non open source files
|
|
rm_rf "x-pack"
|
|
|
|
cd "metricbeat" 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.Deps(CollectDocs, FieldsDocs)", ""
|
|
|
|
system "mage", "-v", "build"
|
|
ENV.deparallelize
|
|
system "mage", "-v", "update"
|
|
|
|
(etc/"metricbeat").install Dir["metricbeat.*", "fields.yml", "modules.d"]
|
|
(libexec/"bin").install "metricbeat"
|
|
prefix.install "build/kibana"
|
|
end
|
|
|
|
(bin/"metricbeat").write <<~EOS
|
|
#!/bin/sh
|
|
exec #{libexec}/bin/metricbeat \
|
|
--path.config #{etc}/metricbeat \
|
|
--path.data #{var}/lib/metricbeat \
|
|
--path.home #{prefix} \
|
|
--path.logs #{var}/log/metricbeat \
|
|
"$@"
|
|
EOS
|
|
end
|
|
|
|
service do
|
|
run opt_bin/"metricbeat"
|
|
end
|
|
|
|
test do
|
|
(testpath/"config/metricbeat.yml").write <<~EOS
|
|
metricbeat.modules:
|
|
- module: system
|
|
metricsets: ["load"]
|
|
period: 1s
|
|
output.file:
|
|
enabled: true
|
|
path: #{testpath}/data
|
|
filename: metricbeat
|
|
EOS
|
|
|
|
(testpath/"logs").mkpath
|
|
(testpath/"data").mkpath
|
|
|
|
fork do
|
|
exec bin/"metricbeat", "-path.config", testpath/"config", "-path.data",
|
|
testpath/"data"
|
|
end
|
|
|
|
sleep 15
|
|
|
|
output = JSON.parse((testpath/"data/meta.json").read)
|
|
assert_includes output, "first_start"
|
|
|
|
(testpath/"data").glob("metricbeat-*.ndjson") do |file|
|
|
s = JSON.parse(file.read.lines.first.chomp)
|
|
assert_match "metricbeat", s["@metadata"]["beat"]
|
|
end
|
|
end
|
|
end
|