Falcon to Telegraf middlewares
Project description
falcon-telegraf-middleware
What is this?
Package to ease gathering metrics from Falcon APIs into InfluxDB via a Telegraf. By use of middlewares this orthogonal functionality is added in a hassle-free way minimizing required work. Sane defaults make quickstart really quick 👍
How?
Inject the middleware (or couple of them) when creating Api
instance:
from falcon_telegraf import LogHits, Timer
telegraf_client = TelegrafClient('localhost', 8094)
app = falcon.API(
middleware=[
LogHits(telegraf_client),
Timer(),
]
)
Note that passing telegraf_client
is totally optional.
Measurement names can be set when creating middleware, prefixed or autogenerated.
Middlewares
LogHits
Creates a metric named hits-path/to/endpoint with one fields called hits
with value 1.
Executes after on-*
method was called. Because of this you can add custom tags and values.
Example:
def on_get(self, request, response, some_path_variable):
request.context['telegraf_tags']['my_new_tag'] = 'this_tags_value'
request.context['telegraf_values']['some_path_variable'] = some_path_variable
...
Timer
Reports time in ms elapsed between registering response and registering request. Default metric prefix is time-
.
Other things in processing pipeline can affect it's readings so take them with a grain of salt.
Deploy
First bump version in setup.py
in master branch via merge request. Afterwards push a version tag and wait.
git tag `date +"%Y.%-m.%-d.1"`
git push --tags
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for falcon-telegraf-middleware-2018.10.12.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 023ed1b2885986d0cff7a2b38d470870762c343f1d951d6e11d10b2be4446f69 |
|
MD5 | 79ce74283378ff6e136301b9d363015d |
|
BLAKE2b-256 | 45732e69a28216e041e7b006c60359527c2409a38744ab22bead2e600c9c31af |