Using a9s LogMe for PCF

This topic describes how to use a9s LogMe for Pivotal Cloud Foundry (PCF) after it has been successfully installed.

Stream App Logs to LogMe

To use a9s LogMe for PCF with an app, create a service instance and bind the service instance to your app. For more information on managing service instances, see Managing Service Instances with the cf CLI.

View the Service Offering

After the tile is installed, run cf marketplace to see a9s-logme service offering and its service plans:

$ cf marketplace
Getting services from marketplace in org test / space test as admin...
OK
service    plans                                                                            description
a9s-logme  logme-single-small, logme-single-big, logme-cluster-small, logme-cluster-big     This is the anynines LogMe service.

For more information on available service plans, see Configure Service Plans.

Create a LogMe Service Instance

To provision a LogMe instance, run cf create-service SERVICE-NAME PLAN-NAME INSTANCE-NAME where INSTANCE-NAME is any name you want to give the instance you create.

$ cf create-service a9s-logme logme-single-small my-logme-service

Note: This may take several minutes.

Run the cf services command to list all your service instances. To view the status of a specific service instance, run cf service INSTANCE-NAME.

Bind the Logme Service to Your App

After the LogMe service instance is created, run cf bind-service APP-NAME INSTANCE-NAME to bind the LogMe service to any App whose logs should be streamed:

$ cf bind-service my-app my-logme-service

Restage or Restart Your App

To enable your app to access the LogMe service instance, run cf restage APP-NAME or cf restart APP-NAME.

See Your App’s logs

Perform the following steps to see your application’s logs:

  1. Grap the dashboard URL with cf service my-logme-service:

    Service instance: my-logme-service
    Service: a9s-logme
    Bound apps: my-app
    Tags:
    Plan: logme-single-small
    Description: This is the anynines LogMe service.
    Documentation url: https://a9s-logme-dashboards.apps.dev2.a9s-ops.your-domain.com/service-instance/a89f3114-5e77-40a5-b3b0-34a9741f3cd5
    Dashboard:
    Last Operation
    Status: create succeeded
    Message:
    Started: 2017-07-22T17:10:21Z
    Updated: 2017-07-22T17:13:26Z
    

  2. Browse to the dashboard URL and authenticate on the redirected page with your Cloud Foundry credentials: Pcf authentication page

  3. Click Authorize to approve the authorization request: Pcf authorization page

  4. In the dashboard that appears, specify the Index name or pattern and the Time-field name. For the Index name or pattern you could use the prefilled value. Dashboard index For the Time-field name use the only available value, @timestamp. Dashboard timestamp

  5. Click Create to apply the settings.

Your application’s logs appear on the Discover tab of the dashboard:

Dashboard app logs

Stream a9s Service Logs to LogMe

To use a LogMe service instance to monitor another service instance, follow the two first steps of Stream application logs to LogMe to create an a9s LogMe service instance.

Create a Service Key

After the LogMe service instance is created, run cf create-service-key my-logme-service SERVICE-KEY-NAME to create a new key for your service instance:

$ cf create-service-key my-logme-service key1
$ cf service-key my-logme-service key1

{
 "host": "syslog://d37f7da-logstash.service.dc1.consul:514",
 "password": "a9sfd6e0d814e78c903290ebb5a7207b20c5f0a2653",
 "username": "a9sed20b19c769f0804bc68b97d02cba86e9c3a0379"
}

Update Your Service

Run cf update-service INSTANCE-NAME -c PARAMETERS-AS-JSON to update the syslog endpoint of the instance you want to monitor with LogMe. For this, you need to give the URL given by the cf service-key command as a value for the syslog key.

$ cf update-service service-instance-to-monitor \
-c '{"syslog": ["d37f7da-logstash.service.dc1.consul:514"]}'

See Your Service’s Logs

Perform the following steps to see your service’s logs:

  1. Grap the dashboard URL with cf service my-logme-service:

    Service instance: my-logme-service
    Service: a9s-logme
    Bound apps: my-app
    Tags:
    Plan: logme-single-small
    Description: This is the anynines LogMe service.
    Documentation url: https://a9s-logme-dashboards.apps.your-domain.com/service-instance/a89f3114-5e77-40a5-b3b0-34a9741f3cd5
    Dashboard:
    Last Operation
    Status: create succeeded
    Message:
    Started: 2017-07-22T17:10:21Z
    Updated: 2017-07-22T17:13:26Z
    

  2. Browse to the dashboard URL and authenticate on the redirected page with your Cloud Foundry credentials: Pcf authentication page

  3. Click Authorize to approve the authorization request: Pcf authorization page

  4. The dashboard appears. Specify the Index name or pattern and the Time-field name. For the Index name or pattern you can use the prefilled value. Dashboard index For the Time-field name use the only available value, @timestamp. Dashboard timestamp

  5. Click Create to apply the settings.

Your service’s logs appear on the Discover tab of the dashboard:

Dashboard service logs

Stop Streaming App Logs to LogMe

Follow the steps below to stop streaming the logs of your applications to LogMe.

List Available Services

Run cf services to list available service instances and get the name of the service instance you want to delete.

$ cf services

Getting services in org test / space test as admin...
OK

name                 service       plan                   bound apps        last operation
my-logme-service     a9s-logme     logme-single-small     a9s-logme-app     create succeeded

This example shows that my-logme-service is bound to the a9s-logme-app app.

Unbind the Service Instance

If your LogMe service instance is bound to an app, you will need to unbind them first. Run cf unbind-service APP-NAME INSTANCE-NAME to unbind the service from your app:

$ cf unbind-service a9s-logme-app my-logme-service

Delete the Service Instance

Run cf delete-service INSTANCE-NAME to delete the service instance:

$ cf delete-service my-logme-service

Note: This may take several minutes.

Deleting a service deprovisions the corresponding infrastructure resources. Run the cf services command to view the deletion status.

Stop Streaming Service Logs to LogMe

Follow the steps below to stop streaming the logs of your services to LogMe.

Overwrite Your Service configuration

If you want to stop streaming your service instance logs to your LogMe instance, you can overwrite the syslog key of your service configuration.

Run cf update-service INSTANCE-NAME -c PARAMETERS-AS-JSON to update the syslog endpoint of the instance you don’t want to monitor anymore. For this, you need to overwrite the value of the syslog key with an empty string.

$ cf update-service service-instance-to-monitor -c '{"syslog": [""]}'

Delete the Service Instance

If you are not using it anymore, you may want to delete the service key and the service instance itself. Run cf delete-service-key INSTANCE-NAME SERVICE-KEY-NAME and cf delete-service INSTANCE-NAME to do so.

$ cf delete-service-key my-logme-service key1
$ cf delete-service my-logme-service

Note: This may take several minutes.

Deleting a service deprovisions the corresponding infrastructure resources. Run the cf services command to view the deletion status.

Create a pull request or raise an issue on the source for this page in GitHub