Skip to main content

Logs

Status: EARLY Draft/Proposal

LogLines

Version: 0.0

Properties and field requirements

  • Time field - required
    • The first time field with the name timestamp is the time field.
    • it must be non nullable
  • Body field - required
    • The first string field with the name body is the body field.
    • it must be non nullable
  • Severity field - optional
    • The first string field with the name severity is the severity field.
    • Represents the severity/level of the log line
    • If no severity field is found, consumers/client will decide the log level. Example: logs panel will try to parse the message field and determine the log level
    • Log level can be one of the values specified in the docs here
  • ID field - optional
    • The first string field with the name id is the id field.
    • Unique identifier of the log line
  • Labels field - optional
    • The first field with the name labels is the labels field.
    • This field represents additional information about the log line.
    • Field type must be json raw message type. Example value: {}, {"hello":"world", "foo": 123.45, "bar" :["yellow","red"], "baz" : { "name": "alice" }}
      • Value should be represented with Record<string,any> type in javascript.

Any other field is ignored by logs visualisation.

Example

Following is an example of a logs frame in go

data.NewFrame(
"logs",
data.NewField("timestamp", nil, []time.Time{time.UnixMilli(1645030244810), time.UnixMilli(1645030247027), time.UnixMilli(1645030247027)}),
data.NewField("body", nil, []string{"message one", "message two", "message three"}),
data.NewField("severity", nil, []string{"critical", "error", "warning"}),
data.NewField("id", nil, []string{"xxx-001", "xyz-002", "111-003"}),
data.NewField("labels", nil, []json.RawMessage{[]byte(`{}`), []byte(`{"hello":"world"}`), []byte(`{"hello":"world", "foo": 123.45, "bar" :["yellow","red"], "baz" : { "name": "alice" }}`)}),
)

the same can be represented as

Name: timestamp
Type: []time.Time
Name: body
Type: []string
Name: severity
Type: []*string
Name: id
Type: []*string
Name: labels
Type: []json.RawMessage
2022-02-16 16:50:44.810 +0000 GMTmessage onecriticalxxx-001{}
2022-02-16 16:50:47.027 +0000 GMTmessage twoerrorxyz-002{"hello":"world"}
2022-02-16 16:50:47.027 +0000 GMTmessage threewarning111-003{"hello":"world", "foo": 123.45, "bar" :["yellow","red"], "baz" : { "name": "alice" }}

Meta data requirements

  • Frame type must be set to FrameTypeLogLines/log-lines
  • Frame meta can optionally specify preferredVisualisationType:logs as meta data. Without this property, explore page will be rendering the logs data as table instead in logs view

Invalid cases

  • Frame without time field
  • Frame without string field
  • Frame with field name "tsNs" where the type of the "tsNs" field is not number.