Skip to content

natej/timera

Repository files navigation

Timera

Store metrics in InfluxDB.

Grafana Dashboard

Grafana Dashboard

There's currently one plugin included with Timera, httptimer.

With httptimer, you can store the time it takes to get http responses. For example:

[httptimer_plugin_01]
name = www.google.com
url = https://www.google.com/
proxy = http://proxy.example.com:3128/
include_direct = true

See the config file, config.ini, for options.

Use any InfluxDB-compatible visualization software to view your metrics. For example:

Plugins

Timera has a simple plugin system. So it's easy to write your own plugin to collect and store the metrics you want. See the custom plugin below and the included plugin httptimer for examples.

config.ini:

[mymetrics_plugin_01]
plugin_import = mymetrics.metrics
name = cpu_load_short
field = value

mymetrics/metrics.py:

import logging
import timera

log = logging.getLogger(__name__)

def get_metrics(config, timestamp, plugin):
    """
    :param config: ConfigParser instance
    :param timestamp: unix timestamp (seconds since epoch) for current collection interval
    :param plugin: dict with parsed plugin values
    """
    measurement = plugin['config']['name']
    field = plugin['config']['field']
    metric = 0.64
    fields = {field: str(metric)}
    tags = {'host': 'server01', 'region': 'us-west'}
    log.info('%s %r: %s=%f' % (measurement, tags, field, metric))
    measurementd = dict(measurement=measurement, time=timestamp, fields=fields, tags=tags)
    idbc = timera.db.get_client(config)
    timera.db.write_points(idbc, [measurementd])

If you create a plugin you think others would find useful, please submit a PR with tests for inclusion in Timera.

Requirements

Install

$ pip install timera

Or if using a virtual environment:

$ source env/bin/activate
$ pip install timera

Development Install

Use make install-dev to install in editable mode (pip install -e .) with pytest and tox:

$ source env/bin/activate
$ cd timera-master
$ make install-dev
$ make test
$ tox

Run It

Create db and start collecting metrics:

# edit config.ini
$ timera config.ini reset_db
$ timera config.ini start

Optional

Use Supervisor to run Timera. See the contrib dir. Supervisor requires Python 2 (pip install supervisor).

Viewing Metrics with Grafana

Configure InfluxDB as a datasource.

For the httptimer plugin, create a graph panel and configure the query:

Grafana Metrics Tab

Grafana Metrics Tab

Changes

See CHANGES.rst.

License

Timera is provided under the MIT License. See LICENSE.txt.

About

Store metrics in InfluxDB.

Resources

License

Stars

Watchers

Forks

Packages

No packages published