GraphiteSend

About

Graphitesend is a python library that can be used to easily push data into graphite using python.

Usage Example

Very basic sending of a metric called metric with a value of 45

>>> import graphitesend
>>> graphitesend.init()
>>> graphitesend.send('metric', 45)
>>> graphitesend.send('metric2', 55)

The above would send the following metric to graphite over the plaintext (default) protocol on port 2003 (default)

system.localhostname.metric  45 epoch-time-stamp
system.localhostname.metric2 55 epoch-time-stamp

Cleaning up the interface and using a group of cpu to alter the metric prefix

>>> import graphitesend
>>> g = graphitesend.init(group='cpu')
>>> g.send('metric', 45)
>>> g.send('metric2', 55)

The above would send the following metric to graphite

system.localhostname.cpu.metric 45 epoch-time-stamp
system.localhostname.cpu.metric2 55 epoch-time-stamp

Using graphitesend from the commandline

A cli script that allows for anything to send metrics over to graphite (not just python).

The usage is very simple you need to give the command a metric and a value.

$ graphitesend name.of.the.metric 666

Send more* then 1 metric and value

$ graphitesend name.of.the.metric 666
$ graphitesend name.of.the.other_metric 2

Example Scripts using graphitesend

The github repo of https://github.com/daniellawrence/graphitesend-examples has lots of examples using graphitesend to grab data from your local linux system.

Installation

Stable releases of graphitsend are best installed via pip or easy_install.

We recommend using the latest stable version of graphitsend; releases are made often to prevent any large gaps in functionality between the latest stable release and the development version.

However, if you want to live on the edge, you can pull down the source code from our Git repository, or fork us on Github.

Documentation

Graphitesend is a python library that can be used to easily push data into graphite using python.

Usage Example

Very basic sending of a metric called metric with a value of 45

>>> import graphitesend
>>> graphitesend.init()
>>> graphitesend.send('metric', 45)
>>> graphitesend.send('metric2', 55)

The above would send the following metric to graphite over the plaintext (default) protocol on port 2003 (default)

system.localhostname.metric  45 epoch-time-stamp
system.localhostname.metric2 55 epoch-time-stamp

Cleaning up the interface and using a group of cpu to alter the metric prefix

>>> import graphitesend
>>> g = graphitesend.init(group='cpu')
>>> g.send('metric', 45)
>>> g.send('metric2', 55)

The above would send the following metric to graphite

system.localhostname.cpu.metric 45 epoch-time-stamp
system.localhostname.cpu.metric2 55 epoch-time-stamp

Using graphitesend from the commandline

A cli script that allows for anything to send metrics over to graphite (not just python).

The usage is very simple you need to give the command a metric and a value.

$ graphitesend name.of.the.metric 666

Send more* then 1 metric and value

$ graphitesend name.of.the.metric 666
$ graphitesend name.of.the.other_metric 2

Example Scripts using graphitesend

The github repo of https://github.com/daniellawrence/graphitesend-examples has lots of examples using graphitesend to grab data from your local linux system.

Overview and Tutorial

Welcome to GraphiteSend!

This is a quick dive in at some of the features of graphitesend.

What is GraphiteSend?

As the README says:

Graphitesend is a python library that can be used to easily push data into graphite using python.

More specifically, Graphite is:

  • A common way for you to push all your metrics that your going to gather in python to your graphite server.

The most common usage of this is to either

  • quickly put to gether a new script that is going to metrics into graphite.
  • extending an oldscript to standarize how to push metrics into graphite.

Hello, graphite

Very basic sending of a metric called hello world with the current value of 53.

This will make a connection to the a graphite server called (configurable) and pass the following

>>> graphitesend.send('hello world', 45)
systems.ubuntu.hello_world 45.000000 1386490491

As you can see graphitesend has done a few things for you..

  • Added a default prefix of “systems.” to make sure all your metrics land in the same namespace
  • Added the system_name as the current hostname after the prefix.
  • Fixed the space in the metric name
  • validated and converted the value into a float
  • Used the current timestamp
  • Send all the above to the graphitesend on the plain text protocol, default port 2003

Sending Dicts of data

Instead of sending single metrics to the graphite server you can group them up into a dict or list.

>>> graphitesend.send_dict({'hello world': 45, 'goodbye world': 54})
systems.ubuntu.hello_world 45.000000 1386490491
systems.ubuntu.goodbye_world 54.000000 1386490491

As long as you keep the format of {metric: value} the data will be sent over to graphite.

>>> graphitesend.send_dict(
...  {
...   'hello world': 45,
...   'this world': 54
...   'goodbye world': 54
...  }
... )

Sending lists of data

You can do the same as sending dicts however by providing a list.

>>> graphitesend.send_list([('hello world', 45), ('goodbye world', 54))
systems.ubuntu.hello_world 45.000000 1386490491
systems.ubuntu.goodbye_world 54.000000 1386490491

As long as you keep the format of metric, value, [timestamp] the data will be sent over to graphite.

The optional timestamp needs to be provided in unix epoch format.

>>> graphitesend.send_list(
...  [
...   ('hello world', 45),
...   ('this world', 54),
...   ('goodbye world', 54, 10000)
...  ]
... )

GraphiteSend API

Bugs/ticket tracker

To file new bugs or search existing ones, you may visit GraphiteSends’s Github Issues page. This does require a (free, easy to set up) Github account.