Integrate 3rd Party Log Management Service with Cloud Foundry (PCF) (2022)
As seen in previous tutorial, we learned how to create spring boot application and deplying to Pivotal Cloud Foundry (PCF).
Loggregator is the Cloud Foundry component used for logging, it gives stream of output logs from your application along with Cloud Foundry system components logs which communicates with your application during updates and execution.
Loggregator will stream logs to your terminal by default. If you want more than the limited amount of logging information that can be buffered by Loggregator, you can drain logs to a third-party log management service.
Here in above diagram, Log Mgr indicates any 3rd party log management services like Papertrail, Splunk etc.
We will use free log management service Papertrailapp to integrate with Cloud Foundry.Now lets move ahead and learn step by step how to configure 3rd party log management service with Pivotal Cloud Foundry(PCF).
Create Papertrail Account
- Go to papertrailapp home page.
- Create account by clicking on Signup button and provide all details.
- Click on Add your first system.
- Papertrail provides a log destination to use with a Cloud Foundry log drain for your application. Register each app separately if you have multiple Cloud Foundry apps.
Copy Papertrail Log destination
logs5.papertrailapp.com:17805, this would be required in coming steps when creating service with Cloud Foundry.
Set up Cloud Foundry drain
- Login to Cloud foundry from command prompt using
cf login -a api.run.pivotal.io
D:\>cf login -a api.run.pivotal.io API endpoint: api.run.pivotal.io Email> firstname.lastname@example.org Password> Authenticating... OK Targeted org techgeeknext-org Select a space (or press enter to skip): 1. development 2. Production Space> 1 Targeted space development API endpoint: https://api.run.pivotal.io (API version: 2.142.0) User: email@example.com Org: techgeeknext-org Space: development
D:\>cf cups techgeeknext-logs -l syslog-tls://logs3.papertrailapp.com:17805 Creating user provided service techgeeknext-logs in org techgeeknext-org / space development as firstname.lastname@example.org... OK
D:\>cf services Getting services in org techgeeknext-org / space development as email@example.com... name service plan bound apps last operation broker upgrade available techgeeknext-logs user-provided techgeeknextRabbitmqservice cloudamqp lemur techgeeknext-springBootRabbitMq create succeeded appdirect
D:\>cf bind-service techgeeknext-springBootRabbitMq techgeeknext-logs Binding service techgeeknext-logs to app techgeeknext-springBootRabbitMq in org techgeeknext-org / space development as firstname.lastname@example.org... OK TIP: Use 'cf restage techgeeknext-springBootRabbitMq' to ensure your env variable changes take effect
Note: If you don't have any example to test in Pivotal Cloud Foundry, you can download sample example , bind it using above command and use it for testing.
D:\>cf restage techgeeknext-springBootRabbitMq This action will cause app downtime. Restaging app techgeeknext-springBootRabbitMq in org techgeeknext-org / ............. ............. state since cpu memory disk details #0 running 2019-11-04T13:11:34Z 0.0% 125.2M of 1G 127.4M of 1G