87 lines
2.9 KiB
Ruby
87 lines
2.9 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.30.3.tar.gz"
|
|
sha256 "66a835096e717c11db2ecb5f948c6346868fa1f877196ee2237fb4630df97c06"
|
|
license "Apache-2.0"
|
|
|
|
livecheck do
|
|
url :stable
|
|
strategy :github_latest
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, arm64_monterey: "fefbed7117320e05da0bd4dbf48515877d5cef128c70799191a3593b2c8a362c"
|
|
sha256 cellar: :any_skip_relocation, arm64_big_sur: "97621b99e959e16419b9539bf7162a1fda9367580da427a8533a3e9e74cf3de9"
|
|
sha256 cellar: :any_skip_relocation, monterey: "60ec8d5eeecb91faad842e889b9a559eb6143927bdc4900cffadd753ab80dd30"
|
|
sha256 cellar: :any_skip_relocation, big_sur: "df45f718948efe0c8aac092333b79151aa9652b5927c2127c542cd40067f068d"
|
|
sha256 cellar: :any_skip_relocation, catalina: "16b43830daf9666454eef51b71b190295ef777abc4c0f736147d1ffa44f9301c"
|
|
sha256 cellar: :any_skip_relocation, mojave: "d4a48002a602a51a97a5a30206986979a6ff6bf751963d939ce706f3e4ff05d5"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "8e357ffc40d706b9732dfd82b4e8f6e92f51029524b5cd605c0b0e3599d794a1"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "node" => :build
|
|
depends_on "yarn" => :build
|
|
|
|
def install
|
|
ENV.deparallelize
|
|
ENV.prepend_path "PATH", Formula["node"].opt_libexec/"bin"
|
|
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
|
|
|
|
service do
|
|
run [opt_bin/"prometheus_brew_services"]
|
|
keep_alive false
|
|
log_path var/"log/prometheus.log"
|
|
error_log_path var/"log/prometheus.err.log"
|
|
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
|