101 lines
3.0 KiB
Ruby
101 lines
3.0 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.25.0.tar.gz"
|
|
sha256 "bb95b39870a1844483c0775c5122092b07006ae26f8961a881bebb7eafe52afa"
|
|
license "Apache-2.0"
|
|
|
|
livecheck do
|
|
url :stable
|
|
strategy :github_latest
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, big_sur: "710f5ce18d58b4d50e8071d28a8036c0cc5567840af2fb5dc81165bfa237c92e"
|
|
sha256 cellar: :any_skip_relocation, catalina: "fe29a2cd28d1f08f8c7c0d12cf6284ab7c6f2268515d458dfee06ba20d76be51"
|
|
sha256 cellar: :any_skip_relocation, mojave: "69dd17b94119cb0298e7a82f4b2f979585583adc83d4635164cb1074726f26c9"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "node" => :build
|
|
depends_on "yarn" => :build
|
|
|
|
def install
|
|
mkdir_p buildpath/"src/github.com/prometheus"
|
|
ln_sf buildpath, buildpath/"src/github.com/prometheus/prometheus"
|
|
|
|
system "make", "assets"
|
|
system "make", "build"
|
|
bin.install %w[promtool prometheus]
|
|
libexec.install %w[consoles console_libraries]
|
|
|
|
(bin/"prometheus_brew_services").write <<~EOS
|
|
#!/bin/bash
|
|
exec #{bin}/prometheus $(<#{etc}/prometheus.args)
|
|
EOS
|
|
|
|
(buildpath/"prometheus.args").write <<~EOS
|
|
--config.file #{etc}/prometheus.yml
|
|
--web.listen-address=127.0.0.1:9090
|
|
--storage.tsdb.path #{var}/prometheus
|
|
EOS
|
|
|
|
(buildpath/"prometheus.yml").write <<~EOS
|
|
global:
|
|
scrape_interval: 15s
|
|
|
|
scrape_configs:
|
|
- job_name: "prometheus"
|
|
static_configs:
|
|
- targets: ["localhost:9090"]
|
|
EOS
|
|
etc.install "prometheus.args", "prometheus.yml"
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
When run from `brew services`, `prometheus` is run from
|
|
`prometheus_brew_services` and uses the flags in:
|
|
#{etc}/prometheus.args
|
|
EOS
|
|
end
|
|
|
|
plist_options manual: "prometheus --config.file=#{HOMEBREW_PREFIX}/etc/prometheus.yml"
|
|
|
|
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>#{opt_bin}/prometheus_brew_services</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
|