There are several things wrong with how the retrieval of logging and metric data is currently working. Let’s see, how the current architecture looks like.
Each time you execute “cf push”, “cf app” or “cf logs”, there is a request sent to the traffic controller which needs to lookup every single doppler instance and aggregate the logs and metrics you are interested in. Obviously, this architecture leads to performance issues in a growing environment. And this is why we need Log Cache!
Log Cache is a component co-located on the Doppler servers that duplicates and stores the information coming from Loggregator. Unlike the Firehose data stream, which is constantly cleared to make room for new messages, the Log Cache persists data from Loggregator so that it is possible to query them on demand. The Log Cache is accessible either via the CF CLI plugin or via RESTful interface.
Once you’ve installed the Log Cache plugin as described here https://github.com/cloudfoundry/log-cache-cli, you can use the following CF CLI command to access your logs and metrics:
$ cf tail
“my-app” can either be the app-guid or the app-name
This query would return a series of timestamped metrics like the following:
By default, cf tail returns the 10 most recent messages. Each message includes the following:
There are several flags that you can include with cf tail to focus your queries:
To query the Log Cache programmatically, you can make API calls to its RESTful endpoint:
https://log-cache./api/v1/read/
You will need to provide a UAA authorization token, you can get this via cf CLI executing the command “cf oauth-token” or via API:
curl -v -XPOST -H”Application/json” -u “cf:” –data “username=&password=&client_id=cf&grant_type=password&response_type=token” https://login.lyra-836.appcloud.swisscom.com/oauth/token
Within the API you also have the option to include parameters:
curl -s -H “Authorization: Bearer xxxxx” ‘https://log-cache.lyra-836.appcloud.swisscom.com/api/v1/read/?envelope_types=GAUGE&limit=1’ | jq.
Be smart and switch to Log Cache for getting your app metrics and logs!
Andrea Aymon
Cloud Engineer
Finde deinen Job oder die Karrierewelt, die zu dir passt. In der du mitgestalten und dich weiterentwickeln willst.
Was du draus machst, ist was uns ausmacht.