How to use goaccess with heroku rails app

216 views Asked by At

I want to generate goaccess dashboard result from heroku logs of rails application, As I checked there is no production.rb file in heroku

Format of logs in heroku is

2020-07-16T17:18:54.972063+00:00 app[web.1]: I, [2020-07-16T17:18:54.971939 #10]  INFO -- : [2712edd9-bca1-4d23-9cfd-399e6dedfbdc] Started GET "/api/v1/articles" for 18.225.35.172 at 2020-07-16 17:18:54 +0000
2020-07-16T17:18:54.973433+00:00 app[web.1]: I, [2020-07-16T17:18:54.973345 #10]  INFO -- : [2712edd9-bca1-4d23-9cfd-399e6dedfbdc] Processing by Api::V1::ArticlesController#index as JSON
2020-07-16T17:18:54.973525+00:00 app[web.1]: I, [2020-07-16T17:18:54.973450 #10]  INFO -- : [2712edd9-bca1-4d23-9cfd-399e6dedfbdc]   Parameters: {"article"=>{}}
2020-07-16T17:18:55.082811+00:00 heroku[router]: at=info method=GET path="/api/v1/article" host=abc-1234.herokuapp.com request_id=2779d556-67fc-4602-a58b-60dbcb209833 fwd="18.225.35.172" dyno=web.1 connect=1ms service=41ms status=200 bytes=539 protocol=https

I tried installing goaccess on my heroku server , but I am not able to do that, and I am not able to get log file also. I want response time for each request in goaccess dashboard. Anyone has idea about this ???How I can use goaccess + rails + heroku together

1

There are 1 answers

0
simo On

Try this:

cat ./production.log | grep 'Started GET' | goaccess --log-format='I, "%^" "%r" %^ %h %^ %d %t %^' --date-format=%F --time-format=%T

Note: it will work only for line like:

2020-07-16T17:18:54.972063+00:00 app[web.1]: I, [2020-07-16T17:18:54.971939 #10]  INFO -- : [2712edd9-bca1-4d23-9cfd-399e6dedfbdc] Started GET "/api/v1/articles" for 18.225.35.172 at 2020-07-16 17:18:54 +0000

other lines were ignored by grep, which were:

2020-07-16T17:18:54.973433+00:00 app[web.1]: I, [2020-07-16T17:18:54.973345 #10]  INFO -- : [2712edd9-bca1-4d23-9cfd-399e6dedfbdc] Processing by Api::V1::ArticlesController#index as JSON
2020-07-16T17:18:54.973525+00:00 app[web.1]: I, [2020-07-16T17:18:54.973450 #10]  INFO -- : [2712edd9-bca1-4d23-9cfd-399e6dedfbdc]   Parameters: {"article"=>{}}
2020-07-16T17:18:55.082811+00:00 heroku[router]: at=info method=GET path="/api/v1/article" host=abc-1234.herokuapp.com request_id=2779d556-67fc-4602-a58b-60dbcb209833 fwd="18.225.35.172" dyno=web.1 connect=1ms service=41ms status=200 bytes=539 protocol=https

My original answer was at goaccess issue, Good luck!