Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Filebeat] Data loss when JSON decoding fails #6516

Closed
andrewkroh opened this issue Mar 8, 2018 · 2 comments · Fixed by #6591
Closed

[Filebeat] Data loss when JSON decoding fails #6516

andrewkroh opened this issue Mar 8, 2018 · 2 comments · Fixed by #6591
Labels

Comments

@andrewkroh
Copy link
Member

When JSON decoding fails Filebeat should include the raw data in the message field.

filebeat.prospectors:
- paths:
  - input.json
  json.keys_under_root: true
  json.add_error_key: true

output.console.enabled: true

input.json

Hello world!
{bad: json}
{"hello": "world"}
ata": {
    "beat": "filebeat",
    "type": "doc",
    "version": "6.2.2"
  },
  "source": "/Users/akroh/Downloads/filebeat-6.2.2-darwin-x86_64/input.json",
  "offset": 13,
  "error": {
    "message": "Error decoding JSON: invalid character 'H' looking for beginning of value",
    "type": "json"
  },
  "beat": {
    "name": "macbook",
    "hostname": "macbook",
    "version": "6.2.2"
  }
}
{
  "@timestamp": "2018-03-08T21:52:43.891Z",
  "@metadata": {
    "beat": "filebeat",
    "type": "doc",
    "version": "6.2.2"
  },
  "source": "/Users/akroh/Downloads/filebeat-6.2.2-darwin-x86_64/input.json",
  "offset": 25,
  "error": {
    "type": "json",
    "message": "Error decoding JSON: invalid character 'b' looking for beginning of object key string"
  },
  "beat": {
    "name": "macbook",
    "hostname": "macbook",
    "version": "6.2.2"
  }
}
{
  "@timestamp": "2018-03-08T21:52:43.891Z",
  "@metadata": {
    "beat": "filebeat",
    "type": "doc",
    "version": "6.2.2"
  },
  "offset": 44,
  "hello": "world",
  "source": "/Users/akroh/Downloads/filebeat-6.2.2-darwin-x86_64/input.json",
  "beat": {
    "name": "macbook",
    "hostname": "macbook",
    "version": "6.2.2"
  }
}
@crazyvikas23
Copy link
Contributor

#6591 This should solve it. But i think if json.add_error_key is set to false, data would be lost any way. So we should add another key for raw data.

andrewkroh pushed a commit that referenced this issue Apr 16, 2018
Add raw json to `message` field when JSON unmarshaling fails. This ensures that no data loss occurs.

Fixes #6516
@andrewkroh
Copy link
Member Author

Fixed by #6591.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants