mozilla

JSON DecoderΒΆ

New in version 0.10.

Plugin Name: SandboxDecoder
File Name: lua_decoders/json.lua

Parses a payload containing JSON.

Config:

  • type (string, optional, default “json”):

    Sets the message ‘Type’ header to the specified value, will be overridden if Type config option is specified.

  • payload_keep (bool, optional, default false)

    Whether to preserve the original log line in the message payload.

  • map_fields (bool, optional, default false)

    Enables mapping of json fields to heka message fields.

  • Payload (string, optional, default nil)

    String specifying json field to map to message Payload, expects field value to be a string. Overrides the keep_payload config option.

  • Uuid (string, optional, default nil)

    String specifying json field to map to message Uuid, expects field value to be a string.

  • Type (string, optional, default nil)

    String specifying json field to map to to message Type, expects field value to be a string. Overrides the type config option

  • Logger (string, optional, default nil)

    String specifying json field to map to message Logger, expects field value to be a string.

  • Hostname (string, optional, default nil)

    String specifying json field to map to message Hostname, expects field value to be a string.

  • Severity (string, optional, default nil)

    String specifying json field to map to message Severity, expects field value to be numeric.

  • EnvVersion (string, optional, default nil)

    String specifying json field to map to message EnvVersion, expects field value to be numeric.

  • Pid (string, optional, default nil)

    String specifying json field to map to message Pid, expects field value to be numeric

  • Timestamp (string, optional, default nil)

    String specifying json field to map to message Timestamp, if field value not in ns-since-epoch format, provide the timestamp_format config option.

  • timestamp_format (string, optional, default nil)

    String specifying the format used to parse extracted JSON values for the Timestamp fields, in standard strftime format. If left blank, timestamp values will be assumed to be in nanoseconds-since-epoch.

timestamp in strftime format.

{
  "msg": "Start Request",
  "event": "artemis.web.ensure-running",
  "extra": {
    "workspace-id": "cN907xLngi"
  },
  "time": "2015-05-06T20:40:05.509926234Z",
  "severity": 1
}

Example Heka Configuration

[ArtemisLogInput]
type = "LogstreamerInput"
log_directory = "/srv/artemis/current/logs"
file_match = 'artemis\.log'
decoder = "JsonDecoder"

[JsonDecoder]
type = "SandboxDecoder"
filename = "lua_decoders/json.lua"

    [JsonDecoder.config]
    type = "artemis"
    payload_keep = true
    map_fields = true
    Severity = "severity"

Example Heka Message

Timestamp:2015-05-06 20:40:05 -0800 PST
Type:artemis
Hostname:test.example.com
Pid:0
UUID:8e414f01-9d7f-4a48-a5e1-ae92e5954df5
Payload:
EnvVersion:
Severity:1
Fields:
name:”msg” value_type:STRING value_string:”Start Request”
name:”event” value_type:STRING value_string:”artemis.web.ensure-running”
name:”extra.workspace-id” value_type:STRING value_string:”cN907xLngi”
name:”time” value_type:STRING value_string:”2015-05-06T20:40:05.509926234Z”