<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Module cloudi_service_monitoring</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<hr>

<h1>Module cloudi_service_monitoring</h1>
<ul class="index"><li><a href="#description">Description</a></li><li><a href="#types">Data Types</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>
   <h3><a name="CloudI_Monitoring_Service">CloudI Monitoring Service</a></h3><p>   
This service will update monitoring metrics at regular intervals for the   
Erlang VM and CloudI.  To disable the update, set the interval to   
undefined.</p>.
<p>Copyright © 2015-2020 Michael Truog</p>

<p><b>Version:</b> 2.0.1 Dec 3 2021 23:10:29
  ------------------------------------------------------------------------</p>
<p><b>Behaviours:</b> <a href="_build/default/lib/cloudi_core/doc/cloudi_service.html"><tt>cloudi_service</tt></a>.</p>
<p><b>Authors:</b> Michael Truog (<a href="mailto:mjtruog at protonmail dot com"><tt>mjtruog at protonmail dot com</tt></a>).</p>

<h2><a name="description">Description</a></h2>
   <h3><a name="CloudI_Monitoring_Service">CloudI Monitoring Service</a></h3><p>   
This service will update monitoring metrics at regular intervals for the   
Erlang VM and CloudI.  To disable the update, set the interval to   
undefined.</p>
  
   <p>To allow services to provide metrics based on their execution,   
add service configuration option entries for aspects provided by this   
module (if other aspects are already being used,   
add it to the end of the list).  This can be done automatically with   
the add/1 function, if the service configuration is provided   
programmatically.</p>
  
   <p>Internal services need to add:    
{aspects_init_after,     
[{{cloudi_service_monitoring, aspect_init_after_internal}}]},    
{aspects_request_before,     
[{{cloudi_service_monitoring, aspect_request_before_internal}}]},    
{aspects_request_after,     
[{{cloudi_service_monitoring, aspect_request_after_internal}}]},    
{aspects_info_before,     
[{{cloudi_service_monitoring, aspect_info_before_internal}}]},    
{aspects_info_after,     
[{{cloudi_service_monitoring, aspect_info_after_internal}}]},    
{aspects_terminate_before,     
[{{cloudi_service_monitoring, aspect_terminate_before_internal}}]}</p>
  
   <p>External services need to add:    
{aspects_init_after,     
[{{cloudi_service_monitoring, aspect_init_after_external}}]},    
{aspects_request_before,     
[{{cloudi_service_monitoring, aspect_request_before_external}}]},    
{aspects_request_after,     
[{{cloudi_service_monitoring, aspect_request_after_external}}]},    
{aspects_terminate_before,     
[{{cloudi_service_monitoring, aspect_terminate_before_external}}]}</p>
  
   To monitor logging usage, add (to the logging configuration):
    {aspects_log_after,
     [{{cloudi_service_monitoring, aspect_log_after}}]},
  
<h2><a name="types">Data Types</a></h2>

<h3 class="typedecl"><a name="type-driver">driver()</a></h3>
<p><tt>driver() = <a href="#type-driver_exometer">driver_exometer()</a></tt></p>


<h3 class="typedecl"><a name="type-driver_exometer">driver_exometer()</a></h3>
<p><tt>driver_exometer() = {exometer, Reporters::[{<a href="#type-exometer_reporter_name">exometer_reporter_name()</a>, <a href="#type-exometer_reporter_extra">exometer_reporter_extra()</a>}, ...], Interval::<a href="#type-exometer_interval">exometer_interval()</a>, Owner::<a href="_build/default/lib/cloudi_core/doc/cloudi_service.html#type-source">cloudi_service:source()</a>}</tt></p>
<p> supported drivers</p>

<h3 class="typedecl"><a name="type-exometer_interval">exometer_interval()</a></h3>
<p><tt>exometer_interval() = pos_integer()</tt></p>
<p> milliseconds</p>

<h3 class="typedecl"><a name="type-exometer_reporter_extra">exometer_reporter_extra()</a></h3>
<p><tt>exometer_reporter_extra() = any()</tt></p>


<h3 class="typedecl"><a name="type-exometer_reporter_name">exometer_reporter_name()</a></h3>
<p><tt>exometer_reporter_name() = atom()</tt></p>


<h3 class="typedecl"><a name="type-metric_list">metric_list()</a></h3>
<p><tt>metric_list() = [{<a href="#type-metric_type">metric_type()</a>, <a href="#type-metric_name">metric_name()</a>, <a href="#type-metric_value">metric_value()</a>}]</tt></p>


<h3 class="typedecl"><a name="type-metric_name">metric_name()</a></h3>
<p><tt>metric_name() = [atom() | binary() | integer(), ...]</tt></p>


<h3 class="typedecl"><a name="type-metric_type">metric_type()</a></h3>
<p><tt>metric_type() = counter | spiral | gauge | histogram</tt></p>


<h3 class="typedecl"><a name="type-metric_value">metric_value()</a></h3>
<p><tt>metric_value() = non_neg_integer()</tt></p>


<h2><a name="index">Function Index</a></h2>
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#add-1">add/1</a></td><td>
  <h4><a name="Add_cloudi_service_monitoring_service_configuration_options.">Add cloudi_service_monitoring service configuration options.</a></h4>
  Programmatically adds service configuration options to provide
  service metrics based on service events.</td></tr>
<tr><td valign="top"><a href="#aspect_info_after_internal-0">aspect_info_after_internal/0</a></td><td>
  <h4><a name="Function_for_aspects_info_after_service_configuration_option.">Function for aspects_info_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_info_after_internal}}.</td></tr>
<tr><td valign="top"><a href="#aspect_info_before_internal-0">aspect_info_before_internal/0</a></td><td>
  <h4><a name="Function_for_aspects_info_before_service_configuration_option.">Function for aspects_info_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_info_before_internal}}.</td></tr>
<tr><td valign="top"><a href="#aspect_init_after_external-0">aspect_init_after_external/0</a></td><td>
  <h4><a name="Function_for_aspects_init_after_service_configuration_option.">Function for aspects_init_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_init_after_external}}.</td></tr>
<tr><td valign="top"><a href="#aspect_init_after_internal-0">aspect_init_after_internal/0</a></td><td>
  <h4><a name="Function_for_aspects_init_after_service_configuration_option.">Function for aspects_init_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_init_after_internal}}.</td></tr>
<tr><td valign="top"><a href="#aspect_log_after-0">aspect_log_after/0</a></td><td>
  <h4><a name="Function_for_aspects_log_after_logging_configuration_option.">Function for aspects_log_after logging configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_log_after}}.</td></tr>
<tr><td valign="top"><a href="#aspect_log_before-0">aspect_log_before/0</a></td><td>
  <h4><a name="Function_for_aspects_log_before_logging_configuration_option.">Function for aspects_log_before logging configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_log_before}}.</td></tr>
<tr><td valign="top"><a href="#aspect_request_after_external-0">aspect_request_after_external/0</a></td><td>
  <h4><a name="Function_for_aspects_request_after_service_configuration_option.">Function for aspects_request_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_request_after_external}}.</td></tr>
<tr><td valign="top"><a href="#aspect_request_after_internal-0">aspect_request_after_internal/0</a></td><td>
  <h4><a name="Function_for_aspects_request_after_service_configuration_option.">Function for aspects_request_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_request_after_internal}}.</td></tr>
<tr><td valign="top"><a href="#aspect_request_before_external-0">aspect_request_before_external/0</a></td><td>
  <h4><a name="Function_for_aspects_request_before_service_configuration_option.">Function for aspects_request_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_request_before_external}}.</td></tr>
<tr><td valign="top"><a href="#aspect_request_before_internal-0">aspect_request_before_internal/0</a></td><td>
  <h4><a name="Function_for_aspects_request_before_service_configuration_option.">Function for aspects_request_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_request_before_internal}}.</td></tr>
<tr><td valign="top"><a href="#aspect_terminate_before_external-0">aspect_terminate_before_external/0</a></td><td>
  <h4><a name="Function_for_aspects_terminate_before_service_configuration_option.">Function for aspects_terminate_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_terminate_before_external}}.</td></tr>
<tr><td valign="top"><a href="#aspect_terminate_before_internal-0">aspect_terminate_before_internal/0</a></td><td>
  <h4><a name="Function_for_aspects_terminate_before_service_configuration_option.">Function for aspects_terminate_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_terminate_before_internal}}.</td></tr>
<tr><td valign="top"><a href="#cloudi_service_handle_info-3">cloudi_service_handle_info/3</a></td><td></td></tr>
<tr><td valign="top"><a href="#cloudi_service_init-4">cloudi_service_init/4</a></td><td></td></tr>
<tr><td valign="top"><a href="#cloudi_service_terminate-3">cloudi_service_terminate/3</a></td><td></td></tr>
<tr><td valign="top"><a href="#update-4">update/4</a></td><td></td></tr>
<tr><td valign="top"><a href="#update_or_create-4">update_or_create/4</a></td><td>
  <h4><a name="Update/Create_a_metric.">Update/Create a metric.</a></h4>
  Use cloudi_service:self/1 to get the service process when passing a
  service metric, otherwise use 'undefined' instead of the service process.</td></tr>
<tr><td valign="top"><a href="#update_or_create-5">update_or_create/5</a></td><td>
  <h4><a name="Update/Create_a_metric_with_options.">Update/Create a metric with options.</a></h4>
  Must be called from a service process.</td></tr>
</table>

<h2><a name="functions">Function Details</a></h2>

<h3 class="function"><a name="add-1">add/1</a></h3>
<div class="spec">
<p><tt>add(Internal::<a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-service_internal">cloudi_service_api:service_internal()</a> | <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-service_external">cloudi_service_api:service_external()</a> | <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-service_proplist">cloudi_service_api:service_proplist()</a>) -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-service_internal">cloudi_service_api:service_internal()</a> | <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-service_external">cloudi_service_api:service_external()</a> | <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-service_proplist">cloudi_service_api:service_proplist()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Add_cloudi_service_monitoring_service_configuration_options.">Add cloudi_service_monitoring service configuration options.</a></h4>
  Programmatically adds service configuration options to provide
  service metrics based on service events.</p>

<h3 class="function"><a name="aspect_info_after_internal-0">aspect_info_after_internal/0</a></h3>
<div class="spec">
<p><tt>aspect_info_after_internal() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_info_after_internal_f">cloudi_service_api:aspect_info_after_internal_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_info_after_service_configuration_option.">Function for aspects_info_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_info_after_internal}}.</p>

<h3 class="function"><a name="aspect_info_before_internal-0">aspect_info_before_internal/0</a></h3>
<div class="spec">
<p><tt>aspect_info_before_internal() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_info_before_internal_f">cloudi_service_api:aspect_info_before_internal_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_info_before_service_configuration_option.">Function for aspects_info_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_info_before_internal}}.</p>

<h3 class="function"><a name="aspect_init_after_external-0">aspect_init_after_external/0</a></h3>
<div class="spec">
<p><tt>aspect_init_after_external() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_init_after_external_f">cloudi_service_api:aspect_init_after_external_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_init_after_service_configuration_option.">Function for aspects_init_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_init_after_external}}.</p>

<h3 class="function"><a name="aspect_init_after_internal-0">aspect_init_after_internal/0</a></h3>
<div class="spec">
<p><tt>aspect_init_after_internal() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_init_after_internal_f">cloudi_service_api:aspect_init_after_internal_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_init_after_service_configuration_option.">Function for aspects_init_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_init_after_internal}}.</p>

<h3 class="function"><a name="aspect_log_after-0">aspect_log_after/0</a></h3>
<div class="spec">
<p><tt>aspect_log_after() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_log_f">cloudi_service_api:aspect_log_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_log_after_logging_configuration_option.">Function for aspects_log_after logging configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_log_after}}.</p>

<h3 class="function"><a name="aspect_log_before-0">aspect_log_before/0</a></h3>
<div class="spec">
<p><tt>aspect_log_before() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_log_f">cloudi_service_api:aspect_log_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_log_before_logging_configuration_option.">Function for aspects_log_before logging configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_log_before}}.</p>

<h3 class="function"><a name="aspect_request_after_external-0">aspect_request_after_external/0</a></h3>
<div class="spec">
<p><tt>aspect_request_after_external() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_request_after_external_f">cloudi_service_api:aspect_request_after_external_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_request_after_service_configuration_option.">Function for aspects_request_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_request_after_external}}.</p>

<h3 class="function"><a name="aspect_request_after_internal-0">aspect_request_after_internal/0</a></h3>
<div class="spec">
<p><tt>aspect_request_after_internal() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_request_after_internal_f">cloudi_service_api:aspect_request_after_internal_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_request_after_service_configuration_option.">Function for aspects_request_after service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_request_after_internal}}.</p>

<h3 class="function"><a name="aspect_request_before_external-0">aspect_request_before_external/0</a></h3>
<div class="spec">
<p><tt>aspect_request_before_external() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_request_before_external_f">cloudi_service_api:aspect_request_before_external_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_request_before_service_configuration_option.">Function for aspects_request_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_request_before_external}}.</p>

<h3 class="function"><a name="aspect_request_before_internal-0">aspect_request_before_internal/0</a></h3>
<div class="spec">
<p><tt>aspect_request_before_internal() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_request_before_internal_f">cloudi_service_api:aspect_request_before_internal_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_request_before_service_configuration_option.">Function for aspects_request_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_request_before_internal}}.</p>

<h3 class="function"><a name="aspect_terminate_before_external-0">aspect_terminate_before_external/0</a></h3>
<div class="spec">
<p><tt>aspect_terminate_before_external() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_terminate_before_external_f">cloudi_service_api:aspect_terminate_before_external_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_terminate_before_service_configuration_option.">Function for aspects_terminate_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_terminate_before_external}}.</p>

<h3 class="function"><a name="aspect_terminate_before_internal-0">aspect_terminate_before_internal/0</a></h3>
<div class="spec">
<p><tt>aspect_terminate_before_internal() -&gt; <a href="_build/default/lib/cloudi_core/doc/cloudi_service_api.html#type-aspect_terminate_before_internal_f">cloudi_service_api:aspect_terminate_before_internal_f()</a></tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Function_for_aspects_terminate_before_service_configuration_option.">Function for aspects_terminate_before service configuration option.</a></h4>
  Add as {{cloudi_service_monitoring, aspect_terminate_before_internal}}.</p>

<h3 class="function"><a name="cloudi_service_handle_info-3">cloudi_service_handle_info/3</a></h3>
<div class="spec">
<p><tt>cloudi_service_handle_info(Request, State, Dispatcher) -&gt; any()</tt></p>
<p> </p>
</div>

<h3 class="function"><a name="cloudi_service_init-4">cloudi_service_init/4</a></h3>
<div class="spec">
<p><tt>cloudi_service_init(Args, Prefix, Timeout, Dispatcher) -&gt; any()</tt></p>
<p> </p>
</div>

<h3 class="function"><a name="cloudi_service_terminate-3">cloudi_service_terminate/3</a></h3>
<div class="spec">
<p><tt>cloudi_service_terminate(Reason, Timeout, State) -&gt; any()</tt></p>
<p> </p>
</div>

<h3 class="function"><a name="update-4">update/4</a></h3>
<div class="spec">
<p><tt>update(Type::<a href="#type-metric_type">metric_type()</a>, Name::<a href="#type-metric_name">metric_name()</a>, Value::<a href="#type-metric_value">metric_value()</a>, Driver::<a href="#type-driver">driver()</a>) -&gt; ok</tt><br></p>
<p> </p>
</div>

<h3 class="function"><a name="update_or_create-4">update_or_create/4</a></h3>
<div class="spec">
<p><tt>update_or_create(Service::<a href="_build/default/lib/cloudi_core/doc/cloudi_service.html#type-source">cloudi_service:source()</a> | undefined, Type::<a href="#type-metric_type">metric_type()</a>, Name::<a href="#type-metric_name">metric_name()</a>, Value::<a href="#type-metric_value">metric_value()</a>) -&gt; ok | {error, any()}</tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Update/Create_a_metric.">Update/Create a metric.</a></h4>
  Use cloudi_service:self/1 to get the service process when passing a
  service metric, otherwise use 'undefined' instead of the service process.</p>

<h3 class="function"><a name="update_or_create-5">update_or_create/5</a></h3>
<div class="spec">
<p><tt>update_or_create(Service::<a href="_build/default/lib/cloudi_core/doc/cloudi_service.html#type-source">cloudi_service:source()</a>, Type::<a href="#type-metric_type">metric_type()</a>, Name::<a href="#type-metric_name">metric_name()</a>, Value::<a href="#type-metric_value">metric_value()</a>, Options::[{service_metric, boolean()}]) -&gt; ok | {error, any()}</tt><br></p>
<p> </p>
</div><p>
  <h4><a name="Update/Create_a_metric_with_options.">Update/Create a metric with options.</a></h4>
  Must be called from a service process.  Use cloudi_service:self/1
  to get the service process.  The option service_metric determines
  whether the cloudi_service_monitoring service metric prefix is used
  (which includes the service id, service_metric defaults to false).</p>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc</i></p>
</body>
</html>
