Tiven Wang
Wang Tiven December 05, 2017
425 favorite favorites
bookmark bookmark
share share

日志系统(Log)对于一个应用程序更是对一个云平台的 Maintainability 至关重要。 CloudFoundry Platform 也不例外,开发了她自己的日志管理系统 Loggregator

Image: loggregator architecture new

关于Loggregator详细的架构,对 CloudFoundry 平台管理感兴趣的读者可以详细研读其文档。本篇我们只介绍如何把 CloudFoundry 应用的日志收集到第三方日志管理系统中,以便进行详细分析。

Log Management Services

Cloud Foundry 支持众多第三方日志管理系统,包括 Logit.io, Papertrail, Splunk, Splunk Storm, SumoLogic, Logsene 等。我们不深入介绍各个系统的异同优劣,只介绍如何同 Cloud Foundry 配置起来。

Papertrail

Papertrail 相对比较简单易懂,作为入门比较合适。注册用户后访问链接 https://papertrailapp.com/systems/new 创建一个新的日志系统,选择 I use Cloud Foundry 你会得到提示:

CloudFoundry will log to logs6.papertrailapp.com:48899 and appear in CloudFoundry Events.

然后创建 CloudFoundry 的 User-Provided Service Instances

$ cf cups my-logs -l syslog-tls://logs6.papertrailapp.com:48899

-l 参数说明一个日志系统链接,应用程序可以往此链接上写入日志内容。

然后把此 User-Provided Service Instance 绑定给你需要输出日志的应用程序

$ cf bind-service cook my-logs

重启应用使配置生效,你便可以在这个第三方日志管理系统中看到 CloudFoundry 应用程序的日志了

$ cf restage cook

syslog URL

Cloud Foundry uses the syslog URL to route messages to the service. The syslog URL has a scheme of syslog, syslog-tls, or https, and can include a port number. For example: syslog://logs.example.com:1234

Elastic Runtime does not support using syslog-tls with self-signed certificates. If you are running your own syslog server and want to use syslog-tls, you must have an SSL certificate signed by a well-known certificate authority.

references:

https://docs.pivotal.io/pivotalcf/1-6/devguide/services/log-management.html

http://scottfrederick.cfapps.io/blog/2014/02/20/cloud-foundry-and-logstash

https://stackoverflow.com/questions/34181094/set-logging-level-in-spring-boot-via-environment-variable

https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html

https://commons.apache.org/proper/commons-logging/

Similar Posts

  • Try Cloud Foundry 12 - Config Server Config Server for Pivotal Cloud Foundry (PCF) is an externalized application configuration service, which gives you a central place to manage an application’s external properties across all environments.
  • Microservices - API Gateway Implement an API gateway that is the single entry point for all clients. The API gateway handles requests in one of two ways. Some requests are simply proxied/routed to the appropriate service. It handles other requests by fanning out to multiple services.
  • Microservices - Circuit Breaker 访问远程服务时, 比依赖超时时间更好一些的方式是一种叫断路器(Circuit Breaker)的模式. Circuit Breaker 就像一位交通警察, 在前方道路畅通的情况下, 他会放行; 当前方道路由于各种原因拥堵时, 他会告诉你前方道路不通请回; 如果他是个更智能的交警的话, 还会告诉你前方道路部分拥堵, 只允许部分车辆通过, 比如实行单双号.
  • Redis Redis
  • Try Cloud Foundry 11 - Autoscaler Autoscaler
  • Microservices - Load Balancing 在微服务架构中每个服务都可能有多个运行实例, 那么服务消费者在调用服务时怎么定位应该把请求发送给哪个实例呐? 这就是负载均衡 Load Balancing 要做的事情。Load Balancing 可以在服务端也可以是在消费端。

Comments

comments powered by Disqus
Back to Top