Cloud foundry app status or health notification?

2019-07-10 03:31发布

问题:

Is there a way to get some notification when a Cloud Foundry application fails or is unreachable? I mean to register to some deployed app and if the status of the application is changed to failed or something, I want to receive a notification.

回答1:

On Pivotal Cloud Foundry, when a app crashes, an event is emitted thru the firehose.

PCF Metrics tile, available from Pivotal, can be deployed to your PCF foudnation. PCF Metrics will track all events for apps running on the foundation and are accessible to developers (thru Apps Manager). I believe Metrics tile tracks history for up to two weeks. I am not aware of any alerting capabilities in the PCF Metrics tile (I could be wrong, in which case, please correct me), that will prompt you when an app crashes.

Other approaches are to implement event logging tools like Splunk, New Relic etc. They support alerts. You will have to build those.

API monitoring tools like AppD, Apigee, and New Relic provide alerting and can notify you went the response time to an app has degraded (as in your app has crashed). This approach is a little more involved. You may require to add an agent to your buildpack, depending on the tool you choose.



回答2:

IMHO there is no such built-in feature for Cloud Foundry, but IBM Cloud offers the Availability Monitoring service to monitor apps and send out alerts in case of unavailability or other similar events. The service is part of the DevOps category in the IBM Cloud catalog.

There is also Alert Notification to manage alerts, the notification of the right groups via all kinds of channels and to track the alert status. For your question you should start with the Availability Monitoring and then work towards how those events are handled.



回答3:

You can use the cf events appname command to get a list of all events about the application, this will print out all the recent events such as application crashes.

if run the cf events appname -v you will see the json rest calls the cf cli makes to Cloud Foundry.

You can use Cloud Foundry Java Client to write you own code to interact with Cloud Foundry.

Another thing you can do is stream your application logs to any syslog compatible log aggregation service for example splunk. Then have splunk monitor for app crash events in the log. You can read how to configure app log streaming at the docs



回答4:

This functionality is scheduled to be available with PCF Metrics 1.5 and can be seen with PWS (Pivotal Web Services) in Alpha Mode.

The functionality is available under the Monitors Tab inside of PCF Metrics (1.5).

Webhook notifications (i.e. Slack) can be configured for a number of Events (including as you discussed crashes).