graylog2-server icon indicating copy to clipboard operation
graylog2-server copied to clipboard

Improve GELF spec documentation by adding JSON schema

Open mikkolehtisalo opened this issue 1 year ago • 0 comments

The GELF specification documentation probably should include JSON Schema now that they are becoming more commonly used. It would be useful especially for developers of custom logging for automated testing in CI/CD pipelines.

Here's a basic reference schema for GELF 1.1:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://graylog.com/graylog.gelf.11.json",
  "title": "Graylog Extended Log Format",
  "description": "The Graylog Extended Log Format (GELF) is a log format that avoids the shortcomings of classic plain syslog",
  "type": "object",
  "properties": {
    "version": {
      "description": "GELF spec version",
      "const": "1.1"
    },
    "host": {
      "description": "The name of the host, source or application that sent this message",
      "type": "string"
    },
    "short_message": {
      "description": "A short, descriptive message",
      "type": "string"
    },
    "full_message": {
      "description": "A long message that can contain a backtrace",
      "type": "string"
    },
    "timestamp": {
      "description": "Seconds since UNIX epoch with optional decimal places for millisecond",
      "type": "number"
    },
    "level": {
      "description": "The level equal to the standard syslog levels",
      "type": "number"
    },
    "facility": {
      "description": "Deprecated, send as additional field instead",
      "type": "string"
    },
    "line": {
      "description": "Deprecated, the line in a file that caused the error, send as additional field instead",
      "type": "string"
    },
    "file": {
      "description": "Depreated, the file that caused the error, send as additional field instead"
    }
  },
  "required": [
    "version",
    "host",
    "short_message"
  ],
  "patternProperties": {
    "^_[\\w\\.\\-]*$": {
      "description": "Every field you send and prefix with an underscore (_) will be treated as an additional field",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        }
      ]
    },
    "^_id$": {
      "description": "Additional field _id is reserved for Graylog internal use",
      "not": {}
    }
  },
  "additionalProperties": false
}

mikkolehtisalo avatar Jun 09 '24 11:06 mikkolehtisalo