新手问题 问个关于 ELK 的问题

tt12580-github · 2017年03月10日 · 最后由 tt12580-github 回复于 2017年03月10日 · 1641 次阅读

rails 的 ELK 该怎么配置才能显示成下面这个样子的 message: {"method":"GET","path":"/","format":"html","controller":"application","action":"index","status":200, "duration":7.91,"view":0.31,"db":0.0,"ip":"req_ip","route":"application#index","request_id":"some_id","source":"127.0.1.1","tags":["request"],"@timestamp":"2017-02-10T06:52:01.984Z","@version":"1"} @version:1 @timestamp:February 10th 2017, 08:52:10.451 offset:25,747 type:log tags:json, beats_input_codec_plain_applied beat.hostname:deployer-VirtualBox

mengqing 回复

我刚试了这个 gem,但 log 还是和原来的一样啊

能把原来的贴出来么?

Started GET "/addresses" for 127.0.0.1 at 2017-03-10 14:15:43 +0800
Processing by AddressesController#index as HTML
  Rendering addresses/index.html.erb within layouts/application
  ^[[1m^[[36mAddress Load (0.2ms)^[[0m  ^[[1m^[[34mSELECT `addresses`.* FROM `addresses`^[[0m
  Rendered addresses/_table.html.erb (1.6ms)
  ^[[1m^[[36mPicture Load (0.2ms)^[[0m  ^[[1m^[[34mSELECT  `pictures`.* FROM `pictures` ORDER BY `pictures`.`id` DESC LIMIT 8 OFFSET 0^[[0m
  Rendered collection of pictures/_picture.html.erb [8 times] (2.1ms)
  ^[[1m^[[35m (0.3ms)^[[0m  ^[[1m^[[34mSELECT COUNT(*) FROM `pictures`^[[0m
  ^[[1m^[[36mAddress Load (0.2ms)^[[0m  ^[[1m^[[34mSELECT  `addresses`.* FROM `addresses` ORDER BY `addresses`.`id` DESC LIMIT 1^[[0m
  Rendered addresses/index.html.erb within layouts/application (10.6ms)
Completed 200 OK in 61ms (Views: 58.7ms | ActiveRecord: 0.9ms)


Started GET "/" for 127.0.0.1 at 2017-03-10 16:12:27 +0800
  ^[[1m^[[36mActiveRecord::SchemaMigration Load (0.2ms)^[[0m  ^[[1m^[[34mSELECT `schema_migrations`.* FROM `schema_migrations`^[[0m
Processing by AddressesController#index as HTML
  Rendering addresses/index.html.erb within layouts/application
  ^[[1m^[[36mAddress Load (0.3ms)^[[0m  ^[[1m^[[34mSELECT `addresses`.* FROM `addresses`^[[0m
  Rendered addresses/_table.html.erb (8.2ms)
  ^[[1m^[[36mPicture Load (0.2ms)^[[0m  ^[[1m^[[34mSELECT  `pictures`.* FROM `pictures` ORDER BY `pictures`.`id` DESC LIMIT 8 OFFSET 0^[[0m
  Rendered collection of pictures/_picture.html.erb [8 times] (1.8ms)
  ^[[1m^[[35m (0.2ms)^[[0m  ^[[1m^[[34mSELECT COUNT(*) FROM `pictures`^[[0m
  ^[[1m^[[36mAddress Load (0.3ms)^[[0m  ^[[1m^[[34mSELECT  `addresses`.* FROM `addresses` ORDER BY `addresses`.`id` DESC LIMIT 1^[[0m
  Rendered addresses/index.html.erb within layouts/application (41.0ms)
Completed 200 OK in 391ms (Views: 377.4ms | ActiveRecord: 2.2ms)
mengqing 回复

我这个是在 development.rb 上改的

是不是你没设置呢

# config/initializers/lograge.rb
# OR
# config/environments/development.rb
MyApp::Application.configure do
  config.lograge.enabled = true
end

然后需要重启 server

mengqing 回复

我搞错啦,这个新的 log 输出在 logstasher.log 里的吧

tt12580-github 关闭了讨论。 03月24日 16:55
需要 登录 后方可回复, 如果你还没有账号请 注册新账号