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:
telegraf_client = TelegrafClient('localhost', 8094)
app = falcon.API(
middleware=[
LogHits(telegraf_client),
TimeRequests(),
]
)
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.
LogHitsContextAware
Similar to LogHits
but executes after on-*
method was called and adds more context data. Because of this you can add custom tags.
Example:
def on_get(self, request, response, some_path_variable):
request.context['my_new_tag'] = 'this_tags_value'
request.context['some_path_variable'] = some_path_variable ## this is unnecessary - it's logged by middleware
...
It's metric name is the same as for LogHits
.
Note that using this two middlewares in the sam API doesn't make any sense.
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.4.19.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c3e73ae2f64f5574815ec70f80275a270283cd6895d32c3a808918d4bb356d2 |
|
MD5 | 30327020330c30304d9a3118c3418382 |
|
BLAKE2b-256 | 8fd86b573e8c08025cd920b9a4258a2c035407b2c9bbe293db3db23a5d8dcee9 |