class Prometheus < Formula desc "Service monitoring system and time series database" homepage "https://prometheus.io/" url "https://github.com/prometheus/prometheus/archive/v2.15.2.tar.gz" sha256 "2ba37bced3e90c5e7dd3248918f13f2f3444de748cfe413b0a09f82532c3c553" bottle do cellar :any_skip_relocation sha256 "4c1fec08803cee24252ac7ae3459b928e609a42a2151ed17017b2182ef183877" => :catalina sha256 "d4807cdd70fa35152127626e79a1f966ae3e7a50be06fd3c239a8bd039492212" => :mojave sha256 "0a75a53d47767302e3014e98a227cc5b61a9536b31d1a0c50ed506593d014852" => :high_sierra 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] end def post_install (etc/"prometheus.args").write <<~EOS --config.file #{etc}/prometheus.yml --web.listen-address=127.0.0.1:9090 --storage.tsdb.path #{var}/prometheus EOS (etc/"prometheus.yml").write <<~EOS global: scrape_interval: 15s scrape_configs: - job_name: "prometheus" static_configs: - targets: ["localhost:9090"] EOS end def caveats; <<~EOS When used with `brew services`, prometheus' configuration is stored as command line flags in: #{etc}/prometheus.args Configuration for prometheus is located in the #{etc}/prometheus.yml file. 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