3
votes

I'm trying to send metrics to graphite from my python app through statsD, I'm using this client (which I understand is most common).

But I can't figure out how to send metrics with tags.

I've tried this syntax (from here):

c.incr('foo.bar,tag1=val')

And also this (got the idea from here):

c.incr('foo.bar;tag1=val')

But nothing seem to work.

Did anyone succeeded sending statsd metrics from python with tags?

Thanks

2
Also tried c.incr('foo.bar#tag1=val') without successTzvika Mordoch

2 Answers

0
votes

UPDATE:

It seems all you need to do now is to install:

pip install statsd-telegraf

See here

Works as expected


To send tags from python statsD you need to install this fork:

https://pypi.org/project/statsd-telegraf/

But, two important notes:

  1. Do NOT install from PyPI alone, it has an unfixed bug
    BAD: pip install statsd-tags

After installing from PyPI, Install directly from GitHub, using the correct username (In the PyPI link above, the wrong link is shown)

    GOOD: pip install statsd-tags
          pip install -e git+https://github.com/Granitosaurus/statsd-telegraf#egg=statsd-telegraf
  1. The documentation in PyPI of how to use the tags is wrong.

Tags should be a dict. For example:

    import statsd
    c = statsd.StatsClient('localhost', 8125, prefix='foo')
    c.incr('bar', tags = {"key1": "value1", "key2":"value2"})
-1
votes

It appears that there is no tag support in the python client as seen in this issue

I looked for a different client that includes tags support but no luck.

I think the best option would be to take the code from this rejected pull request.