<p>Matt Jordan <strong>uploaded patch set #8</strong> to this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11337">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add core Prometheus support to Asterisk<br><br>Prometheus is the defacto monitoring tool for containerized applications.<br>This patch adds native support to Asterisk for serving up Prometheus<br>compatible metrics, such that a Prometheus server can scrape an Asterisk<br>instance in the same fashion as it does other HTTP services.<br><br>The core module in this patch provides an API that future work can build<br>on top of. The API manages metrics in one of two ways:<br>(1) Registered metrics. In this particular case, the API assumes that<br>    the metric (either allocated on the stack or on the heap) will have<br>    its value updated by the module registering it at will, and not<br>    just when Prometheus scrapes Asterisk. When a scrape does occur,<br>    the metrics are locked so that the current value can be retrieved.<br>(2) Scrape callbacks. In this case, the API allows consumers to be<br>    called via a callback function when a Prometheus initiated scrape<br>    occurs. The consumers of the API are responsible for populating<br>    the response to Prometheus themselves, typically using stack<br>    allocated metrics that are then formatted properly into strings<br>    via this module's convenience functions.<br><br>These two mechanisms balance the different ways in which information is<br>generated within Asterisk: some information is generated in a fashion<br>that makes it appropriate to update the relevant metrics immediately;<br>some information is better to defer until a Prometheus server asks for<br>it.<br><br>Note that some care has been taken in how metrics are defined to<br>minimize the impact on performance. Prometheus's metric definition<br>and its support for nesting metrics based on labels - which are<br>effectively key/value pairs - can make storage and managing of metrics<br>somewhat tricky. While a naive approach, where we allow for any number<br>of labels and perform a lot of heap allocations to manage the information,<br>would absolutely have worked, this patch instead opts to try to place<br>as much information in length limited arrays, stack allocations, and<br>vectors to minimize the performance impacts of scrapes. The author of<br>this patch has worked on enough systems that were driven to their knees<br>by poor monitoring implementations to be a bit cautious.<br><br>Additionally, this patch only adds support for gauges and counters.<br>Additional work to add summaries, histograms, and other Prometheus<br>metric types may add value in the future. This would be of particular<br>interest if someone wanted to track SIP response types.<br><br>Finally, this patch includes unit tests for the core APIs.<br><br>ASTERISK-28403<br><br>Change-Id: I891433a272c92fd11c705a2c36d65479a415ec42<br>---<br>A configs/samples/prometheus.conf.sample<br>A include/asterisk/res_prometheus.h<br>A res/res_prometheus.c<br>A res/res_prometheus.exports.in<br>A tests/test_res_prometheus.c<br>5 files changed, 2,273 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/37/11337/8</pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11337">change 11337</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11337"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I891433a272c92fd11c705a2c36d65479a415ec42 </div>
<div style="display:none"> Gerrit-Change-Number: 11337 </div>
<div style="display:none"> Gerrit-PatchSet: 8 </div>
<div style="display:none"> Gerrit-Owner: Matt Jordan <mjordan@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Matt Jordan <mjordan@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>