apachetop icon indicating copy to clipboard operation
apachetop copied to clipboard

Is there any option to configure it to work with json type of logs?

Open FlaviuRadulescu opened this issue 4 years ago • 1 comments

Not an issue, but a question.

Is there any option to make it work with a json log similar to this one?

{
 "time":"[04/Jul/2020:11:14:30 +0000]",
 "remoteHostOrIP":"141.101.98.64",
 "localHostOrIP":"95.217.58.91",
 "host":"host.domain",
 "urlPath":"/links",
 "query":"?url=links&taskId=489097",
 "requestMethod":"POST",
 "HTTP-StatusCode":"201",
 "userAgent":"some user agent",
 "referer":"-",
 "uniqueID":"-",
 "X-Forwarded-For":"-",
 "CF-Connecting-IP":"2a06:98c0:3600::103",
 "Cf-Ipcountry":"-",
 "remoteUser":"-",
 "responseTimeMicroseconds":"10443",
 "remoteHost":"141.101.98.64",
 "keepAliveRequest":"0",
 "remoteLogName":"-",
 "request":"POST /links?taskId=489097 HTTP/1.1",
 "requestTimeSeconds":"0",
 "fileName":"proxy:fcgi://php-fpm/path/index.php",
 "bytesReceived":"1218",
 "bytesSent":"5642",
 "sizeExcludingHTTPHeaders":"-",
 "connectionStatus":"+",
 "HostInTheHeader":"host.domain",
 "setCoockie":"5642",
 "getCoockie":"-",
 "php-postData":"-",
 "php-getData":"-",
 "php-sssSLog":"-",
 "php-ssPLog":"-"
}

Thank you, F

FlaviuRadulescu avatar Jul 04 '20 11:07 FlaviuRadulescu

Currently this is not supported.

If this were a common request, I'd consider adding it. However, it would mean to add a dependency to another lib, since I wouldn't re-invent the wheel for parsing JSON.

But I don't see this as a feature that is used very often.

There are 2 options:

  • code it yourself and open a PR
  • pipe the above log through jq or another filter that can convert the data into a supported format and feed it to apachetop

tessus avatar Jul 04 '20 18:07 tessus