logstash-output-scalyr 0.1.24.beta → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/Gemfile +4 -0
  4. data/README.md +112 -4
  5. data/lib/logstash/outputs/scalyr.rb +115 -31
  6. data/lib/scalyr/common/client.rb +2 -1
  7. data/lib/scalyr/common/util.rb +28 -1
  8. data/lib/scalyr/constants.rb +4 -1
  9. data/logstash-output-scalyr.gemspec +3 -2
  10. data/spec/benchmarks/bignum_fixing.rb +2 -5
  11. data/spec/benchmarks/flattening_and_serialization.rb +2 -27
  12. data/spec/benchmarks/json_serialization.rb +85 -0
  13. data/spec/benchmarks/set_session_level_serverhost_on_events.rb +107 -0
  14. data/spec/benchmarks/util.rb +24 -0
  15. data/spec/logstash/outputs/scalyr_integration_spec.rb +12 -7
  16. data/spec/logstash/outputs/scalyr_spec.rb +434 -14
  17. data/spec/scalyr/common/util_spec.rb +4 -0
  18. data/vendor/bundle/jruby/2.5.0/cache/jrjackson-0.4.14-java.gem +0 -0
  19. data/vendor/bundle/jruby/2.5.0/cache/json-1.8.6-java.gem +0 -0
  20. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/Gemfile +0 -0
  21. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/Mavenfile +1 -7
  22. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/README.md +0 -0
  23. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/Rakefile +8 -2
  24. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/alt_bench.rb +0 -0
  25. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/changelog.md +25 -2
  26. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/jrjackson.gemspec +2 -1
  27. data/vendor/bundle/jruby/2.5.0/gems/jrjackson-0.4.14-java/lib/com/fasterxml/jackson/core/jackson-annotations/2.9.10/jackson-annotations-2.9.10.jar +0 -0
  28. data/vendor/bundle/jruby/2.5.0/gems/jrjackson-0.4.14-java/lib/com/fasterxml/jackson/core/jackson-core/2.9.10/jackson-core-2.9.10.jar +0 -0
  29. data/vendor/bundle/jruby/2.5.0/gems/jrjackson-0.4.14-java/lib/com/fasterxml/jackson/core/jackson-databind/2.9.10.8/jackson-databind-2.9.10.8.jar +0 -0
  30. data/vendor/bundle/jruby/2.5.0/gems/jrjackson-0.4.14-java/lib/com/fasterxml/jackson/module/jackson-module-afterburner/2.9.10/jackson-module-afterburner-2.9.10.jar +0 -0
  31. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/lib/jrjackson/build_info.rb +9 -5
  32. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java/lib/jrjackson/jars/jrjackson-1.2.26.jar → jrjackson-0.4.14-java/lib/jrjackson/jars/jrjackson-1.2.32.jar} +0 -0
  33. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/lib/jrjackson/jrjackson.rb +0 -0
  34. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/lib/jrjackson.rb +0 -0
  35. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/lib/jrjackson_jars.rb +8 -8
  36. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/lib/require_relative_patch.rb +0 -0
  37. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/pom.xml +8 -25
  38. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/profiling/profiled.rb +0 -0
  39. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/run_all_individual_bench.sh +0 -0
  40. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/run_jruby_individual_bench.sh +0 -0
  41. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/run_mri_individual_bench.sh +0 -0
  42. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/IParseHandler.java +0 -0
  43. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JavaBigDecimalValueConverter.java +0 -0
  44. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JavaBigIntValueConverter.java +0 -0
  45. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JavaConverter.java +0 -0
  46. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JavaFloatValueConverter.java +0 -0
  47. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JavaHandler.java +0 -0
  48. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JavaLongValueConverter.java +0 -0
  49. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JjParse.java +0 -0
  50. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JrJacksonBase.java +0 -0
  51. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JrJacksonJava.java +0 -0
  52. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JrJacksonRaw.java +0 -0
  53. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JrJacksonRuby.java +0 -0
  54. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JrJacksonSaj.java +0 -0
  55. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JrJacksonSch.java +0 -0
  56. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JrJacksonService.java +0 -0
  57. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/JrParse.java +0 -0
  58. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/ParseError.java +0 -0
  59. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyAnySerializer.java +4 -4
  60. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyBigDecimalValueConverter.java +0 -0
  61. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyBigIntValueConverter.java +0 -0
  62. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyConverter.java +0 -0
  63. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyDateFormat.java +0 -0
  64. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyFloatValueConverter.java +0 -0
  65. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyHandler.java +0 -0
  66. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyIntValueConverter.java +0 -0
  67. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyJacksonModule.java +18 -6
  68. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyKeyConverter.java +0 -0
  69. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyNameConverter.java +0 -0
  70. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyObjectDeserializer.java +0 -0
  71. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyStringConverter.java +0 -0
  72. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyStringKeyConverter.java +0 -0
  73. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyStringNameConverter.java +0 -0
  74. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubySymbolKeyConverter.java +0 -0
  75. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubySymbolNameConverter.java +0 -0
  76. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/RubyUtils.java +0 -0
  77. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/SajParse.java +0 -0
  78. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/SchParse.java +0 -0
  79. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/main/java/com/jrjackson/StreamParse.java +0 -0
  80. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/src/test/java/com/jrjackson/RubyAnySerializerTest.java +0 -0
  81. data/vendor/bundle/jruby/2.5.0/gems/{jrjackson-0.4.8-java → jrjackson-0.4.14-java}/test/jrjackson_test.rb +15 -0
  82. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/bigdecimal.rb +28 -0
  83. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/complex.rb +28 -0
  84. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/core.rb +11 -0
  85. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/date.rb +34 -0
  86. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/date_time.rb +50 -0
  87. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/exception.rb +31 -0
  88. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/ostruct.rb +31 -0
  89. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/range.rb +29 -0
  90. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/rational.rb +27 -0
  91. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/regexp.rb +30 -0
  92. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/struct.rb +30 -0
  93. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/symbol.rb +25 -0
  94. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/add/time.rb +38 -0
  95. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/common.rb +484 -0
  96. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/ext/generator.jar +0 -0
  97. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/ext/parser.jar +0 -0
  98. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/ext.rb +21 -0
  99. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/generic_object.rb +70 -0
  100. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/pure/generator.rb +530 -0
  101. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/pure/parser.rb +359 -0
  102. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/pure.rb +21 -0
  103. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json/version.rb +8 -0
  104. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/lib/json.rb +62 -0
  105. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail1.json +1 -0
  106. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail10.json +1 -0
  107. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail11.json +1 -0
  108. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail12.json +1 -0
  109. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail13.json +1 -0
  110. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail14.json +1 -0
  111. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail18.json +1 -0
  112. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail19.json +1 -0
  113. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail2.json +1 -0
  114. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail20.json +1 -0
  115. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail21.json +1 -0
  116. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail22.json +1 -0
  117. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail23.json +1 -0
  118. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail24.json +1 -0
  119. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail25.json +1 -0
  120. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail27.json +2 -0
  121. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail28.json +2 -0
  122. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail3.json +1 -0
  123. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail4.json +1 -0
  124. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail5.json +1 -0
  125. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail6.json +1 -0
  126. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail7.json +1 -0
  127. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail8.json +1 -0
  128. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/fail9.json +1 -0
  129. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/pass1.json +56 -0
  130. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/pass15.json +1 -0
  131. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/pass16.json +1 -0
  132. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/pass17.json +1 -0
  133. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/pass2.json +1 -0
  134. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/pass26.json +1 -0
  135. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/fixtures/pass3.json +6 -0
  136. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/setup_variant.rb +11 -0
  137. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/test_json.rb +519 -0
  138. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/test_json_addition.rb +196 -0
  139. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/test_json_encoding.rb +65 -0
  140. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/test_json_fixtures.rb +35 -0
  141. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/test_json_generate.rb +348 -0
  142. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/test_json_generic_object.rb +75 -0
  143. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/test_json_string_matching.rb +39 -0
  144. data/vendor/bundle/jruby/2.5.0/gems/json-1.8.6-java/tests/test_json_unicode.rb +72 -0
  145. data/vendor/bundle/jruby/2.5.0/specifications/{jrjackson-0.4.8-java.gemspec → jrjackson-0.4.14-java.gemspec} +7 -7
  146. data/vendor/bundle/jruby/2.5.0/specifications/json-1.8.6-java.gemspec +37 -0
  147. metadata +167 -68
  148. data/vendor/bundle/jruby/2.5.0/cache/jrjackson-0.4.8-java.gem +0 -0
  149. data/vendor/bundle/jruby/2.5.0/gems/jrjackson-0.4.8-java/lib/com/fasterxml/jackson/core/jackson-annotations/2.9.7/jackson-annotations-2.9.7.jar +0 -0
  150. data/vendor/bundle/jruby/2.5.0/gems/jrjackson-0.4.8-java/lib/com/fasterxml/jackson/core/jackson-core/2.9.7/jackson-core-2.9.7.jar +0 -0
  151. data/vendor/bundle/jruby/2.5.0/gems/jrjackson-0.4.8-java/lib/com/fasterxml/jackson/core/jackson-databind/2.9.7/jackson-databind-2.9.7.jar +0 -0
  152. data/vendor/bundle/jruby/2.5.0/gems/jrjackson-0.4.8-java/lib/com/fasterxml/jackson/module/jackson-module-afterburner/2.9.7/jackson-module-afterburner-2.9.7.jar +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 312d501ddc98f27b8d2be32bb20cb29439e7ce096d5f12870ef1b1bf095c32ee
4
- data.tar.gz: c0f6c4a51f42acef8266ee30480fc00a19e59098d7b957deddcc017bade71695
3
+ metadata.gz: 17884743262e123a7719335dd18559236505f4bfbf50ff8b2e2ca24e9416c35f
4
+ data.tar.gz: 34db0e1f15cc4f9a207fb5a681a5f4d6a1337f1187e01dc6a0f9467440ab53d0
5
5
  SHA512:
6
- metadata.gz: 2628a0bcfbe9a13dfc5bb9fd93360ef7629fca158cc325184817b4f15492ff5fcb28c03ca992c08dbbf9dc7953d2715b071b5d94f67912c36f66625f7bcf3234
7
- data.tar.gz: 1d009fe06794e8f2d15737da874609600e57569fe3d6be0297fb23a1ab99d375f3ac2e9bdbf52b653baa85222bc3d5da001ac8d68a3848c8099ed7eb1510175f
6
+ metadata.gz: c55678d99d117c2dd08fe48c4505b2da39a57553cf8cc36a84cab7aa38dbf539bb63b564772cf5a2e575c334b617bdb3b5b61d91af13c5cff0c4ea4c18738834
7
+ data.tar.gz: d8e819de557a452f4129bd94eb581ff40dbdd902a1eba07ef6e7ec838f72ee5dfdd266827100232f03f9269cd933329426846081dcfaf5b3e66084075b79989c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Beta
2
2
 
3
+ ## 0.2.0.beta, 0.2.0
4
+
5
+ - Fix a bug and correctly handle ``serverHost`` event level attribute. Now if an event contains
6
+ ``serverHost`` attribute, this attribute will be correctly set on the event level and available for
7
+ "Sources" filtering in the UI.
8
+ - Plugin doesn't set ``serverHost`` attribute with a fixed value of ``Logstash`` on each event
9
+ level anymore. If you still want this behavior, you can achieve that with logstash mutate filter.
10
+ - Session level ``serverHost`` value now defaults to logstash aggregator node hostname
11
+ (``use_hostname_for_serverhost`` config option now defaults to true).
12
+ - ``host`` attribute is not removed by default from all the events. By default, logstash adds
13
+ ``host`` attribute which contains logstash aggregator host to each event. This is now redundant
14
+ and unncessary with the fixed and improved serverHost behavior (host and serverHost would contain
15
+ the same value by default). If you want to change this behavior and and still include ``host``
16
+ attribute on each event you can do that by setting ``remove_host_attribute_from_events`` config
17
+ option to false.
18
+
19
+ ## 0.1.26.beta
20
+ - Add support for new ``json_library`` config option. Valid values are ``stdlib`` (default) are ``jrjackson``. The later may offer 2-4x faster JSON serialization.
21
+
3
22
  ## 0.1.23.beta
4
23
  - Add testing support for disabling estimation of serialized event size for each event in the batch.
5
24
 
data/Gemfile CHANGED
@@ -12,9 +12,13 @@ end
12
12
 
13
13
  group :test do
14
14
  gem "webmock"
15
+
16
+ # Require the specific version of `json` used in logstash while testing
17
+ gem 'json', '1.8.6'
15
18
  end
16
19
 
17
20
  gem 'pry'
18
21
  gem 'pry-nav'
19
22
  gem 'quantile', '~> 0.2.1'
20
23
  gem 'manticore', '~> 0.7.1', platform: :jruby
24
+ gem 'jrjackson', '~> 0.4.14', platform: :jruby
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
-
2
1
  [![CircleCI](https://circleci.com/gh/scalyr/logstash-output-scalyr.svg?style=svg)](https://circleci.com/gh/scalyr/logstash-output-scalyr)
3
2
 
4
- # [Scalyr output plugin for Logstash (Beta release)]
3
+ # [Scalyr output plugin for Logstash]
5
4
 
6
5
  This plugin implements a Logstash output plugin that uploads data to [Scalyr](http://www.scalyr.com).
7
6
 
@@ -10,7 +9,9 @@ You can view documentation for this plugin [on the Scalyr website](https://app.s
10
9
  # Quick start
11
10
 
12
11
  1. Build the gem, run `gem build logstash-output-scalyr.gemspec`
13
- 2. Install the gem into a Logstash installation, run `/usr/share/logstash/bin/logstash-plugin install logstash-output-scalyr-0.1.22.beta.gem` or follow the latest official instructions on working with plugins from Logstash.
12
+ 2. Install the gem into a Logstash installation, run `/usr/share/logstash/bin/logstash-plugin install logstash-output-scalyr-0.2.0.gem`
13
+ or follow the latest official instructions on working with plugins from Logstash. As an alternative, you can directly install latest
14
+ stable version from RubyGems - ``/usr/share/logstash/bin/logstash-plugin --version 0.2.0 logstash-output-scalyr``
14
15
  3. Configure the output plugin (e.g. add it to a pipeline .conf)
15
16
  4. Restart Logstash
16
17
 
@@ -40,6 +41,51 @@ output {
40
41
 
41
42
  In the above example, the Logstash pipeline defines a file input that reads from `/var/log/messages`. Log events from this source have the `host` and `path` fields. The pipeline then outputs to the scalyr plugin, which in this example is configured to remap `host`->`serverHost` and `path`->`logfile`, thus facilitating filtering in the Scalyr UI.
42
43
 
44
+ ## Notes on serverHost attribute handling
45
+
46
+ > Some of this functionality has been fixed and changed in the v0.2.0 release. In previous
47
+ versions, plugin added ``serverHost`` attribute with a value of ``Logstash`` to each event and
48
+ this attribute was not handled correctly - it was treated as a regular event level attribute
49
+ and not a special attribute which can be used for Source functionality and filtering.
50
+
51
+ By default this plugin will set ``serverHost`` for all the events in a batch to match hostname of
52
+ the logstash node where the output plugin is running.
53
+
54
+ You can change that either by setting ``serverHost`` attribute in the ``server_attributes`` config
55
+ option hash or by setting ``serverHost`` attribute on the event level via logstash record attribute.
56
+
57
+ In both scenarios, you will be able to utilize this value for "Sources" functionality and filterin
58
+ in the Scalyr UI.
59
+
60
+ For example:
61
+
62
+ 1. Define static value for all the events handled by specific plugin instance
63
+
64
+ ```
65
+ output {
66
+ scalyr {
67
+ api_write_token => 'SCALYR_API_KEY'
68
+ server_attributes => {'serverHost' => 'my-host-1'}
69
+ }
70
+ }
71
+ ```
72
+
73
+ 2. Define static value on the event level which is set via logstash filter
74
+
75
+ ```
76
+ mutate {
77
+ add_field => { "serverHost" => "my hostname" }
78
+ }
79
+ ```
80
+
81
+ 3. Define dynamic value on the event level which is set via logstash filter
82
+
83
+ ```
84
+ mutate {
85
+ add_field => { "serverHost" => "%{[host][name]}" }
86
+ }
87
+ ```
88
+
43
89
  ## Options
44
90
 
45
91
  - The Scalyr API write token, these are available at https://www.scalyr.com/keys. This is the only compulsory configuration field required for proper upload
@@ -72,7 +118,7 @@ In the above example, the Logstash pipeline defines a file input that reads from
72
118
  - Related to the server_attributes dictionary above, if you do not define the 'serverHost' key in server_attributes,
73
119
  the plugin will automatically set it, using the aggregator hostname as value, if this value is true.
74
120
 
75
- `config :use_hostname_for_serverhost, :validate => :boolean, :default => false`
121
+ `config :use_hostname_for_serverhost, :validate => :boolean, :default => true`
76
122
 
77
123
  ---
78
124
 
@@ -395,3 +441,65 @@ bundle exec rake publish_gem
395
441
 
396
442
  `RUBY_USER` and `RUBY_PASSWORD` should be replaced with the username and password to the RubyGems.org account you wish to release to,
397
443
  these credentials should be found in Keeper.
444
+
445
+ # Testing Plugin Changes
446
+
447
+ This section describes how to test the plugin and changes using docker compose setup from
448
+ lostash-config-tester repo available at https://github.com/Kami/logstash-config-tester.
449
+
450
+ This repo has been forked and already contains some changes which make testing the plugin
451
+ easier.
452
+
453
+ The logstash configuration in that repo is set up to receive records encoded as JSON via
454
+ standard input, decode the JSON into the event object and print it to stdout + send it
455
+ to the Scalyr output.
456
+
457
+ ```bash
458
+ # 0. Clone the tester repo
459
+ git clone https://github.com/Kami/logstash-config-tester ~/
460
+
461
+ # 1. Build the plugin
462
+ gem build logstash-output-scalyr.gemspec
463
+
464
+ # 2. Copy it to the config test repo
465
+ cp logstash-output-scalyr-0.2.0.gem ~/logstash-config-test/logstash-output-scalyr.gem
466
+
467
+ # 3. Build docker image with the latest dev version of the plugin (may take a while)
468
+ docker-compose build
469
+
470
+ # 4. Configure API key in docker-compose.yml and make any changes to plugin config in
471
+ # pipeline/scalyr_output.conf.j2, if necessary
472
+ vim docker-compose.yml
473
+
474
+ vim pipeline/scalyr_output.conf.j2
475
+
476
+ # 4. Run logstash with the stdin input and stdout + scalyr output
477
+ docker-compose run logstash
478
+ ```
479
+
480
+ A couple of things to keep in mind:
481
+
482
+ 1. Logstash log level is set to debug which is quite verbose, but it makes troubleshooting and
483
+ testing easier.
484
+ 2. Plugin accepts records (events) as JSON via standard input. This means to inject the mock
485
+ event you can simply copy the JSON event representation string to stdin and press enter. If you
486
+ want to submit multiples events to be handled as a single batch, paste each event one at a time
487
+ and press enter at the end. Logstash pipeline has been configured to wait up to 5 seconds before
488
+ handling the batch which should give you enough time to test batches with multiple events (this
489
+ setting can be adjusted in ``config/logstash.yml`` - ``pipeline.batch.delay``, if needed)
490
+
491
+ Example values you can enter into stdin:
492
+
493
+ 1. Single event batch
494
+
495
+ ```javascript
496
+ {"foo": "bar", "message": "test logstash"}
497
+ ```
498
+
499
+ 2. Batch with 3 events
500
+
501
+ ```javascript
502
+ {"serverHost": "host-1", "bar": "baz", "message": "test logstash 1"}
503
+ {"serverHost": "host-2", "bar": "baz", "message": "test logstash 2"}
504
+ {"bar": "baz", "message": "test logstash 3"}
505
+ ```
@@ -13,6 +13,7 @@ require 'rbzip2'
13
13
  require 'zlib'
14
14
  require 'stringio'
15
15
  require 'quantile'
16
+ require 'jrjackson'
16
17
 
17
18
  require 'scalyr/common/client'
18
19
  require "scalyr/common/util"
@@ -42,7 +43,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
42
43
 
43
44
  # Related to the server_attributes dictionary above, if you do not define the 'serverHost' key in server_attributes,
44
45
  # the plugin will automatically set it, using the aggregator hostname as value, if this value is true.
45
- config :use_hostname_for_serverhost, :validate => :boolean, :default => false
46
+ config :use_hostname_for_serverhost, :validate => :boolean, :default => true
46
47
 
47
48
  # Field that represents the origin of the log event.
48
49
  # (Warning: events with an existing 'serverHost' field, it will be overwritten)
@@ -65,6 +66,23 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
65
66
  # value with have fields moved.
66
67
  config :log_constants, :validate => :array, :default => nil
67
68
 
69
+ # When this option is true and session level server host is defined (either via
70
+ # server_attributes config option or via node hostname) and some events in a batch contain
71
+ # "serverHost" attributes, other nodes in a batch which don't contain it will have serverHost
72
+ # set to the session level value.
73
+ # This is needed because session level attribute has priority over event level which means
74
+ # that in case we specify serverHost on some events, other events won't have any value set
75
+ # for serverHost.
76
+ # Since this option adds some overhead and requires additional processing time, it's
77
+ # disabled by default.
78
+ config :set_session_level_serverhost_on_events, validate: :boolean, default: false
79
+
80
+ # By default, logstash will add "host" attribute which includes logstash aggregator server
81
+ # host to each event. This is not really needed and desired anymore with the fixed and improved
82
+ # serverHost attribute handling (serverHost now contains logstash aggregator hostname by
83
+ # default).
84
+ config :remove_host_attribute_from_events, validate: :boolean, default: true
85
+
68
86
  # If true, nested values will be flattened (which changes keys to delimiter-separated concatenation of all
69
87
  # nested keys).
70
88
  config :flatten_nested_values, :validate => :boolean, :default => false
@@ -151,6 +169,10 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
151
169
  # Scalyr single request limit won't be reached.
152
170
  config :estimate_each_event_size, :validate => :boolean, :default => true
153
171
 
172
+ # Library to use for JSON serialization. Valid values are "stdlib" and "jrjackson". The later may offer 2-4 performance
173
+ # improvements on serialization.
174
+ config :json_library, :validate => :string, :default => "stdlib"
175
+
154
176
  # Manticore related options
155
177
  config :http_connect_timeout, :validate => :number, :default => 10
156
178
  config :http_socket_timeout, :validate => :number, :default => 10
@@ -190,6 +212,24 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
190
212
  @logger.warn "Maximum request buffer > 6 MB. This may result in requests being rejected by Scalyr."
191
213
  end
192
214
 
215
+ if not @estimate_each_event_size
216
+ @logger.warn("estimate_each_event_size config option is false, this means very large batches may be rejected or partially processed by the server")
217
+ end
218
+
219
+ if @json_library != "stdlib" and @json_library != "jrjackson"
220
+ raise LogStash::ConfigurationError, "json_library config option needs to be either stdlib or jrjackson"
221
+ end
222
+
223
+ if @json_library == "stdlib"
224
+ define_singleton_method "json_encode" do |data|
225
+ data.to_json
226
+ end
227
+ elsif @json_library == "jrjackson"
228
+ define_singleton_method "json_encode" do |data|
229
+ JrJackson::Json.dump(data)
230
+ end
231
+ end
232
+
193
233
  @dlq_writer = dlq_enabled? ? execution_context.dlq_writer : nil
194
234
 
195
235
  @message_encoding = nil
@@ -218,12 +258,13 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
218
258
  @server_attributes = new_attributes
219
259
  end
220
260
 
221
- # See if we should use the hostname as the server_attributes.serverHost
222
- if @use_hostname_for_serverhost
223
- if @server_attributes.nil?
261
+ # See if we should use the hostname as the server_attributes.serverHost (aka if fixed serverHost is not
262
+ # defined as part of server_attributes config option)
263
+ if @server_attributes.nil?
224
264
  @server_attributes = {}
225
- end
265
+ end
226
266
 
267
+ if @use_hostname_for_serverhost
227
268
  # only set serverHost if it doesn't currently exist in server_attributes
228
269
  # Note: Use strings rather than symbols for the key, because keys coming
229
270
  # from the config file will be strings
@@ -235,6 +276,15 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
235
276
  # Add monitor server attribute to identify this as coming from a plugin
236
277
  @server_attributes['monitor'] = 'pluginLogstash'
237
278
 
279
+ # We create a fixed copy without host here so we can reference this later if needed to avoid
280
+ # some of the copy + manipulate overhead per batch
281
+ @server_attributes_without_serverhost = @server_attributes.clone
282
+ if @server_attributes_without_serverhost.key? "serverHost"
283
+ @server_attributes_without_serverhost.delete "serverHost"
284
+ end
285
+
286
+ @session_server_host = @server_attributes["serverHost"]
287
+
238
288
  @scalyr_server << '/' unless @scalyr_server.end_with?('/')
239
289
 
240
290
  @add_events_uri = URI(@scalyr_server) + "addEvents"
@@ -267,7 +317,8 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
267
317
  @http_connect_timeout, @http_socket_timeout, @http_request_timeout, @http_pool_max, @http_pool_max_per_route
268
318
  )
269
319
 
270
- @logger.info(sprintf("Started Scalyr output plugin (%s)." % [PLUGIN_VERSION]), :class => self.class.name)
320
+ @logger.info(sprintf("Started Scalyr LogStash output plugin %s (compression_type=%s,compression_level=%s,json_library=%s)." %
321
+ [PLUGIN_VERSION, @compression_type, @compression_type, @json_library]), :class => self.class.name)
271
322
 
272
323
  # Finally, send a status line to Scalyr
273
324
  # We use a special separate short lived client session for sending the initial client status.
@@ -482,7 +533,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
482
533
  @dlq_writer.write(l_event, "#{exc_data[:message]}")
483
534
  }
484
535
  else
485
- @logger.warn("Deal letter queue not configured, dropping #{multi_event_request[:logstash_events].length} events after #{exc_retries} tries.", :sample_events => sample_events)
536
+ @logger.warn("Dead letter queue not configured, dropping #{multi_event_request[:logstash_events].length} events after #{exc_retries} tries.", :sample_events => sample_events)
486
537
  end
487
538
  end
488
539
 
@@ -526,6 +577,8 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
526
577
  logs_ids = Hash.new
527
578
  next_log_id = 1
528
579
 
580
+ batch_has_event_level_server_host = false
581
+
529
582
  logstash_events.each {|l_event|
530
583
 
531
584
  record = l_event.to_hash
@@ -581,6 +634,11 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
581
634
  # Rename user-specified logfile field -> 'logfile'
582
635
  rename.call(@logfile_field, 'logfile')
583
636
 
637
+ # Remove "host" attribute
638
+ if @remove_host_attribute_from_events and record.key? "host"
639
+ record.delete("host")
640
+ end
641
+
584
642
  # Set a default parser is none is present in the event
585
643
  if record['parser'].to_s.empty?
586
644
  record['parser'] = "logstashParser"
@@ -591,26 +649,31 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
591
649
  record['logfile'] = "/logstash/#{serverHost}"
592
650
  end
593
651
 
594
- # Set a default if no serverHost value is present.
595
- if serverHost.nil?
596
- record['serverHost'] = "Logstash"
652
+ # Rename serverHost (if exists) to __origServerHost so sources filtering works correctly
653
+ # It's important that this happens at the very end of the event processing in this function.
654
+ record_has_server_host_attribute = record.key? 'serverHost'
655
+ batch_has_event_level_server_host |= record_has_server_host_attribute
656
+
657
+ if record_has_server_host_attribute
658
+ record[EVENT_LEVEL_SERVER_HOST_ATTRIBUTE_NAME] = record['serverHost']
659
+ record.delete('serverHost')
597
660
  end
598
661
 
662
+ # To reduce duplication of common event-level attributes, we "fold" them into top-level "logs" attribute
663
+ # and reference log entry inside the event
599
664
  log_identifier = nil
600
665
  add_log = false
601
666
  if serverHost
602
667
  log_identifier = serverHost + record['logfile']
603
668
  end
669
+
604
670
  if log_identifier and not logs.key? log_identifier
605
671
  add_log = true
606
672
  logs[log_identifier] = {
607
673
  'id' => next_log_id,
608
674
  'attrs' => Hash.new
609
675
  }
610
- if not record['serverHost'].to_s.empty?
611
- logs[log_identifier]['attrs']['serverHost'] = record['serverHost']
612
- record.delete('serverHost')
613
- end
676
+
614
677
  if not record['logfile'].to_s.empty?
615
678
  logs[log_identifier]['attrs']['logfile'] = record['logfile']
616
679
  record.delete('logfile')
@@ -623,10 +686,21 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
623
686
  end
624
687
  }
625
688
  end
689
+
626
690
  logs_ids[log_identifier] = next_log_id
627
691
  next_log_id += 1
628
692
  end
629
693
 
694
+ # If we already contain "logs" entry for this record, we remove duplicated serverHost from
695
+ # the event attributes since it's already part of the log level attributes which are
696
+ # referenced by the event.
697
+ if log_identifier and logs.key? log_identifier
698
+ if not record[EVENT_LEVEL_SERVER_HOST_ATTRIBUTE_NAME].to_s.empty?
699
+ logs[log_identifier]['attrs'][EVENT_LEVEL_SERVER_HOST_ATTRIBUTE_NAME] = record[EVENT_LEVEL_SERVER_HOST_ATTRIBUTE_NAME]
700
+ record.delete(EVENT_LEVEL_SERVER_HOST_ATTRIBUTE_NAME)
701
+ end
702
+ end
703
+
630
704
  # Delete unwanted fields from record
631
705
  record.delete('@version')
632
706
  record.delete('@timestamp')
@@ -672,7 +746,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
672
746
  :attrs => record
673
747
  }
674
748
 
675
- # optionally set thread
749
+ # optionally set thread and referenced log file
676
750
  if serverHost
677
751
  scalyr_event[:thread] = thread_id.to_s
678
752
  scalyr_event[:log] = logs_ids[log_identifier]
@@ -681,10 +755,10 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
681
755
  if @estimate_each_event_size
682
756
  # get json string of event to keep track of how many bytes we are sending
683
757
  begin
684
- event_json = scalyr_event.to_json
758
+ event_json = self.json_encode(scalyr_event)
685
759
  log_json = nil
686
760
  if add_log
687
- log_json = logs[log_identifier].to_json
761
+ log_json = self.json_encode(logs[log_identifier])
688
762
  end
689
763
  rescue JSON::GeneratorError, Encoding::UndefinedConversionError => e
690
764
  @logger.warn "#{e.class}: #{e.message}"
@@ -700,7 +774,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
700
774
  "UTF-8", :invalid => :replace, :undef => :replace, :replace => "<?>"
701
775
  ).force_encoding('UTF-8')
702
776
  end
703
- event_json = scalyr_event.to_json
777
+ event_json = self.json_encode(scalyr_event)
704
778
  rescue Java::JavaLang::ClassCastException => e
705
779
  # Most likely we ran into the issue described here: https://github.com/flori/json/issues/336
706
780
  # Because of the version of jruby logstash works with we don't have the option to just update this away,
@@ -711,10 +785,10 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
711
785
  @multi_receive_statistics[:total_java_class_cast_errors] += 1
712
786
  end
713
787
  Scalyr::Common::Util.convert_bignums(scalyr_event)
714
- event_json = scalyr_event.to_json
788
+ event_json = self.json_encode(scalyr_event)
715
789
  log_json = nil
716
790
  if add_log
717
- log_json = logs[log_identifier].to_json
791
+ log_json = self.json_encode(logs[log_identifier])
718
792
  end
719
793
  end
720
794
 
@@ -733,7 +807,8 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
733
807
  append_event = false
734
808
  end
735
809
 
736
- multi_event_request = self.create_multi_event_request(scalyr_events, l_events, current_threads, logs)
810
+ Scalyr::Common::Util.set_session_level_serverhost_on_events(@session_server_host, scalyr_events, logs, batch_has_event_level_server_host)
811
+ multi_event_request = self.create_multi_event_request(scalyr_events, l_events, current_threads, logs, batch_has_event_level_server_host)
737
812
  multi_event_request_array << multi_event_request
738
813
 
739
814
  total_bytes = 0
@@ -742,6 +817,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
742
817
  logs_ids = Hash.new
743
818
  scalyr_events = Array.new
744
819
  l_events = Array.new
820
+ batch_has_event_level_server_host = false
745
821
  end
746
822
  else
747
823
  # If size estimation is disabled we simply append the event and handle splitting later on (if needed)
@@ -761,14 +837,14 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
761
837
 
762
838
  # create a final request with any left over events (and make sure there is at least one event)
763
839
  if scalyr_events.size >= 1
764
- multi_event_request = self.create_multi_event_request(scalyr_events, l_events, current_threads, logs)
840
+ Scalyr::Common::Util.set_session_level_serverhost_on_events(@session_server_host, scalyr_events, logs, batch_has_event_level_server_host)
841
+ multi_event_request = self.create_multi_event_request(scalyr_events, l_events, current_threads, logs, batch_has_event_level_server_host)
765
842
  multi_event_request_array << multi_event_request
766
843
  end
767
844
 
768
845
  multi_event_request_array
769
846
  end
770
847
 
771
-
772
848
  # Helper method that adds a client_timestamp to a batch addEvents request body
773
849
  def add_client_timestamp_to_body(body)
774
850
  current_time_millis = DateTime.now.strftime('%Q').to_i
@@ -781,7 +857,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
781
857
  # A request comprises multiple Scalyr Events. This function creates a request hash for
782
858
  # final upload to Scalyr (from an array of events, and an optional hash of current threads)
783
859
  # Note: The request body field will be json-encoded.
784
- def create_multi_event_request(scalyr_events, logstash_events, current_threads, current_logs)
860
+ def create_multi_event_request(scalyr_events, logstash_events, current_threads, current_logs, batch_has_event_level_server_host = false)
785
861
 
786
862
  body = {
787
863
  :session => @session_id + Thread.current.object_id.to_s,
@@ -810,26 +886,33 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
810
886
  end
811
887
 
812
888
  # add serverAttributes
813
- body[:sessionInfo] = @server_attributes if @server_attributes
889
+ # If serverHost is defined on any of the events, we don't send it via sessionInfo since
890
+ # sesionInfo has the higest priority and would always overwritte the event level one
891
+ if batch_has_event_level_server_host
892
+ body[:sessionInfo] = @server_attributes_without_serverhost if @server_attributes_without_serverhost
893
+ else
894
+ body[:sessionInfo] = @server_attributes if @server_attributes
895
+ end
814
896
 
815
897
  # We time serialization to get some insight on how long it takes to serialize the request body
816
898
  start_time = Time.now.to_f
817
899
  begin
818
- serialized_body = body.to_json
900
+ serialized_body = self.json_encode(body)
819
901
  rescue Java::JavaLang::ClassCastException => e
820
902
  @logger.warn("Error serializing events to JSON, likely due to the presence of Bignum values. Converting Bignum values to strings.")
821
903
  @stats_lock.synchronize do
822
904
  @multi_receive_statistics[:total_java_class_cast_errors] += 1
823
905
  end
824
906
  Scalyr::Common::Util.convert_bignums(body)
825
- serialized_body = body.to_json
907
+ serialized_body = self.json_encode(body)
826
908
  end
827
909
  end_time = Time.now.to_f
828
910
  serialization_duration = end_time - start_time
829
911
 
830
912
  serialized_request_size = serialized_body.bytesize
831
913
 
832
- if serialized_request_size >= @max_request_buffer
914
+ # We give it "buffer" since the splitting code allows for some slack and doesn't take into account top-level non-event attributes
915
+ if not @estimate_each_event_size and serialized_request_size >= @max_request_buffer + 5000
833
916
  # TODO: If we end up here is estimate config opsion is false, split the request here into multiple ones
834
917
  @logger.warn("Serialized request size (#{serialized_request_size}) is larger than max_request_buffer (#{max_request_buffer})!")
835
918
  end
@@ -902,8 +985,9 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
902
985
  }
903
986
  @send_stats.synchronize do
904
987
  if !@last_status_transmit_time
905
- status_event[:attrs]['message'] = sprintf("Started Scalyr LogStash output plugin (%s)." % [PLUGIN_VERSION])
906
- status_event[:attrs]['serverHost'] = @node_hostname
988
+ status_event[:attrs]['message'] = sprintf("Started Scalyr LogStash output plugin %s (compression_type=%s,compression_level=%s,json_library=%s)." %
989
+ [PLUGIN_VERSION, @compression_type, @compression_type, @json_library])
990
+ status_event[:attrs][EVENT_LEVEL_SERVER_HOST_ATTRIBUTE_NAME] = @node_hostname
907
991
  else
908
992
  cur_time = Time.now()
909
993
  return if (cur_time.to_i - @last_status_transmit_time.to_i) < @status_report_interval
@@ -925,7 +1009,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
925
1009
  cnt += 1
926
1010
  end
927
1011
  status_event[:attrs]['message'] = msg
928
- status_event[:attrs]['serverHost'] = @node_hostname
1012
+ status_event[:attrs][EVENT_LEVEL_SERVER_HOST_ATTRIBUTE_NAME] = @node_hostname
929
1013
  status_event[:attrs]['parser'] = @status_parser
930
1014
  end
931
1015
  multi_event_request = create_multi_event_request([status_event], nil, nil, nil)