Skip to content

Commit

Permalink
Merge pull request #27 from matsuu/enhance-config-file
Browse files Browse the repository at this point in the history
Enhance config file
  • Loading branch information
matsuu authored Jul 25, 2021
2 parents 5d80d74 + 854e4e6 commit c5069c4
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 22 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ access-log:
format: "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\" %{duration}x"
```

### Envoy

Use [default format](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#config-access-log-default-format)

### Varnishncsa

Add `%D` to [varnishncsa -F option](https://www.varnish-cache.org/docs/trunk/reference/varnishncsa.html).
Expand All @@ -52,6 +56,10 @@ use Rack::CommonLogger, logger
Install via go command or download [release file](https://github.com/matsuu/kataribe/releases)

```sh
# go >=1.16
go install github.com/matsuu/kataribe@latest

# go <1.16
go get -u github.com/matsuu/kataribe
```

Expand Down
84 changes: 62 additions & 22 deletions toml.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package main

const CONFIG_TOML = `# Top Ranking Group By Request
const CONFIG_TOML = `################################################################################
# General
################################################################################
# Top Ranking Group By Request
ranking_count = 20
# Top Slow Requests
Expand All @@ -18,6 +22,10 @@ show_bytes = true
# Percentiles
percentiles = [ 50.0, 90.0, 95.0, 99.0 ]
################################################################################
# Scale
################################################################################
# for Nginx($request_time)
scale = 0
effective_digit = 3
Expand All @@ -26,59 +34,91 @@ effective_digit = 3
#scale = -6
#effective_digit = 6
# for H2O(%{duration}x)
#scale = 0
#effective_digit = 6
# for Envoy
#scale = -3
#effective_digit = 3
# for Rack(Rack::CommonLogger)
#scale = 0
#effective_digit = 4
################################################################################
# Parse
################################################################################
#
# combined + duration
# Nginx example: '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_time'
# Apache example: "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D"
# H2O example: "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\" %{duration}x"
# Varnishncsa example: '%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i" %D'
#
log_format = '^([^ ]+) ([^ ]+) ([^ ]+) \[([^\]]+)\] "((?:\\"|[^"])*)" (\d+) (\d+|-) "((?:\\"|[^"])*)" "((?:\\"|[^"])*)" ([0-9.]+)$'
request_index = 5
status_index = 6
bytes_index = 7
duration_index = 10
#
# Envoy example: use default format
#
#log_format = '^\[([^\]]+)\] "((?:\\"|[^"])*)" (\d+) ([^ ]+) (\d+|-) (\d+|-) (\d+) (\d+) "((?:\\"|[^"])*)" "((?:\\"|[^"])*)" "((?:\\"|[^"])*)" "((?:\\"|[^"])*)" "((?:\\"|[^"])*)"'
#request_index = 2
#status_index = 3
#bytes_index = 6
#duration_index = 7
#
# Rack example: use Rack::CommonLogger, Logger.new("/tmp/app.log")
#
#log_format = '^([^ ]+) ([^ ]+) ([^ ]+) \[([^\]]+)\] "((?:\\"|[^"])*)" (\d+) (\d+|-) ([0-9.]+)$'
#request_index = 5
#status_index = 6
#bytes_index = 7
#duration_index = 8
################################################################################
# Bundle
################################################################################
#
# You can aggregate requests by regular expression
# For overview of regexp syntax: https://golang.org/pkg/regexp/syntax/
[[bundle]]
regexp = '^(GET|HEAD) /memo/[0-9]+\b'
name = "get memo"
[[bundle]]
regexp = '^(GET|HEAD) /stylesheets/'
name = "stylesheets"
#
#[[bundle]]
#regexp = '^(GET|HEAD) /users/[0-9]+\b'
#name = 'GET /memo/*'
#
#[[bundle]]
#regexp = '^(GET|HEAD) /stylesheets/'
#name = 'GET /stylesheets/*'
#
#[[bundle]]
#regexp = '^(GET|HEAD) /images/'
#name = 'GET /images/*'
[[bundle]]
regexp = '^(GET|HEAD) /images/'
name = "images"
################################################################################
# Replace
################################################################################
#
# You can replace the part of urls which matched to your regular expressions.
# For overview of regexp syntax: https://golang.org/pkg/regexp/syntax/
#[[replace]]
#regexp = '/[0-9]+/'
#replace = '/<num>/'
#
#[[replace]]
#regexp = '/[0-9]+\s'
#replace = '/<num> '
#regexp = '/[0-9]+(/|\s)'
#replace = '/<num>$1'
#
#[[replace]]
#regexp = '=[0-9]+&'
#replace = '=<num>&'
#regexp = '=[0-9]+(&|\s)'
#replace = '=<num>$1'
#
#[[replace]]
#regexp = '=[0-9]+\s'
#replace = '=<num> '
`
#regexp = '\s+HTTP/[0-9.]+$'
#replace = ''
################################################################################`

0 comments on commit c5069c4

Please sign in to comment.