User Tools

Site Tools


core:loggingservice

Logging service

The service permits to store and search a log. A log is composed from a set of optional values (text message, a duration of an operation) plus some metainformation (application Id, session Id, datetime of operation).

REST API

Push log message

Save a log message on the service

Permission

No permission needed

Parameters

  • appId (path variable) : application identifier [mandatory | STRING].
  • msg (JSON request body element) : log message [optional | STRING]. If not specified, the value of type is taken.
  • appId (JSON request body) : application identifier [optional | STRING].

Value is set always override by appId path variable.

  • type (JSON request body): type of log message [mandatory | STRING]. Specific to the logging component or application.
  • duration (JSON request body) : duration of application operation [optional | DOUBLE].
  • session (JSON request body): identifier of application session [optional | STRING].
  • timestamp (JSON request body): timestamp of operation [optional | NUMBER].

Value is setted to current if field is missing.

  • custom_attr (JSON request body): map of key/value representing custom attribute to current log message. Accepted values can be numbers or strings.

Request

POST /welive.logging/log/{appId}
Host: dev.smartcommunitylab.it
Content-type: application/json

{

    "msg":"logging test",
    "appId":"9001",
    "type":"AppCustom",
    "duration":0.1,
    "session":"avbfsr3k4",
    "timestamp":34839043490890482390
    "custom_attr": {"rating":1.2, "deviceId":"aaacckfkk334"}
}

Response

  • HTTP 200 if call gone ok
  • HTTP 500 if something gone wrong

Query

Returns the paginate list of result matching query criteria.

Permission

No permission needed

Parameters

  • appId (path variable) : application identifier [mandatory | STRING].
  • from (query param) : Timerange start. Express it in millis [optional | INTEGER]
  • to (query param) : Timerange end. Express it in millis [optional | INTEGER]
  • type (query param) : log type to search [optional | STRING]
  • pattern (query param) : search criteria on custom fields using Lucene syntax [optional | STRING]. Put in logical AND clause with msgPattern if present.
  • msgPattern (query param): search the pattern in log text [optional | STRING]. Put in logical AND clause with pattern if present.
  • limit (query param) : maximum number of messages to return [optional | INTEGER]. Default value is 150
  • offset (query param) : index of first message to return [optional | INTEGER]. Default value is 0

Request

GET /welive.logging/log/{appId}
Host: dev.smartcommunitylab.it
Accept: application/json

Response

{
  "offset": 0,
  "limit": 150,
  "data": [
    {
      "appId": "wer123",
      "type": "AppStart",
      "msg": "appstart logging",
      "timestamp": 1444732794782,
      "custom_attr":{}
    },
    {
      "appId": "wer123",
      "type": "AppCustom",
      "msg": "log with invalid type",
      "timestamp": 1444732732318,
      "custom_attr":{}
    }
  ],
  "total_results": 2
}

Count Query

Returns the number of result matching the query criteria

Permission

No permission needed

Parameters

  • appId (path variable) : application identifier [mandatory | STRING].
  • from (query param) : Timerange start. Express it in millis [optional | INTEGER]
  • to (query param) : Timerange end. Express it in millis [optional | INTEGER]
  • type (query param) : log type to search [optional | STRING]
  • pattern (query param) : search criteria on custom fields using Lucene syntax [optional | STRING]. Put in logical AND clause with msgPattern if present.
  • msgPattern (query param): search the pattern in log text [optional | STRING]. Put in logical AND clause with pattern if present.
  • limit (query param) : maximum number of messages to return [optional | INTEGER]. Default value is 150
  • offset (query param) : index of first message to return [optional | INTEGER]. Default value is 0

Request

GET /welive.logging/log/count/{appId}
Host: dev.smartcommunitylab.it
Accept: application/json

Response

{
  "total_results": 2
}

Log Aggregate

Permission

No permission needed

Parameters

  • request (JSON request body) : An elasticsearch search query [mandatory | STRING].

Request

POST /welive.logging/log/aggregate
Host: dev.smartcommunitylab.it
Content-type: application/json

{
    "_source" : false,
    "size" : 0,
    "aggs" : {
        "agg1" : {
            "sampler" : { 
                "field" : "message"
            } 
            
        }         
    }
    
}

Response

{
  "took": 14,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1564,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "agg1": {
      "doc_count": 0
    }
  }
}
core/loggingservice.txt · Last modified: 09/03/2016 10:59 by Raman