metrica iconmetrica 1.1.0

Data logging system
metrica is a data logging system written in Python.

Live better through data. "Personal metrics" refers to the idea that by tracking things about yourself and your daily life, you can be more productive, healthier, and do "better" for your arbitrary definition of "better". Do you really concentrate better with coffee? Is there an optimal amount of coffee to consume? How does that vary with time-of-day? What about when you bring exercise into the equation?

This is a very old idea, but in general, it's never really worked because of the constant manual entry involved. YFD, for example, is an awesome service, but it's just impossible to follow through given how it needs you to constantly remember to fill it in; that overhead quickly overwhelms the benefits. What we really need is an open standard that a constellation of devices and services all speak.

Quickstart

First, install the metrica command-line tool:

pip install metrica

Then, to "rekey" yourself -- get an authentication token -- simply run:

metrica rekey myemail@example.com

which will result in a new auth token being emailed to you. An email address is necessary due to both the treatment of auth tokens as disposable and the polling feature (see below). At any time, you can call /auth/rekey for an email address to regenerate it. If we just returned the auth token when you made the rekey request without requiring an email address, it would be impossible to regain access to logged data if you lost the auth token.

To start logging data from the command line, add the following to your .bashrc:

export METRICA_AUTH_TOKEN=XXXXX

substituting in "XXXXX" for the auth token in your email. To log an event, simply call metrica:

metrica log ran 2 miles
metrica log drank 1 coffee
metrica log ate 1 bowl of cereal at 8am given brand=cheerios


If successful, there will be no feedback and the console will simply continue to a new line. To see your logged events, call:

metrica list

to delete an event, find the event ID using metrica list, and then call:

metrica delete 4f249f62d115b60001000007

substituting in the correct event ID number. You can also set polls, short questions that get emailed to you periodically for you to record an answer. There are several template questions prebuilt into Metrics. You can also add your own. To see a list of currently active polls as well as available poll templates, type:

metrica polls

To add a poll from the available templates, use:

metrica polls:add caffeine 7

the second argument is the "interval". Technically, the interval is the lambda parameter of a Poisson distribution where the k parameter is the number of times polled over the previous 24 hours. You can think of the interval parameter as the approximate number of times you can expect to be asked this poll per day. To create a custom poll prompt, just add a third parameter:

metrica polls:add unhappy 3 "How unhappy are you right now? [0-10]"

To deactivate a poll at any time, simply call:

metrica polls:remove caffeine

The data logged from that poll remains unchanged when you deactivate a poll. Polls are emailed to the email address associated with the auth_token. You simply respond to the email with your answer (for example, "5", with no quotes) to log it.

Data Entry DSL

log workout from 5:30am to 7am with fb:afriend fb:friendtwo
log weight 158 lbs on 5/3/2010 :tag1 :tag2
log ate 1 bowl of cereal at 8am given brand=cheerios


On the CLI, you need to use : to mark tags. Otherwise, use # (this is because # has other meanings in bash, zsh, and friends while : doesn't). You can put hashtags anywhere in your log message, and the meaning of a tag doesn't vary based on where it appears; it works like they're stripped out before the message is parsed.

The basic grammar is:

log < value-stmt > < opt-date-stmt > < opt-time-stmt > < opt-with-stmt > < opt-at-stmt > \
 jopt-by-stmt > < opt-at-time-stmt > < opt-params-stmt >
 < value-stmt > := < event_name > < opt-units >
 < opt-date-stmt > := 'on' < date-str >
 < opt-time-stmt > := 'from' < time-of-day > < opt-to-stmt >
 < opt-to-stmt > := 'to' < time-of-day >
 < opt-with-stmt > := 'with' < with-list >
 < with-list > := < friend-name > | < with-list > < friend-name >
 < opt-at-stmt > := 'at' < location-name >
 < opt-at-time-stmt > := 'at-time' < time-of-day >
 < opt-by-stmt > := 'by' < author-name >
 < opt-params-stmt > := 'given' < params-list >
 < params-list > := < param > | < params-list > < param >
 < param > := < key >=< value >


API / Protocol

The goal is to provide a clean, RESTful API for storing personal data. To do this, my goal is to make it as easy as possible to send data to Metrics. The command-line tool included is one way; but it should be very easy to write your own interfaces for custom devices, data you may have lying around or otherwise.

POST /auth/login - Create a user session. Expects an
 `auth_token` to be POSTed.
DELETE /auth/login - Destroy a user session. Expects the
 user_id cookie to included.
POST /auth/rekey - Generate a new auth_token. Expects an
 `email` to be POSTed.
GET /polls - Get a list of current and template polls.
 Expects the user_id cookie.
POST /polls - Activate a poll. Expects the user_id cookie.

DELETE /polls/:name - Deactivate a poll. Expects the user_id
 cookie.
GET /events - Get the list of all logged events for the
 user. Expects the user_id cookie.
POST /events/new - Log a new event. Expects the user_id cookie.

GET /events/:id - Get the event known by instance id :id.
 Expects the user_id cookie.
DELETE /events/:id - Delete the event of instance id :id. Expects
 the user_id cookie.
GET /events/with/:keyword - Find the list of all events tagged `with`
 person :keyword. Expects the user_id cookie.
GET /events/tag/:keyword - Find the list of all events tagged `tag`
 keyword :keyword. Expects the user_id cookie.
GET /timeseries/:event_name - Get a parsed timeseries list for all events
 of type :event_name. Expects the user_id cookie.


Events are stored internally in this format:

{
 "event": "myevent",
 "value": {
 "content": 2,
 "units": "internets"
 },
 "tags": [
 "foo", "bar", "quux"
 ],
 "when": {
 "began": "2010-05-06T05:30:00",
 "ended": "2010-05-06T07:00:00"
 },
 "with": [
 "fb:someone",
 "twttr:anotheruser",
 "fb:100120203012"
 ],
 "where": {
 "label": "starbucks"
 },
 "time_created": "2010-05-06T19:11:45.915615",
 "time_updated": "2010-05-06T19:11:45.915622"
}

last updated on:
February 6th, 2012, 16:54 GMT
price:
FREE!
developed by:
Max Hodak
license type:
Other/Proprietary License
category:
ROOT \ System \ Logging

FREE!

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Add your review!

SUBMIT