Class: UU::Logstore::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/uu/logstore/log.rb

Overview

Log is a stream of aggregated, time-ordered events collected from the output streams of uuApps.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session = nil) ⇒ Log

Creates a new instance of Log.

Parameters:

  • session (UU::OS::Security::Session) (defaults to: nil)

    Instance of session representing authenticated user (can be obtained with UU::OS::Security::Session#current_session method).



17
18
19
# File 'lib/uu/logstore/log.rb', line 17

def initialize(session = nil)
  @client = UU::OS::CMD::CommandClient.new(PATH, session)
end

Class Method Details

.get_log_list(app_deployment_uri, parameters = {}) ⇒ Hash

Deprecated.

Use get_record_list instead.

Returns a list of messages from the specified log. This method is a convenience shortcut for the #get_log_list instance method.

Examples:

require "uu/os/security/session"
require "uu_logstore"

UU::OS::Security::Session.("app-deployer-passwd")

response = UU::Logstore::Log.get_log_list("ues:DEV1234-BT:DEV")
puts response

Returns:



116
117
118
# File 'lib/uu/logstore/log.rb', line 116

def self.get_log_list(app_deployment_uri, parameters = {})
  self.new(UU::OS::Security::Session.current_session).get_log_list(app_deployment_uri, parameters)
end

.get_record_list(app_deployment_uri, parameters = {}) ⇒ Hash

Returns a list of records from the specified log. This method is a convenience shortcut for the #get_record_list instance method.

Examples:

Basic usage

require "uu_logstore"
require "uu/os/security/session"

# User needs to be cast into access group associated with the resource pool
# where the specified uuAppBox is deployed.
UU::OS::Security::Session.("app-deployer-passwd")

records = UU::Logstore::Log.get_record_list("ues:DEV1234-BT[123]:DEV[456]:APP[789]", recordType: "TRACE_LOG")
jj records

Returns:



239
240
241
# File 'lib/uu/logstore/log.rb', line 239

def self.get_record_list(app_deployment_uri, parameters = {})
  self.new(UU::OS::Security::Session.current_session).get_record_list(app_deployment_uri, parameters)
end

Instance Method Details

#get_log_list(app_deployment_uri, parameters = {}) ⇒ Hash

Deprecated.

Use #get_record_list instead.

Returns a list of messages from the specified log.

Examples:

require "uu/os/security/session"
require "uu_logstore"

# User needs to be cast into access group associated with the resource pool where uuAppBox
# is deployed and wants to manipulate with.
UU::OS::Security::Session.("app-deployer-passwd")

logstore = UU::Logstore::Log.new(UU::OS::Security::Session.current_session)
response = logstore.get_log_list("ues:DEV1234-BT:DEV")
puts response

Response (containing 1 message)

{
  :messages => [
    {
      :id => "4470bfd1-ce55-11e5-90fe-0242ac110002",
      :timestamp => "2016-02-08T11:15:32.042Z",
      :producer => "performance_log",
      :level => "ERROR",
      :runtimestack => nil,
      :output => nil,
      :hostname => "uuapps-0001.unicornuniverse.eu",
      :message => "{\"LogProducer\":\"performance_log\",\"memory_used\":326, \"cpu_load\":0}"
    }
  ]
}

Parameters:

  • app_deployment_uri (UU::OS::UESURI, String)

    URI of uuApp deployment for which to obtain logs. The value is the result of UU::C3::AppDeployment.deploy or UU::C3::AppDeployment.get_app_deployment_list methods. UESURI must be in canonical or normalized form (i.e. needs to contain IDs, not just codes). This parameter is required.

  • parameters (Hash) (defaults to: {})

    Logstore query filtering parameters.

Options Hash (parameters):

  • to (String)

    Date and time. Search for messages using an absolute time range, specified as to with format yyyy-MM-ddTHH:mm:ss.SSSZ (e.g. 2014-01-23T15:34:49.000Z) or yyyy-MM-dd HH:mm:ss. Parameter from must also be specified if this parameter is specified. May be nil. Current time is used if to is not specified.

  • from (String)

    Date and time. Search for messages using an absolute time range, specified as from with format yyyy-MM-ddTHH:mm:ss.SSSZ (e.g. 2014-01-23T15:34:49.000Z) or yyyy-MM-dd HH:mm:ss. May be nil unless the to parameter is specified. 24 hours ago (starting from current time) is used if from is not specified.

  • level (String)

    Lowest log level of messages to return. May be nil. The value must be one of: ERROR, WARNING, INFO, DEBUG.

    The ERROR level designates error events which prevent normal program execution. Should be corrected immediately.

    The WARNING level designates potentially harmful situations. Nevertheless these situations still allow the application to continue running. This level may be configured in production environment only for a reasonably short time (i.e. to track down a bug).

    The INFO level designates informational messages that highlight the progress of the application at coarse-grained level. This level should not be configured in production environment, only in testing and development environments.

    The DEBUG level designates fine-grained informational events that are most useful to debug an application. This level should not be configured in production environment, only in testing and development environments.

  • runtimestack (String)

    Code of runtime stack that the returned messages contain. This parameter allows to obtain only messages e.g. for widgets or asynchronous commands. May be nil.

  • output (String)

    Output to the log that was captured and processed. A typical example is stdout or stderr. May be nil.

  • hostname (String)

    Hostnames are human-readable nicknames that correspond to the address of a device connected to a network. This parameter allows to obtain only messages logged from a particular host. May be nil.

  • producer (String)

    Log output producer defined by deployed application. It is defined by the application provider. A typical example is catalina or performance_log. May be nil.

Returns:

  • (Hash)

    Response structure.



98
99
100
# File 'lib/uu/logstore/log.rb', line 98

def get_log_list(app_deployment_uri, parameters = {})
  @client.invoke("Log/getLogList", app_deployment_uri, parameters: parameters)
end

#get_record_list(app_deployment_uri, criteria = {}) ⇒ Hash

Returns a list of records from the specified log.

Examples:

Basic usage

require "uu_logstore"
require "uu/os/security/session"

# User needs to be cast into access group associated with the resource pool
# where the specified uuAppBox is deployed.
UU::OS::Security::Session.("app-deployer-passwd")

log = UU::Logstore::Log.new(UU::OS::Security::Session.current_session)
records = log.get_record_list("ues:DEV1234-BT[123]:DEV[345]:APP[789]", recordType: "TRACE_LOG")
jj records

Response

{
  "totalSize": 1,
  "criteria": {
    "recordType": "TRACE_LOG",
    "pageSize": 1000
  },
  "pageEntries": [
    {
      "id": "5695b781-8acd-11e6-b9cf-0242ac110004",
      "time": "2016-06-20T08:39:58Z",
      "recordType": "TRACE_LOG",
      "logLevel": "ERROR",
      "runtimeStackCode": "CMD_JRUBY_V1.0",
      "hostName": "h-tfkeb1mc",
      "nodeName": "dev0137_bt-uu_os_content_structure-cmd-0_4_4-beta003-5767abdd279289e67bc21ae2",
      "nodeImageName": "uu_os_content_structure-cmd:0.4.4-beta003",
      "message": "ArgumentError [ec602990-c326-4613-922d-8af38785b180]: queue_uri is not set",
      "appDeploymentUri": "ues:[84723967990092195]:[571fb9d82792891f35e228de]:[572c7fea27928971931473a1]",
      "appVersion": "0.4.4-BETA003"
    }
  ]
}

Parameters:

  • app_deployment_uri (UU::OS::UESURI, String)

    UESURI of uuApp deployment for which to obtain logs. The value is the result of UU::C3::AppDeployment.deploy or UU::C3::AppDeployment.get_app_deployment_list methods. UESURI must be in canonical or normalized form (i.e. needs to contain IDs, not just codes). This parameter is required.

  • criteria (Hash) (defaults to: {})

    Logstore query filtering and paging criteria. If multiple criteria are specified, the returned records match all of them.

Options Hash (criteria):

  • from (String)

    Oldest time of time interval to get records for. Format is yyyy-MM-ddTHH:mm:ssZ (e.g. 2014-01-23T15:34:49Z) or +yyyy-MM-dd HH:mm:ss+ (the latter uses current time zone). May be nil. When nil is set, time 24 hours ago is assumed.

  • to (String)

    Newest time of time interval to get application log records for. Format is yyyy-MM-ddTHH:mm:ssZ (e.g. 2014-01-23T15:34:49Z) or +yyyy-MM-dd HH:mm:ss+ (the latter uses current time zone). May be nil. When nil is set, current time is assumed.

  • logLevel (String)

    Lowest log level of records to return. May be nil. The value must be one of: FATAL, ERROR, WARNING, INFO, DEBUG.

    • The FATAL level designates error events (on server side) which prevent normal program execution. These events affect SLA.

    • The ERROR level designates alternative flows - incorrect input parameters, etc. That means errors caused by client side.

    • The WARNING level designates potentially harmful situations. Nevertheless these situations still allow the application to continue running.

    • The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.

    • The DEBUG level designates fine-grained informational events that are most useful to debug an application.

    The priority of log levels corresponds to the order stated above. E.g. if the value of this parameter is set to WARNING, records having logLevel attribute set to WARNING, ERROR or FATAL are returned.

  • recordType (String)

    Type of log record. Examples directly supported by uuLogstore - TRACE_LOG (errors, debug messages, …), ACCESS_LOG. Other record types can be introduced by other uuApps. May be nil.

  • runtimeStackCode (String)

    Code of runtime stack that the returned records contain. This parameter allows to obtain only records e.g. for widgets or asynchronous commands. May be nil.

  • nodeName (String)

    Name of node from which records have been logged. This parameter allows to obtain records only from a particular node. May be nil.

  • nodeImageName (String)

    Name of node image from which records have been logged. This parameter allows to obtain records only from a particular node image. May be nil.

  • hostName (String)

    Hostnames are human-readable nicknames that correspond to the address of a device connected to a network. This parameter allows to obtain only records logged from a particular host. May be nil.

  • correlationId (String)

    Identifier of records that have been split from one original record which exceeded the configured record size limit. You can specify last part of index (e.g. 51a…4a6-2) or get all parts of record without specifying (e.g. 51a…4a6). May be nil.

  • traceId (String)

    Identifier of a request that entered or exited the application containers. A request entering uuCloud via a gateway is assigned a traceID by the gateway. Every entity in uuCloud then logs the traceID to its access log if the request enters it. All consequent requests (of the original request) made by uuCloud entities have also the same traceID (for example if a deploy request with a certain traceID reaches uuC3 then all requests made by uuC3 while executing the deploy has the same traceID). May be nil.

  • appVersion (String)

    uuApp version to get records for. Precise version match is performed, i.e. only records having the appVersion attribute set to the precise value specified in this parameter are returned. May be nil.

  • pageSize (Fixnum)

    Result set page size. May be nil. Default value is 1000.

Returns:

  • (Hash)

    Result set ordered from the newest records to the oldest ones.



218
219
220
221
222
# File 'lib/uu/logstore/log.rb', line 218

def get_record_list(app_deployment_uri, criteria = {})
  criteria[:to] = _try_parse_time(criteria[:to])
  criteria[:from] = _try_parse_time(criteria[:from])
  @client.invoke("Log/getRecordList", app_deployment_uri, parameters: criteria)
end