Commit cbc74134 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

cleaning up here and there...

parent a9fa84a6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -174,7 +174,9 @@ class FnordMetric::Namespace
  def load_gauges
    gaugelist_key = key_prefix("zero-config-gauges")
    sync_redis.hgetall(gaugelist_key).each do |gauge_key, gauge_opts|
      opt_gauge(gauge_key.to_sym, JSON.parse(gauge_opts).symbolize_keys)
      gopts = JSON.parse(gauge_opts).symbolize_keys
      gopts.delete(:zero_config)
      opt_gauge(gauge_key.to_sym, gopts)
    end
  end

+4 −0
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@ class FnordMetric::NumbersWidget < FnordMetric::Widget
  end

  def self.execute_values_for(gauge, event)
    unless gauge
      return { "error" => "gauge not found..." }
    end

    _t = Time.now.to_i

    if at = event["at"]
+3 −3
Original line number Diff line number Diff line
@@ -27,16 +27,16 @@ class FnordMetric::ZeroConfigGauge
    case type

      when :_set
        set_value gauge, data[:value]
        set_value gauge, data[:value].to_i

      when :_incr
        incr_tick gauge, data[:value]
        incr_tick gauge, data[:value].to_i

      when :_decr
        FnordMetric.error("_decr is not yet implemented")

      when :_avg
        incr_avg gauge, data[:value]
        incr_avg gauge, data[:value].to_i

      when :_min, :_max
        FnordMetric.error("_min/_max is not yet implemented")
+6 −0
Original line number Diff line number Diff line
@@ -12,4 +12,10 @@ FnordMetric.namespace :myapp do

end

FnordMetric.options = {
  :inbound_stream => ["0.0.0.0",2323],
  :inbound_protocol => :tcp
}

FnordMetric.standalone
+5 −4
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ on port 4242) and save this to a fil `my_dashboard.html`


We will display on counter "total revenue in the last hour" on our page. First we
have to connect to the FnordMetric Backend using WebSockets:
have to connect to the FnordMetric Backend using WebSockets (_Make sure you set the
correct namespace, it's "myapp" in the example_):

    <script>
      FnordMetric.setup({
@@ -53,7 +54,7 @@ sales in the last hour. And update every second:
      data-at="sum(-1hour)"
      data-gauge="total_sales_in_euro"
      data-autoupdate="1"
      data-unit=""
      data-unit="$"
      >0</span>


@@ -61,9 +62,9 @@ Now open my_dashboard.html in the browser of your choice. You should see a
page displaying "0". It's a good idea to open the JavaScript / Inspector
console of your browser as FnordMetric UI will print error messages using `console.log`

The last step is to start sending data. This will report one sale of 29.99€:
The last step is to start sending data. This will report one sale of 29€:

    curl -X POST -d '{ "_type": "_incr", "value": 29.99, "gauge": "total_sales_per_minute" }' http://localhost:4242/events
    curl -X POST -d '{ "_type": "_incr", "value": 29, "gauge": "total_sales_in_euro" }' http://localhost:4242/events


For fun and profit, we can display a timeseries graph of sales in the last 10 minutes with this snippet: