class Prometheus < Formula desc "Service monitoring system and time series database" homepage "https://prometheus.io/" url "https://github.com/prometheus/prometheus/archive/v2.7.1.tar.gz" sha256 "bfbeb434342a03b5849e2ec7a0cbe573067299cf59ccf59db0cacd8db8800bb0" bottle do cellar :any_skip_relocation sha256 "6ccedfd5d1e7f9c2d36d94fd8837c1a51fa5ed3655ca8f614c931e4d3ac1c223" => :mojave sha256 "a323c8dde209edc5fbaa4bdc458904dc7e39496ff6f7a8bb641e90bade695b72" => :high_sierra sha256 "33b47833ae493393a9801f52ba9ce84b9b8a3960fa07261b03b1e25a08ac3d28" => :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 Label #{plist_name} ProgramArguments sh -c #{opt_bin}/prometheus $(< #{etc}/prometheus.args) RunAtLoad KeepAlive StandardErrorPath #{var}/log/prometheus.err.log StandardOutPath #{var}/log/prometheus.log 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