-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from uswitch/airship-2978-customisable-log-format
AIRSHIP-2978 Customisable Access Log formats
- Loading branch information
Showing
10 changed files
with
214 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Access Log | ||
|
||
The Access log format is configurable via the Yggdrasil config file only. It is defined as a json object as follows: | ||
|
||
```json | ||
{ | ||
"accessLogger": { | ||
"format": { | ||
"bytes_received": "%BYTES_RECEIVED%", | ||
"bytes_sent": "%BYTES_SENT%", | ||
"downstream_local_address": "%DOWNSTREAM_LOCAL_ADDRESS%", | ||
"downstream_remote_address": "%DOWNSTREAM_REMOTE_ADDRESS%", | ||
"duration": "%DURATION%", | ||
"forwarded_for": "%REQ(X-FORWARDED-FOR)%", | ||
"protocol": "%PROTOCOL%", | ||
"request_id": "%REQ(X-REQUEST-ID)%", | ||
"request_method": "%REQ(:METHOD)%", | ||
"request_path": "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%", | ||
"response_code": "%RESPONSE_CODE%", | ||
"response_flags": "%RESPONSE_FLAGS%", | ||
"start_time": "%START_TIME(%s.%3f)%", | ||
"upstream_cluster": "%UPSTREAM_CLUSTER%", | ||
"upstream_host": "%UPSTREAM_HOST%", | ||
"upstream_local_address": "%UPSTREAM_LOCAL_ADDRESS%", | ||
"upstream_service_time": "%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%", | ||
"user_agent": "%REQ(USER-AGENT)%" | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
The config above would be the same as the default access logger config shipped with Yggdasil. Thus if no format is provided this will be the format used. | ||
|
||
[See Envoy docs for more on access log formats](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#config-access-log-default-format) | ||
|
||
The access log is written to `/var/log/envoy/access.log` which is not currently configurable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package envoy | ||
|
||
import ( | ||
types "github.com/envoyproxy/go-control-plane/pkg/cache/types" | ||
resource "github.com/envoyproxy/go-control-plane/pkg/resource/v3" | ||
) | ||
|
||
type EnvoySnapshot struct { | ||
Listeners map[string]types.Resource | ||
Clusters map[string]types.Resource | ||
} | ||
|
||
func (s *Snapshotter) ConfigDump() (EnvoySnapshot, error) { | ||
snapshot, err := s.CurrentSnapshot() | ||
if err != nil { | ||
return EnvoySnapshot{}, err | ||
} | ||
|
||
listeners := snapshot.GetResources(resource.ListenerType) | ||
clusters := snapshot.GetResources(resource.ClusterType) | ||
|
||
return EnvoySnapshot{ | ||
Listeners: listeners, | ||
Clusters: clusters, | ||
}, nil | ||
} |
Oops, something went wrong.