Commit graph

6 commits

Author SHA1 Message Date
Kim Alvefur
1261dfba9f luacheck: Shut up (backports 3caff1f93520, ignores module deleted in trunk) 2022-05-30 17:34:58 +02:00
Kim Alvefur
43351d2b54 Spelling: Fix various spelling mistakes (thanks timeless)
Words, sometimes I wonder how they even work

Maybe I missed something.
2022-03-07 00:13:56 +01:00
Matthew Wild
fa22d40ba3 mod_http_openmetrics: Imported from prosody-modules mod_prometheus @df2246b15075
This version has several changes from the earlier mod_prometheus:

- Conversion of metrics into the text-based OpenMetrics format is moved to
  util.openmetrics
- Support for IP-based access control
- Compatibility with earlier Prosody versions removed
2021-11-24 16:03:05 +00:00
Matthew Wild
2562f23efc util.openmetrics: Use pack from util.table, detect appropriate unpack for Lua 5.1 (thanks sups) 2021-06-14 11:19:42 +01:00
Kim Alvefur
4abc78fb2f util.openmetrics: Prettify format of histogram buckets
"%g" turns 1GB into 1.07374e+09, which is a bit awkward for the bytes
measurements IMO. Turning up the precision, at "%.17g" turns 0.1 into
0.10000000000000001 while "%0.16" gives 0.1, hiding most of those pesky
floating point artefacts. Lua version 5.2 uses "%.14g" ( see
LUA_NUMBER_FMT in luaconf.h.html ) so it seems like a sensible choice
here.
2021-06-08 00:58:27 +02:00
Jonas Schäfer
5d597837f5 Statistics: Rewrite statistics backends to use OpenMetrics
The metric subsystem of Prosody has had some shortcomings from
the perspective of the current state-of-the-art in metric
observability.

The OpenMetrics standard [0] is a formalization of the data
model (and serialization format) of the well-known and
widely-used Prometheus [1] software stack.

The previous stats subsystem of Prosody did not map well to that
format (see e.g. [2] and [3]); the key reason is that it was
trying to do too much math on its own ([2]) while lacking
first-class support for "families" of metrics ([3]) and
structured metric metadata (despite the `extra` argument to
metrics, there was no standard way of representing common things
like "tags" or "labels").

Even though OpenMetrics has grown from the Prometheus world of
monitoring, it maps well to other popular monitoring stacks
such as:

- InfluxDB (labels can be mapped to tags and fields as necessary)
- Carbon/Graphite (labels can be attached to the metric name with
  dot-separation)
- StatsD (see graphite when assuming that graphite is used as
  backend, which is the default)

The util.statsd module has been ported to use the OpenMetrics
model as a proof of concept. An implementation which exposes
the util.statistics backend data as Prometheus metrics is
ready for publishing in prosody-modules (most likely as
mod_openmetrics_prometheus to avoid breaking existing 0.11
deployments).

At the same time, the previous measure()-based API had one major
advantage: It is really simple and easy to use without requiring
lots of knowledge about OpenMetrics or similar concepts. For that
reason as well as compatibility with existing code, it is preserved
and may even be extended in the future.

However, code relying on the `stats-updated` event as well as
`get_stats` from `statsmanager` will break because the data
model has changed completely; in case of `stats-updated`, the
code will simply not run (as the event was renamed in order
to avoid conflicts); the `get_stats` function has been removed
completely (so it will cause a traceback when it is attempted
to be used).

Note that the measure_*_event methods have been removed from
the module API. I was unable to find any uses or documentation
and thus deemed they should not be ported. Re-implementation is
possible when necessary.

   [0]: https://openmetrics.io/
   [1]: https://prometheus.io/
   [2]: #959
   [3]: #960
2021-04-18 11:47:41 +02:00