Commit 0145af7e authored by Paul Asmuth's avatar Paul Asmuth
Browse files

doc: structure

parent d7b2ef37
Loading
Loading
Loading
Loading
+24 −12
Original line number Diff line number Diff line
Event Handler
-------------
Events and Gauges
-----------------

The basic unit of input data in FnordMetric is called an event. These events
are JSON objects (arbitrary hashmaps) A event may look like this:
An Event is a piece of input data that is sent to FnordMetric through one of the various
sources. These events are JSON objects (arbitrary hashmaps) with almost no contraints on
the schema. A event may look like this:

    { "_type": "sale", "product_id": 534221, "purchase_value": 2999 }

This pages describes the semantics of these events. More information about the various
ways to submit these events to FnordMetric (HTTP, TCP/UDP, etc.) please see Sending Data
FIXPAUL.


### Predefined events

Some events have a special format and meaning (like "increment this counter by 4"
or "add this sample to the average query time gauge"). You can just send these
@@ -16,6 +23,8 @@ _Example: increment something by four_
    ...


### Custom Events

You can also send completely custom events and write a piece of ruby code that
processes them. In this case the only requirement is that the event has a
`_type` key, which is used to identify the correct event handler. All other fields
@@ -27,7 +36,6 @@ _Example: send a "user signed up" event and increment two gauges_
    fnord...



There is a small number of keys which have a special meaning, all of them
are prefixed with an underscore:

@@ -35,6 +43,7 @@ are prefixed with an underscore:
    - events containing user data (_session, _name)
    - _namespace


### Gauges

The basic concept in FnordMetric is called a "gauge". A Gauge is a primitive data store for a numerical value over
@@ -50,13 +59,13 @@ upfront, they are automatically created as you send events. These events have
to follow a strict schema:
<hr class="space" />

Example: _Increment the gauge `sales-per-second` by 4, gauge resolution is 1 second._
Example: _Increment the gauge `sales-per-second` by 4_

    { "_type": "_incr", "value": 4, "gauge": "sales-per-second", "flush_interval": 1 }
    { "_type": "_incr", "value": 4, "gauge": "sales-per-second" }

Example: _Sample average request time (this sample: 42ms), gauge resolution is 10 seconds._
Example: _Sample average request time (this sample: 42ms), gauge resolution is 1 second._

    { "_type": "_avg", "value": 42, "gauge": "avg-request-time", "flush_interval": 10 }
    { "_type": "_avg", "value": 42, "gauge": "avg-request-time", "flush_interval": 1 }


Valid keys for these events are:
@@ -79,15 +88,18 @@ Valid keys for these events are:
    </td>
  </tr>
  <tr>
    <th><b>flush_interval</b> <i>(mandatory)</i></th>
    <th><b>flush_interval</b></i></th>
    <td>
      interval in which the value of this gauge is persisted. this is basically the
      gauge's resolution.
      interval in which the value of this gauge is persisted in seconds. this is
      basically the gauge's resolution. the flush interval controls how much memory
      a gauge uses (smaller flush_intervals use more memory)
      the default is 10 seconds
    </td>
  </tr>
</table>
<br />


### Create gauges by hand

FnordMetric also offers an api to create these gauges by hand.
+2 −24
Original line number Diff line number Diff line
Getting Started
---------------

The basic concept in FnordMetric is called a "gauge". A Gauge is a primitive data store for a numerical value over
time. A gauge has two dimensions: Value und Time. Gauges can be used in different modes like sum,
average, max/min, etcetara.

The FnordMetric core deals with processing data. There are two basic concepts:
events and gauges.

An Event is a piece of data that is sent to FnordMetric through one of the various
sources. This event is a JSON Object / Hash with almost no constraints on the schema.

You can install FnordMetric Classic by runing

@@ -34,21 +25,8 @@ Simple Example: this will render a timeline-plot showing the number of sales per

    FnordMetric.standalone

The easiest way to submit an event (i.e. a piece of data) is using `netcat` from the commandline:

    echo '{ "_type": "_incr", "value": 1, "gauge": "sales_per_minute", "flush_interval": 60 }' | nc localhost 1337

or you can use the HTTP API:

    curl -X POST -d '{ "_type": "_incr", "value": 1, "gauge": "sales_per_minute", "flush_interval": 60 }' http://localhost:4242/events


### Gauges

here be dragons
The canonical way to submit data is the HTTP + JSON api, this will report a single sale:

    curl -X POST -d '{ "_type": "_incr", "value": 1, "gauge": "sales_per_minute" }' http://localhost:4242/events

### Event Handlers
You write event handlers in ruby that get invoked per incoming event and modify (increment,
set, etcetera) gauges.
+4 −2
Original line number Diff line number Diff line
Sending Data
------------

The basic unit of input data in FnordMetric is called an event. These events
are JSON objects (arbitrary hashmaps)  A event may look like this:
An Event is a piece of input data that is sent to FnordMetric through one of the various
sources. These events are JSON objects (arbitrary hashmaps) with almost no contraints on
the schema. A event may look like this:

    { "_type": "sale", "product_id": 534221, "purchase_value": 2999 }


This page describes how to send these events to FnordMetric. To read more
about the semantics of the events please see Events and Gauges (FIXPAUL)