Streaming Logs from Apps with the Hybrid Agent

You can retrieve app logs directly from the app container using the TIBCO Cloud Integration - Hybrid Agent. You can do this with the --logStream option for the tibagent start agent command.

The --logStream command streams app logs from all apps using the configured access key to standard output.

When using the --logStream option, the Hybrid Agent checks for new apps bound to the same access key every 10 seconds. When new apps are found, it streams the new app's logs as well. Log streaming for an app stops when an app is either deleted or no longer bound to the same access key.

Requirements

Usage

To stream logs, run the following command:

tibagent start agent --logStream <agentName>

This command starts a TIBCO Cloud Integration - Hybrid Agent instance using the default configuration and streams logs to standard output from all apps that use the configured access key. One socat listener aggregates all logs from multiple apps and multiple app instances.

You can specify a port using the following command.

tibagent start agent --logStream --logStreamPort <port number> <agentName>

You can also specify a different configuration with the --config-dir option:

tibagent start agent --config-dir ~/config2 --logStream <agentName>

Log Format

Log output includes log messages for TIBCO Cloud Integration - Hybrid Agent and each app.

Message Body Format

Messages are formatted in JSON as follows:

{
	"timestamp": <timestamp#>,
	"time": "formatted time string",
	"level" : "<INFO  |WARN|ERROR| DEBUG>",
	"message": "details message"
}

TIBCO Cloud Integration - Hybrid Agent Log Format

TIBCO Cloud Integration - Hybrid Agent logs have the following format:

For example:

Sep 18 15:13:24 192.168.0.13 [a:tibagent:a][27586]: {"timestamp":1600467204,"time":"2020-09-18T15:13:24.559Z","level":"INFO","app":"tibagent","message":"Agent 'apple' started on port '7816' successfully."}
Sep 18 15:13:24 192.168.0.13 [a:tibagent:a][27586]: {"timestamp":1600467204,"time":"2020-09-18T15:13:24.583Z","level":"DEBUG","app":"tibagent","message":"Running socat"}
Sep 18 15:13:25 192.168.0.13 [a:tibtunnel:a][27586]: {"timestamp":1600467205,"time":"2020-09-18T15:13:25.069Z","level":"INFO","app":"tibtunnel","message":"tibtunnel(d66f4f3f3d2d): (TT) client connected"}
Sep 18 15:13:25 192.168.0.13 [a:tibtunnel:a][27586]: {"timestamp":1600467205,"time":"2020-09-18T15:13:25.070Z","level":"INFO","app":"tibtunnel","message":"tibtunnel(d66f4f3f3d2d): (T) tunnel created (WS connection)"}

App Log Format

App logs have the following format:

For example:

Dec 16 15:47:23 tciapp bw/[o:01DTFXRAH526DGH4V5DHDVN4CQ:o][a:6lbfhm3vw5kdv2mxh5mufvo3jmhfnwm2:a][c:bf73f8c11e86:c]:
{ "timestamp": 1576540043, "time": "23:47:23.594", "level": "WARN", "app": "helloworld.application", "message": "[com.tibco.bw.thor.runtime.tools.internal.LogListenerImpl@1f7cec93] osgi.log.org.apache.felix.eventadmin - [EventAdminThread #8] [23:47:23:594] [org.apache.felix.eventadmin_1.4.7.001 [255]] [{org.osgi.service.event.EventHandler}={event.topics=[com/tibco/bw/runtime/AppStateChangedEvent], service.id=140, service.bundleid=89, service.scope=singleton}] EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=com/tibco/bw/runtime/AppStateChangedEvent]  |{org.osgi.service.event.EventHandler}={event.topics=[com/tibco/bw/runtime/AppStateChangedEvent], service.id=140, service.bundleid=89, service.scope=singleton}| Bundle(com.tibco.bw.sharedresource.runtime_6.2.1000.002 [89])] {org.osgi.service.event.EventHandler}={event.topics=[com/tibco/bw/runtime/AppStateChangedEvent], service.id=140, service.bundleid=89, service.scope=singleton}, java.lang.IllegalArgumentException: No enum constant com.tibco.bw.sharedresource.runtime.configuration.ApplicationState.Starting " }
Dec 16 15:47:24 tciapp flogo/[o:01EH5V6ZCCWPS16ND1EWWN5MWP:o][a:f5o5r7rrrakgboa5bzfoenujstd2ubvo:a][c:08bb2b10bdf4:c]:
{ "timestamp": 1600467218, "time": "2020-09-18T22:13:38.716Z", "level": "INFO", "appname": "flogo1", "apptype": "flogo", "orgid": "01EH5V6ZCCWPS16ND1EWWN5MWP", "appid": "f5o5r7rrrakgboa5bzfoenujstd2ubvo", "instance": "08bb2b10bdf4", "message": "[flogo.app-metrics-collector] - Metrics collection is successfully started" }

Notes

There is no persistence of log streams. They are streamed directly from the app output. There is a buffer in memory to tolerate intermittent connections. If the TIBCO Cloud Integration - Hybrid Agent stops running, logs are buffered until a connection is reestablished. Undelivered log entries are then flushed and catch up to the next real-time log entries in the stream. If listener unavailability exceeds this buffer, earlier entries are discarded as new entries fill the buffer in real time. The buffer size is 16 MB per app container.

CPU and Memory Percent Usage Warning Logs

You can configure TIBCO Cloud™ Integration to monitor the percentage usage of CPU and memory of a TIBCO Flogo® or TIBCO BusinessWorks™ App based on a threshold. See Configuring App Variables for details.

The JSON message body of the warning log includes two additional attributes:

For example:

Mar 05 16:51:03 tciapp flogo/[o:01E106VQJNC0ZNZSZ3C0NPKMVJ:o][a:cjf54z4ynervzkvv2v6bud3n7v4wkeoi:a][c:638fea463f23:c]: { "timestamp": 1583426990, "time": "2020-03-05T16:49:50.000Z", "level": "WARN", "appname": "SF_Rest", "apptype": "flogo", "orgid": "01E106VQJNC0ZNZSZ3C0NPKMVJ", "appid": "cjf54z4ynervzkvv2v6bud3n7v4wkeoi", "instance": "638fea463f23", "cpuPercentUsage": 53.20, "memPercentUsage": 2.44, "message": "App CPU usage exceeded threshold 5% (instance:638fea463f23): %CPU=53.20 %MEM=2.44 " }

Mar 05 05:34:33 tciapp flogo/[o:01E106VQJNC0ZNZSZ3C0NPKMVJ:o][a:cjf54z4ynervzkvv2v6bud3n7v4wkeoi:a][c:9e0d60dcbdee:c]: { "timestamp": 1583386435, "time": "2020-03-05T05:33:55.000Z", "level": "WARN", "appname": "SF_Rest", "apptype": "flogo", "orgid": "01E106VQJNC0ZNZSZ3C0NPKMVJ", "appid": "cjf54z4ynervzkvv2v6bud3n7v4wkeoi", "instance": "9e0d60dcbdee", "cpuPercentUsage": 6.40, "memPercentUsage": 4.96, "message": "App Memory usage exceeded threshold 1% (instance:9e0d60dcbdee): %CPU=6.40 %MEM=4.96 " }

Related Topics

Using the Agent for Hybrid Connectivity