how to make logging even more feature rich by using a queueing server

15
| Log management as a service Simplify Log Management How to Make Logging Even More Feature Rich By Using a Queueing Server Matthew Setter

Upload: loggly

Post on 15-Jul-2015

269 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

How to Make Logging Even More Feature Rich By Using a Queueing Server

Matthew Setter

Page 2: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

• Do you want some form of local persistence?

• Do you need additional processing capabilities?

Is Your Logging Good Enough?

image copyright i k o http://goo.gl/vEWrxW

Logging is essential. But sometimes you can make life easier,

perhaps better, by extracting the logging logic

Page 3: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

Queueing Servers Extract Your Logging Logic?

Page 4: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

1. They allow apps to respond quicker

2. They introduce fully asynchronous functionality to backend systems

3. They increase reliability and uptime

Why Use a Queueing Server?

image copyright Oberazzi http://goo.gl/ZRGP47

Page 5: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

•  Applications can focus more on what they’re designed for

•  Applications can be more responsive user needs

•  Logging can be managed by a separate application

•  Logging can be scaled up and down as needed

Other Benefits of Queueing Servers

image copyright Ken Fager http://goo.gl/kQ0q2E

Page 6: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

What is a Queueing Server?

A queueing server has multiple queues which can hold different types of information, or messages. Messages are added to the queue by processes often referred to as producers and removed from the queue by processes known as consumers.

Page 7: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

How Does a Queueing Server Work?

image copyright Surendra Pulagam http://goo.gl/go5rJ3

A process, called a producer, adds a message to a queue

A process, called a consumer, retrieves the message from the queue, then processes the information contained in the message

Page 8: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

Item Description

Message The message to be logged. e.g., { operation: “read-user-account”, status: “OK” }

Priority The message priority level

Params Any extra information, such as formatting, memory observation and so on.

What is a Message Object

Page 9: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

<?php require('vendor/autoload.php'); use Pheanstalk\Pheanstalk; $pheanstalk = new Pheanstalk('127.0.0.1'); $queueName = "log-messages-queue"; $pheanstalk->useTube($queueName)->put( json_encode( [ 'message' => 'Unable to connect to MySQL database', 'priority' => 'debug', 'params' => [ 'logMemoryUsage' => true, 'format' => '%datetime% - %channel% - %level_name% - %message%\n', ] ] ) );

Code Example Adding a Message To a Queue

Page 10: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

Now There’s a Message In The Queue

Page 11: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

<?php require 'vendor/autoload.php'; use Pheanstalk\Pheanstalk; $pheanstalk = new Pheanstalk('127.0.0.1'); $queueName = "log-messages-queue"; $pheanstalk->watch($queueName); while ($job = $pheanstalk->reserve()) { $messageData = json_decode($job->getData()); $log = getLoggerService($messageData); $logLevel = "add" . ucfirst(strtolower($messageData->priority)); $log->$logLevel($messageData->message); $pheanstalk->delete($job); }

Code Example Extract, Log & Delete The Message

Page 12: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

•  Check Your Benchmarks - speed may not be related to logging

•  Don’t use a queueing server before you need to •  Analyze & debug your applications •  Check if your language or 3rd party library

natively supports queueing or queueing-like functionality

Caveats

Page 13: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

Queuing Servers Can: •  Allow for more efficient logging •  Help reduce application overhead •  Help increase responsiveness •  Make applications more maintainable

In Conclusion

Page 14: How to Make Logging Even More Feature Rich By Using a Queueing Server

| Log management as a service Simplify Log Management

Want Your Logging Approach to Result in More Insights?

About Us:

Loggly is the world’s most popular cloud-based log management solution, used by more

than 5,000 happy customers to effortlessly spot problems in real-time, easily pinpoint

root causes and resolve issues faster to ensure application success.

Let Loggly help you with the heavy lifting!

Visit us at loggly.com or follow @loggly on Twitter.

Try Loggly FREE for 30 days