class Prometheus < Formula desc "Service monitoring system and time series database" homepage "https://prometheus.io/" url "https://github.com/prometheus/prometheus/archive/v2.7.2.tar.gz" sha256 "f958ed682d4aeefbd0355914043277cba0d7c0d0eaf6dda9c05ca6de7eea3cf7" bottle do cellar :any_skip_relocation sha256 "ceaac702569e9675120170679f227edb36c0c43826b13818c6fc9b0ead86a505" => :mojave sha256 "6d540b5021c708c70efcd470241c52393c6efcb7627d463e540a7c8db67b125e" => :high_sierra sha256 "b25a28c86546a7cc5a4a66a0dc737c006612d38d5b29bb2dd810c448a932333f" => :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