Plugin for exporting Kong request data such as Service name, Route name, Consumer name or request latency to Google Cloud Logging.
Exported Data
For every request, the following data is exported:
- service name (if known)
- route name (if known)
- consumer name (if known)
- upstream_uri
- uri
- latency_request
- latency_gateway
- latency_proxy
- httpRequest
The logs are labeled with: "source": "kong-google-logging"
.
Usage
The plugin requires some Google service account credentials to write log entries to Google Cloud Logging.
The service account requires the scope as described in the API docs.
The credential details can be configured using the google_key
parameter OR by providing a path to the key file using the google_key_file
parameter.
The plugin uses Kong’s batch queue to send out log entries to Google in batches. For more information about the batch queue parameters, see batch_queue.lua.
Sample configuration via declarative (YAML):
plugins:
- name: google-logging
config:
google_key:
private_key: "***"
client_email: "***"
project_id: "***"
token_uri: "***"
google_key_file: /path/to/service-account-keyfile.json
resource:
type: k8s_cluster
labels:
project_id: "my project"
location: "my location"
cluster_name: "my cluster name"
retry_count: 0
flush_timeout: 2
batch_max_size: 200
Install
Luarocks
luarocks install kong-plugin-google-logging
Source Code
> git clone https://github.com/SmartParkingTechnology/kong-google-logging-plugin.git
> cd /path/to/kong/plugins/kong-google-logging-plugin
> luarocks make *.rockspec
Configuration Reference
This plugin is not compatible with DB-less mode.
Enable the plugin globally
A plugin which is not associated to any service, route, or consumer is considered global, and will be run on every request. Read the Plugin Reference and the Plugin Precedence sections for more information.
Parameters
Here's a list of all the parameters which can be used in this plugin's configuration:
Form Parameter | Description |
---|---|
name
required Type: string |
The name of the plugin, in this case google-logging . |
enabled
required Type: boolean Default value: true |
Whether this plugin will be applied. |
config.log_id
optional Default value: cloudresourcemanager.googleapis.com%2Factivity
|
The log id in: |
config.google_key
optional |
The private key parameters of the Google service account. Either |
config.google_key_file
optional |
Path to the service account json file. The associated service account needs the scope: |
config.resource
optional |
The Google monitor resource. Also see MonitoredResource. |
config.retry_count
optional Default value: 0
|
Kong batch queue |
config.flush_timeout
optional Default value: 2
|
Kong batch queue |
config.batch_max_size
optional Default value: 200
|
Kong batch queue |