homebrew-core/Formula/prometheus.rb
2019-10-18 02:32:06 -04:00

73 lines
2.2 KiB
Ruby

class Prometheus < Formula
desc "Service monitoring system and time series database"
homepage "https://prometheus.io/"
url "https://github.com/prometheus/prometheus/archive/v2.13.1.tar.gz"
sha256 "5624c16728679362cfa46b76ec1d247018106989f2260d35583c42c49c5142b5"
bottle do
cellar :any_skip_relocation
sha256 "8567d3c97901741a54653bce9581054c2c1d2f1cc719d6a07ab62eb4438f06b4" => :catalina
sha256 "dffe17c57858d9ca205d87bdf85cecc6878ed79aa220b39a9012f560ff7238c4" => :mojave
sha256 "f400edd263fc42cfb89bd700b2099ad7d19353949637e3fa756c0db0563c4f62" => :high_sierra
end
depends_on "go" => :build
def install
mkdir_p buildpath/"src/github.com/prometheus"
ln_sf buildpath, buildpath/"src/github.com/prometheus/prometheus"
system "make", "build"
bin.install %w[promtool prometheus]
libexec.install %w[consoles console_libraries]
end
def caveats; <<~EOS
When used with `brew services`, prometheus' configuration is stored as command line flags in
#{etc}/prometheus.args
Example configuration:
echo "--config.file ~/.config/prometheus.yml" > #{etc}/prometheus.args
EOS
end
plist_options :manual => "prometheus"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>#{opt_bin}/prometheus $(&lt; #{etc}/prometheus.args)</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>StandardErrorPath</key>
<string>#{var}/log/prometheus.err.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/prometheus.log</string>
</dict>
</plist>
EOS
end
test do
(testpath/"rules.example").write <<~EOS
groups:
- name: http
rules:
- record: job:http_inprogress_requests:sum
expr: sum(http_inprogress_requests) by (job)
EOS
system "#{bin}/promtool", "check", "rules", testpath/"rules.example"
end
end