Documentation
¶
Overview ¶
Package mozzle implements Cloud Foundry application monitor that emits metric events.
Metrics for the following services are emitted.
Regarding memory usage of each application instance.
memory used_bytes memory total_bytes memory used_ratio
Regarding disk usage of each application instance.
disk used_bytes disk total_bytes disk used_ratio
Regarding CPU consumption.
cpu_percent
Regarding each HTTP event (request-response).
http response time_ms http response content_length_bytes
Regarding application availability.
instance running_count instance configured_count
Regarding application events.
app event
Each of the events has attributes specifying the application's org, space, name, id, and the insntace index (when appropriate).
Additionally, the HTTP events have attributes specifying the method, request_id, content length the returned status code and the peer type. There are two peer types - client and server. Client means that measurements are recorded via the Cloud Foundry router's HTTP client that requested the application container and server means that the measurements are recorded for responding to the end user via the router server.
The application event metrics have attributes that describe the event's actor and actee, as well as their ids.
Index ¶
Constants ¶
const DefaultRPCTimeout = 15 * time.Second
DefaultRPCTimeout is the default timeout when making remote calls.
const DefaultRefreshInterval = 15 * time.Second
DefaultRefreshInterval is the default interval for refreshing application states.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppMonitor ¶ added in v0.2.0
type AppMonitor struct { // Emitter is the emitter used for sending metrics. Emitter Emitter // CloudController client for the API. CloudController *ccv2.Client // Firehose streaming client used for receiving logs and events. Firehose Firehose // UAA should provide valid OAuth2 tokens for the specific Cloud Foundry system. UAA oauth2.TokenSource // ErrLog is used for logging erros that occur when monitoring applications. ErrLog *log.Logger // RPCTimeout configures the timeouts when making RPCs. RPCTimeout time.Duration // RefreshInterval configures the polling interval for application // state changes. RefreshInterval time.Duration // contains filtered or unexported fields }
AppMonitor implements a Cloud Foundry application monitor that collects various application metrics and emits them using a provided emitter.
type Emitter ¶ added in v0.2.0
type Emitter interface { // Emit emits the specified application metric. // It should not block and should be safe for concurrent use. Emit(m Metric) }
Emitter should emit application metrics.
type Firehose ¶ added in v0.2.0
type Firehose interface { // Stream should listen indefinitely for all log and event messages. // // The clients should not made any assumption about the order of the // received events. // // Whenever an error is encountered, the error should be sent down the error // channel and Stream should attempt to reconnect indefinitely. Stream(appGUID string, authToken string) (outputChan <-chan *events.Envelope, errorChan <-chan error) }
Firehose should implement a streaming firehose client that streams all log and event messages.
type Metric ¶ added in v0.2.0
type Metric struct { // Application is the name of the application. Application string // ApplicationID is the GUID of the application. ApplicationID string // Organization is the name of the application's organization. Organization string // Space is the name of the application's space. Space string // Time is the time when the event occurred. Time int64 // Service for which the metric is relevant. Service string // Metric value. Could be int64, float32 or float64. Metric interface{} // State is a text description of the service's state - e.g. 'ok', 'warn'. State string // Attributes are key-value pairs describing the metric. Attributes map[string]string }
Metric is a metric regarding an application.
type RiemannEmitter ¶ added in v0.2.0
type RiemannEmitter struct {
// contains filtered or unexported fields
}
RiemannEmitter implements Emitter that interpretes metrics as Riemann events and emits them to a Riemann instance.
func (*RiemannEmitter) Close ¶ added in v0.2.0
func (r *RiemannEmitter) Close() error
Close renders the emitter unusable and frees all allocated resources. The emitter should not be used after it has been closed. There is no guarantee that any queued events will be sent before closing. This particular close never fails.
func (*RiemannEmitter) Emit ¶ added in v0.2.0
func (r *RiemannEmitter) Emit(m Metric)
Emit constructs a riemann event from the specified metric and emits it to Riemann. It is non-blocking and safe for concurrent use by multiple goroutines.
Emit must be used only after calling Initialize, and not after calling Shutdown.
func (*RiemannEmitter) Initialize ¶ added in v0.2.0
func (r *RiemannEmitter) Initialize(network, addr string, ttl float32, queueSize int)
Initialize prepares for emitting to Riemann. It should be called only once, before using the emitter.
Known networks are "tcp", "tcp4", "tcp6", "udp", "udp4" and "udp6". The queueSize argument specifies how many events will be kept in-memory if there is problem with emission.
type Target ¶
type Target struct { API string Username string Password string // Token should be a valid OAuth2 bearer token, including a refresh token. // If token is provided the username and password fields should be left emtpy. Token *oauth2.Token Insecure bool Org string Space string // RPCTimeout configures the timeouts when making RPCs. RPCTimeout time.Duration // RefreshInterval configures the polling interval for application // state changes. RefreshInterval time.Duration }
Target describes a monitoring target.