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 compatible with DB-less mode.
Example plugin configuration
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.
The following examples provide some typical configurations for enabling
the google-logging
plugin globally.
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 . |
instance_name
optional Type: string |
An optional custom name to identify an instance of the plugin, for example Useful when running the same plugin in multiple contexts, for example, on multiple services. |
enabled
optional Type: boolean Default value: |
Whether this plugin will be applied. |
config.log_id
optional Default value: |
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: |
Kong batch queue |
config.flush_timeout
optional Default value: |
Kong batch queue |
config.batch_max_size
optional Default value: |
Kong batch queue |