[V5.0.7 and earlier]

Viewing application metrics using third-party consoles

You can monitor your LoopBack® applications by obtaining metrics data. You can send the metrics data to a third-party console, a log file, or syslog.

You enable monitoring for an application by setting the STRONGLOOP_METRICS environment variable. The value of the environment variable is a metrics URL that specifies the destination for the metrics data.

Important: From IBM API Connect Version 5.0.8.7, the apic props command referred to on this page is no longer supported by the API Connect toolkit.
Enter the following command:
apic props:set STRONGLOOP_METRICS=metrics_url --remote --service app_name --organization org_name --server management_cluster_hostname_or_address
where:
  • metrics_url is the metrics URL that specifies the logging destination.
  • app_name is the value of the Name property of the App that references the collective to which the application is published.

    For details on how to create and manage Apps, see Working with Apps.

  • org_name is the provider organization to which the application is published.
  • management_cluster_hostname_or_address is the IP address or host name of the Management cluster to which the application is published.
For details on how to publish an application, see Publishing APIs and applications and Publishing a LoopBack application through the API Designer.

The following sections provide details of the possible logging destinations.

StatsD

StatsD is a simple protocol for log information together with a simple daemon (server) that aggregates and summarizes application metrics. The client communicates with the StatsD server by using the StatsD protocol, and the daemon then generates aggregate metrics and relays them to a graphing or monitoring backend. For more information on StatsD, see StatsD, what it is and how it can help you.

The StatsD Node server has the following capabilities:

Other metrics consumers, such as DataDog, have agents that support the StatsD-protocol.

To use StatsD, set a metrics URL of the following form:
statsd://[host[:port]][/scope]
where:
  • host is the name of the host where the StatsD server is running; the default value is localhost.
  • port is the TCP port that the StatsD server is using; the default value is 8125.
  • scope is a string to scope or identify metrics; for example this might be the name of the application or module.
For example:
apic props:set STRONGLOOP_METRICS=statsd://myhost:1234/app1 --remote --service myApp --organization myOrg --server myhost.com
Example output:
my-app.cpu.user:0.00907|g
my-app.cpu.system:0.01664|g
my-app.cpu.total:0.0257|g
my-app.heap.used:10698193|g
my-app.heap.total:27423366|g
my-app.loop.count:127|c

Hosted Graphite

To use Graphite, set a metrics URL of the following form:
graphite://[host[:port]]
where:
  • host is the name of the host where the Graphite server is running; the default value is localhost.
  • port is the TCP port the Graphite server is using; the default value is 2003.
The metrics data is forwarded to hosted Graphite.
For example:
apic props:set STRONGLOOP_METRICS=graphite://myhost.com:1234 --remote --service myApp --organization myOrg --server myhost.com

Splunk

To use Splunk, set a metrics URL of the following form:
splunk://[host]:port
where:
  • host is the name of the host where the Splunk server is running; the default value is localhost.
  • port is the TCP port that the Splunk server is using; you must provide a value because the protocol has no assigned port.
The metrics data is written to Splunk by using a UDP key-value protocol
For example:
apic props:set STRONGLOOP_METRICS=splunk://myhost.com:1234 --remote --service myApp --organization myOrg --server myhost.com

Log file

To send metrics information to a log file, set a metrics URL of the following form:
log:[file]
where file is the name of the log file that you want to send the metrics information to. If you omit the file name, metrics information is send to the console (stdout).
For example:
apic props:set STRONGLOOP_METRICS=log:myapp.log --remote --service myApp --organization myOrg --server myhost.com

Syslog

To write metrics information using syslog, set a metrics URL of the following form:
syslog:[?[application=appName][&priority=level]]
where:
  • appName is any string; the default value is statsd.
  • level is any of the following values:
    • LOG_DEBUG
    • LOG_INFO (the default)
    • LOG_NOTICE
    • LOG_WARNING
    • LOG_CRIT
For example:
apic props:set STRONGLOOP_METRICS=syslog:?application=myApp&priority=LOG_WARNING --remote --service myApp --organization myOrg --server myhost.com