Logstash un-gzip array log configuration
everyone!
I have logstash config, which forwards logs from RabbitMQ to elasticSearch. Something like this:
input {
rabbitmq {
...
}
}
filter {
if [type] == "rabbitmq" {
json {
source => "message"
target => "message"
}
}
}
output {
elasticsearch {
hosts => ["${ES_HOST}"]
user => "${ES_USERNAME}"
password => "${ES_PASSWORD}"
sniffing => false
index => "kit_events-%{[message][elasticsearch][index]}"
}
}
And we were forced to compress logs on a fly, because they are spending too much traffic.
Logs were moved into array and gzipped.
What is the correct way of configuring un-gzipping and splitting array back into objects?
I did some research and found out that there is gzip_lines plugin and something on Ruby(?) to parse array, but I failed to implement it. Did anyone make something like this before?
UPD:
Added this filter
filter {
if [type] == "kitlog-rabbitmq" {
ruby {
init => "
require 'zlib'
require 'stringio'
"
code => "
body = event.get('[http][response][body]').to_s
sio = StringIO.new(body)
gz = Zlib::GzipReader.new(sio)
result = gz.read.to_s
event.set('[http][response][body]', result)
"
}
}
}
And now catching an error
ERROR][logstash.filters.ruby ] Ruby exception occurred: not in gzip format
[DEBUG][logstash.pipeline ] output received {"event"=>{"@timestamp"=>2018-11-30T09:16:19.127Z, "tags"=>["_rubyexception"], "@version"=>"1", "message"=>"x^\x8B\xAEV*\xCE\xCE\xCC\xC9)V\xB2R\x88V\xD26T07\xB7\xB0\xB4\xB44000W\x8A\xD5QPJ\xCE\xCF+IL.\u0001\xCA*)\u0001\xB9\xA9\xB9\x89\x999 N\x96C\x96^r~.X,\xA5\u0014(R\xADT\x9A\u000E6#\xA0\xB2$#?\u000F\xAC\xB9\u0000\"\xE2\u001C\xAC\u0014[\v\xE4\xE6%概\xF4z\u0001\xE9b%\xA0\xC8\xC0\xD9\u001D\v\u0000\u0003\x9ADk", "type"=>"kitlog-rabbitmq"}}
Was trying different gzipping methods, but result is still the same. Also tried changing input codecs (plain - utf-8, plain - binary)
elasticsearch logstash logstash-configuration
add a comment |
everyone!
I have logstash config, which forwards logs from RabbitMQ to elasticSearch. Something like this:
input {
rabbitmq {
...
}
}
filter {
if [type] == "rabbitmq" {
json {
source => "message"
target => "message"
}
}
}
output {
elasticsearch {
hosts => ["${ES_HOST}"]
user => "${ES_USERNAME}"
password => "${ES_PASSWORD}"
sniffing => false
index => "kit_events-%{[message][elasticsearch][index]}"
}
}
And we were forced to compress logs on a fly, because they are spending too much traffic.
Logs were moved into array and gzipped.
What is the correct way of configuring un-gzipping and splitting array back into objects?
I did some research and found out that there is gzip_lines plugin and something on Ruby(?) to parse array, but I failed to implement it. Did anyone make something like this before?
UPD:
Added this filter
filter {
if [type] == "kitlog-rabbitmq" {
ruby {
init => "
require 'zlib'
require 'stringio'
"
code => "
body = event.get('[http][response][body]').to_s
sio = StringIO.new(body)
gz = Zlib::GzipReader.new(sio)
result = gz.read.to_s
event.set('[http][response][body]', result)
"
}
}
}
And now catching an error
ERROR][logstash.filters.ruby ] Ruby exception occurred: not in gzip format
[DEBUG][logstash.pipeline ] output received {"event"=>{"@timestamp"=>2018-11-30T09:16:19.127Z, "tags"=>["_rubyexception"], "@version"=>"1", "message"=>"x^\x8B\xAEV*\xCE\xCE\xCC\xC9)V\xB2R\x88V\xD26T07\xB7\xB0\xB4\xB44000W\x8A\xD5QPJ\xCE\xCF+IL.\u0001\xCA*)\u0001\xB9\xA9\xB9\x89\x999 N\x96C\x96^r~.X,\xA5\u0014(R\xADT\x9A\u000E6#\xA0\xB2$#?\u000F\xAC\xB9\u0000\"\xE2\u001C\xAC\u0014[\v\xE4\xE6%概\xF4z\u0001\xE9b%\xA0\xC8\xC0\xD9\u001D\v\u0000\u0003\x9ADk", "type"=>"kitlog-rabbitmq"}}
Was trying different gzipping methods, but result is still the same. Also tried changing input codecs (plain - utf-8, plain - binary)
elasticsearch logstash logstash-configuration
add a comment |
everyone!
I have logstash config, which forwards logs from RabbitMQ to elasticSearch. Something like this:
input {
rabbitmq {
...
}
}
filter {
if [type] == "rabbitmq" {
json {
source => "message"
target => "message"
}
}
}
output {
elasticsearch {
hosts => ["${ES_HOST}"]
user => "${ES_USERNAME}"
password => "${ES_PASSWORD}"
sniffing => false
index => "kit_events-%{[message][elasticsearch][index]}"
}
}
And we were forced to compress logs on a fly, because they are spending too much traffic.
Logs were moved into array and gzipped.
What is the correct way of configuring un-gzipping and splitting array back into objects?
I did some research and found out that there is gzip_lines plugin and something on Ruby(?) to parse array, but I failed to implement it. Did anyone make something like this before?
UPD:
Added this filter
filter {
if [type] == "kitlog-rabbitmq" {
ruby {
init => "
require 'zlib'
require 'stringio'
"
code => "
body = event.get('[http][response][body]').to_s
sio = StringIO.new(body)
gz = Zlib::GzipReader.new(sio)
result = gz.read.to_s
event.set('[http][response][body]', result)
"
}
}
}
And now catching an error
ERROR][logstash.filters.ruby ] Ruby exception occurred: not in gzip format
[DEBUG][logstash.pipeline ] output received {"event"=>{"@timestamp"=>2018-11-30T09:16:19.127Z, "tags"=>["_rubyexception"], "@version"=>"1", "message"=>"x^\x8B\xAEV*\xCE\xCE\xCC\xC9)V\xB2R\x88V\xD26T07\xB7\xB0\xB4\xB44000W\x8A\xD5QPJ\xCE\xCF+IL.\u0001\xCA*)\u0001\xB9\xA9\xB9\x89\x999 N\x96C\x96^r~.X,\xA5\u0014(R\xADT\x9A\u000E6#\xA0\xB2$#?\u000F\xAC\xB9\u0000\"\xE2\u001C\xAC\u0014[\v\xE4\xE6%概\xF4z\u0001\xE9b%\xA0\xC8\xC0\xD9\u001D\v\u0000\u0003\x9ADk", "type"=>"kitlog-rabbitmq"}}
Was trying different gzipping methods, but result is still the same. Also tried changing input codecs (plain - utf-8, plain - binary)
elasticsearch logstash logstash-configuration
everyone!
I have logstash config, which forwards logs from RabbitMQ to elasticSearch. Something like this:
input {
rabbitmq {
...
}
}
filter {
if [type] == "rabbitmq" {
json {
source => "message"
target => "message"
}
}
}
output {
elasticsearch {
hosts => ["${ES_HOST}"]
user => "${ES_USERNAME}"
password => "${ES_PASSWORD}"
sniffing => false
index => "kit_events-%{[message][elasticsearch][index]}"
}
}
And we were forced to compress logs on a fly, because they are spending too much traffic.
Logs were moved into array and gzipped.
What is the correct way of configuring un-gzipping and splitting array back into objects?
I did some research and found out that there is gzip_lines plugin and something on Ruby(?) to parse array, but I failed to implement it. Did anyone make something like this before?
UPD:
Added this filter
filter {
if [type] == "kitlog-rabbitmq" {
ruby {
init => "
require 'zlib'
require 'stringio'
"
code => "
body = event.get('[http][response][body]').to_s
sio = StringIO.new(body)
gz = Zlib::GzipReader.new(sio)
result = gz.read.to_s
event.set('[http][response][body]', result)
"
}
}
}
And now catching an error
ERROR][logstash.filters.ruby ] Ruby exception occurred: not in gzip format
[DEBUG][logstash.pipeline ] output received {"event"=>{"@timestamp"=>2018-11-30T09:16:19.127Z, "tags"=>["_rubyexception"], "@version"=>"1", "message"=>"x^\x8B\xAEV*\xCE\xCE\xCC\xC9)V\xB2R\x88V\xD26T07\xB7\xB0\xB4\xB44000W\x8A\xD5QPJ\xCE\xCF+IL.\u0001\xCA*)\u0001\xB9\xA9\xB9\x89\x999 N\x96C\x96^r~.X,\xA5\u0014(R\xADT\x9A\u000E6#\xA0\xB2$#?\u000F\xAC\xB9\u0000\"\xE2\u001C\xAC\u0014[\v\xE4\xE6%概\xF4z\u0001\xE9b%\xA0\xC8\xC0\xD9\u001D\v\u0000\u0003\x9ADk", "type"=>"kitlog-rabbitmq"}}
Was trying different gzipping methods, but result is still the same. Also tried changing input codecs (plain - utf-8, plain - binary)
elasticsearch logstash logstash-configuration
elasticsearch logstash logstash-configuration
edited Nov 30 '18 at 10:41
ikebastuz
asked Nov 22 '18 at 16:17
ikebastuzikebastuz
466
466
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
So the content in rabbitmq is gzipped?
In the best of all possible worlds, logstash would see the content-encoding
header and unzip it for you, but the plugin doesn't seem to do anything with that knowledge. You might request the feature.
The plugin does let you access the header, so you could do the gzip yourself. Something like this:
filter {
if [@metadata][rabbitmq_properties][content-encoding] == "gzip" {
ruby {
...
}
}
}
Examples of unzipping a string with ruby exist elsewhere. Hopefully the 'zip' gem is available in logstash.
Thank you, I will give it a try!
– ikebastuz
Nov 28 '18 at 10:06
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434887%2flogstash-un-gzip-array-log-configuration%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
So the content in rabbitmq is gzipped?
In the best of all possible worlds, logstash would see the content-encoding
header and unzip it for you, but the plugin doesn't seem to do anything with that knowledge. You might request the feature.
The plugin does let you access the header, so you could do the gzip yourself. Something like this:
filter {
if [@metadata][rabbitmq_properties][content-encoding] == "gzip" {
ruby {
...
}
}
}
Examples of unzipping a string with ruby exist elsewhere. Hopefully the 'zip' gem is available in logstash.
Thank you, I will give it a try!
– ikebastuz
Nov 28 '18 at 10:06
add a comment |
So the content in rabbitmq is gzipped?
In the best of all possible worlds, logstash would see the content-encoding
header and unzip it for you, but the plugin doesn't seem to do anything with that knowledge. You might request the feature.
The plugin does let you access the header, so you could do the gzip yourself. Something like this:
filter {
if [@metadata][rabbitmq_properties][content-encoding] == "gzip" {
ruby {
...
}
}
}
Examples of unzipping a string with ruby exist elsewhere. Hopefully the 'zip' gem is available in logstash.
Thank you, I will give it a try!
– ikebastuz
Nov 28 '18 at 10:06
add a comment |
So the content in rabbitmq is gzipped?
In the best of all possible worlds, logstash would see the content-encoding
header and unzip it for you, but the plugin doesn't seem to do anything with that knowledge. You might request the feature.
The plugin does let you access the header, so you could do the gzip yourself. Something like this:
filter {
if [@metadata][rabbitmq_properties][content-encoding] == "gzip" {
ruby {
...
}
}
}
Examples of unzipping a string with ruby exist elsewhere. Hopefully the 'zip' gem is available in logstash.
So the content in rabbitmq is gzipped?
In the best of all possible worlds, logstash would see the content-encoding
header and unzip it for you, but the plugin doesn't seem to do anything with that knowledge. You might request the feature.
The plugin does let you access the header, so you could do the gzip yourself. Something like this:
filter {
if [@metadata][rabbitmq_properties][content-encoding] == "gzip" {
ruby {
...
}
}
}
Examples of unzipping a string with ruby exist elsewhere. Hopefully the 'zip' gem is available in logstash.
answered Nov 27 '18 at 19:37
Alain CollinsAlain Collins
13.7k12248
13.7k12248
Thank you, I will give it a try!
– ikebastuz
Nov 28 '18 at 10:06
add a comment |
Thank you, I will give it a try!
– ikebastuz
Nov 28 '18 at 10:06
Thank you, I will give it a try!
– ikebastuz
Nov 28 '18 at 10:06
Thank you, I will give it a try!
– ikebastuz
Nov 28 '18 at 10:06
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434887%2flogstash-un-gzip-array-log-configuration%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown