All Projects → paksu → Pytelegraf

paksu / Pytelegraf

Licence: mit
Python client for sending metrics to Telegraf

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Pytelegraf

Solarthing
Monitors an Outback MATE and a Renogy Rover - MPPT Charge Controller. Integrates with Grafana, PVOutput and more!
Stars: ✭ 33 (-52.17%)
Mutual labels:  influxdb
Ssh Log To Influx
Send SSH authentication logs to influxdb with geohashing IP
Stars: ✭ 49 (-28.99%)
Mutual labels:  influxdb
Unifi Poller
Application: Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus
Stars: ✭ 1,050 (+1421.74%)
Mutual labels:  influxdb
Openwisp Monitoring
Network monitoring system written in Python and Django, designed to be extensible, programmable, scalable and easy to use by end users: once the system is configured, monitoring checks, alerts and metric collection happens automatically.
Stars: ✭ 37 (-46.38%)
Mutual labels:  influxdb
Homer7 Docker
HOMER 7 Docker Images
Stars: ✭ 47 (-31.88%)
Mutual labels:  influxdb
Raspberry pi stats
A script to collect various Raspberry Pi statistics, which are sent via Telegraf to InfluxDB.
Stars: ✭ 50 (-27.54%)
Mutual labels:  influxdb
Unifiedmetrics
Fully-featured metrics collection agent for Minecraft servers. Supports Prometheus and InfluxDB. Dashboard included out-of-box.
Stars: ✭ 29 (-57.97%)
Mutual labels:  influxdb
Facette
Time series data visualization software
Stars: ✭ 1,115 (+1515.94%)
Mutual labels:  influxdb
Docker Flask Mongodb Example
Uses docker compose with a python flask microservice and MongoDB instance to make a sample application
Stars: ✭ 49 (-28.99%)
Mutual labels:  influxdb
Influxdb Haskell
InfluxDB client library for Haskell
Stars: ✭ 51 (-26.09%)
Mutual labels:  influxdb
Grade
Track Go benchmark performance over time by storing results in InfluxDB
Stars: ✭ 41 (-40.58%)
Mutual labels:  influxdb
Influx dashboards
Chronograf Dashboards for use with data produced by Telegraf input plugins.
Stars: ✭ 44 (-36.23%)
Mutual labels:  influxdb
Go Web Backend
Dockerized backend services for web application
Stars: ✭ 50 (-27.54%)
Mutual labels:  influxdb
Ansible Influxdb
Ansible Galaxy InfluxDB Role
Stars: ✭ 36 (-47.83%)
Mutual labels:  influxdb
Nagflux
A connector which copies performancedata from Nagios / Icinga(2) / Naemon to InfluxDB
Stars: ✭ 55 (-20.29%)
Mutual labels:  influxdb
Pgwatch2
PostgreSQL metrics monitor/dashboard
Stars: ✭ 960 (+1291.3%)
Mutual labels:  influxdb
Influx Crypto Trader
Node js trading bot, let you create trading strategy and run it (backtest/simulation/live)
Stars: ✭ 49 (-28.99%)
Mutual labels:  influxdb
Influxdbclient Rs
A easy-use client to influxdb
Stars: ✭ 63 (-8.7%)
Mutual labels:  influxdb
Inch
An InfluxDB benchmarking tool.
Stars: ✭ 57 (-17.39%)
Mutual labels:  influxdb
Personal Influxdb
Import data from various APIs into InfluxDB
Stars: ✭ 51 (-26.09%)
Mutual labels:  influxdb

Pytelegraf

Python client for sending metrics to Telegraf inspired by pystatsd

Build Status

Designed to work with Telegraf UDP listener input plugin. https://github.com/influxdata/telegraf/tree/master/plugins/inputs/udp_listener

Pytelegraf supports and is tested to function with Telegraf version 0.13 and newer. It may work with older versions too but that is untested.

Pytelegraf outputs InfluxDB line protocol https://docs.influxdata.com/influxdb/v0.13/write_protocols/line/


Contacting

Need answers? Join pytelegraf on Gitter Gitter

If you find this library useful please let me know https://twitter.com/joonapaak

If you have an idea how this library can be improved then open an issue or even better send a pull request :)

How to install

pip install pytelegraf

Usage

from telegraf.client import TelegrafClient
client = TelegrafClient(host='localhost', port=8092)

# Records a single value with no tags
client.metric('some_metric', 123)

# Records a three values with different data types
client.metric('some_metric', {'value_a': 100, 'value_b': 100, 'value_c': True})

# Records a single value with one tag
client.metric('some_metric', 123, tags={'server_name': 'my-server'})

Global tags

The client can be initialized with global tags that will be sent with every metric implicitly

This is useful for adding tagging metrics by host or app

client = TelegrafClient(host='localhost', port=8092, tags={'host': 'my-host-001'})

# Records a single value
client.metric('some_metric', 123)

Because client was initialized with tags the metric contains them too so the line that was sent to Telegraf looks like this

some_metric,host=my-host-001 value=123i

Global tags can be overridden by defining them when sending a metric

# Records a single value with host tag
client.metric('some_metric', 123, tags={'host':'another-host-001', 'some_tag':'some_value'})

Will send the following line

some_metric,host=another-host-001,some_tag=some_value value=123i

HTTP Client

The default TelegrafClient uses UDP to send metrics to Telegraf. The HttpClient works similarly, except that it issues requests via an HTTP POST. HTTP introduces non-trivial overhead, so to avoid blocking the main thread, these POSTs are issued in the background.

To use the HttpClient, pytelegraf must be installed like this: pip install pytelegraf[http]. Alternatively, add pytelegraf[http] to requirements.txt.

from telegraf import HttpClient

http_client = HttpClient(host='localhost', port=8186)
http_client.metric('some_metric', 123, tags={'server_name': 'my-server'})

Telegraf configuration for versions 1.3 and higher

Just follow the sample configuration https://github.com/influxdata/telegraf/tree/master/plugins/inputs/socket_listener

[[inputs.socket_listener]]
  service_address = "udp://localhost:8092"
  data_format = "influx"

Telegraf configuration for versions lower than 1.3

Just follow the sample configuration https://github.com/influxdata/telegraf/blob/b59266249dbeff43ba21bfd3dcc854b12eefd9ca/plugins/inputs/udp_listener/README.md

[[inputs.udp_listener]]
  service_address = "localhost:8092"
  allowed_pending_messages = 10000
  data_format = "influx"

Using with Django

Define configuration in Django settings

TELEGRAF_HOST = 'localhost'
TELEGRAF_PORT = 8092
TELEGRAF_TAGS = {'some-global-tag': 'some-value'}

Then use the client in code

from telegraf.defaults.django import telegraf

telegraf.metric('some-metric', 1)

How to develop

  • Clone or fork this repo
  • Make changes
  • Run tests with python setup.py test
  • Submit a pull request

Contributors

  • bobo333
  • sbi
  • isvinogradov
  • umax
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].