You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 35 Next »

Bug Reference

https://issues.apache.org/jira/browse/CLOUDSTACK-3471

Branch

master

Introduction

As of cloudstack 4.3 there is no api that can aggregate log messages by the job id. Since logging is a typically a service that can be and is usually available outside the IaaS core, it was felt that instead of integrating this as an api within cloudstack, it would be better to provide a generic logsearch service that could be invoked by cloudstack to retrieve log messages. We describe the mechanism on how to achieve this in what follows.

Purpose

This is typically useful to root admin users.

References

Document History

Author

Description

Date

Saurav Lahiri

Inital Draft

12/14/2013

Glossary

Feature Specifications

Use cases

  1. Root Admin users can query this service to quickly identify the sequence of steps related to a particular Job.

  2. QA can use this service to link the log messages related to automated test failures.

Architecture and Design description

The system will comprise of a log shipping layer. This layer will be responsible for collecting logs from each of the management server shipping them to a centralized place. We describe how logstash can be used as the shipping layer. It will be configured to use redis to ship individual log files to a centralized location. Fluentd could be another option.

The shipping phase will interact with another layer called the indexer/search layer. This layer will also enable storing the logs in a format that will help in writing search queries. Here we describe the use of logstash to recieve the individual log files and elasticsearch to search through these. Before logstash outputs the recieved messages to elasticsearch, it will apply a specific grok filter that will split the input messages into key value pairs. The key value pair will allow creation of search queries by (key,value). Via the elasticsearch REST api , search queries can be constructed for required jobid.

Instances of Logstash:

Logstash can aggregate log messages from multiple nodes and multiple log files. In a typical production environment, cloudstack is configured with multiple management server instances for scalability and redundancy. One instance of logstash will be configured to run on each of the management server and will ship the log to redis. The logstash process is reasonably light in terms of memory consumption and should not impact the management server.

Instances of elasticsearch and redis

Elasticsearch runs as a horizontal scale out cluster. We describe the process of creating and using seperate Elastic search nodes:

In this configuration any linux user template can be used to spawn elasticsearch nodes. The number of such nodes should be configurable via a global parameter. One of the node will be designated as the master node, which will also run the redis instance.

Logstash Configuration on the log shipping layer.

 

=====================================================================================================
input {
file {
type => "apache"
path => [ "/var/log/cloudstack/management/management-server.log" ]
}
}
output {
stdout { codec => rubydebug }
redis { host => "192.168.56.100" data_type => "list" key => "logstash" }
}
=====================================================================================================

Logstash configuration on the index/search layer.

input {
redis {
host => "<host>"
# these settings should match the output of the agent
data_type => "list"
key => "logstash"

# We use the 'json' codec here because we expect to read
# json events from redis.
codec => json
}
}
filter
{
grok
{
match => [ "message","%{YEAR:year}-%{MONTHNUM:month}-%{MONTHDAY}[T ]%{HOUR}:?%{MINUTE}:?%{SECOND}[T ]INFO%{GREEDYDATA}job[\-]+%{INT:jobid}\s*=\s*\[\s*%{UUID:uuid}\s*\]%{GREEDYDATA}"]
named_captures_only => true
}
}
output
{
stdout { debug => true debug_format => "json"}
elasticsearch {
host => "<host>"
}
}

=====================================================================================================

 

API Command :

A new API command ExtractLogByJobIdCmd will be introduced. This will be implemented as a synchronous command.

Manager:

The manager class will implement the actual functionality of querying elastic search for log messages that match the specified filters. For doing this the Elasticsearch REST api queries will be used. Post method will be used with elasticsearch DSL to specify the required query. DSL is quite flexible and in future if support is required to filter by time stamp and other values DSL would help achieve that with ease.
DSL query for searching logs by jobid

{
    "query": {
        "query_string": {
            "query": "\<jobid\>",
   "fields" : "jobid"
        }
    }
}

Web Services APIs

A new API will introduced which can be accessed as
http://<host>:8080/client/api?command=extractLogByJobId&jobid=<jobid>

 

UI flow

None

IP Clearance

  • Logstash which is an opensource log management tool and is covered under Apache 2.0 license
  • Elasticsearch which is a search and analytics tool and is again covered under Apache 2.0 license. 

Appendix

Appendix A:Appendix B: 

Labels: 

  • No labels