In order to give you better service we use cookies. By continuing to use our website, you agree to the use of cookies as described in our Cookie Policy

Are you a Kong Gateway user? We'd love your feedback. Take the Survey

Kong Logo
  • Get Started
  • Products
    • kong-enterprise Kong Enterprise
      • Kong Enterprise

        End-to-end connectivity platform

      • Kong Mesh

        Universal service mesh

      • Kong Studio

        Empower your developers

      • Dev Portal

        Accelerate innovation

      • Kong Manager

        Manage all your services

      • Kong Immunity

        Autonomously identify issues

      • Kong for Kubernetes

        Native Kubernetes Ingress Controller

      • Enterprise Plugins

        Instantly implement policies

      • Kong Vitals

        Monitor your Kong Enterprise

      • Get Started
    • Built on an Open-source Foundation
      • kong-gateway Kong Gateway

        API Gateway

      • kuma Kuma

        Service Mesh

      • insomnia Insomnia

        API Design and Testing

      • Install
    • Kubernetes & Subscriptions
      • Kubernetes Ingress Controller

        Ingress and CRDs

      • Subscriptions

        Kong Gateway and Enterprise features

  • Solutions
    • Use Cases
      • Decentralize Apps and Services

        Accelerate your journey into microservices

      • Secure and Govern APIs

        Empower teams to provide security, governance and compliance

      • Create a Developer Platform

        Rapidly design, publish and consume APIs and services

    • Deployment Patterns
      • API Gateway

        Take control of your microservices with the world’s most popular API gateway

      • Kubernetes

        Own your Kubernetes cluster by using Kong as an Ingress Controller

      • Service Mesh

        Build, secure and observe your modern Service Mesh

  • Plugins
  • Open Source
    • Install Kong Gateway
    • Kong Community
    • Kubernetes Ingress
    • Kuma
    • Insomnia
  • Docs
    • Documentation
      • Kong Gateway
      • Kong Enterprise
      • Kong Mesh
      • Kong Studio
      • Plugins Hub
  • Resources
    • Learning
      • eBooks
      • Webinars
      • Briefs
      • Blog
    • Community
      • Community
      • Kong Nation
      • Kong Summit
      • GitHub
    • Support
      • Enterprise Support Portal
      • FAQS
      • Kong Professional Services
      • Kong University
  • Company
    • About
    • Customers
    • Investors
    • Careers
    • Partners
    • Press
    • Contact
  • Get Started
header icon

Kong Google Cloud Logging

  • Back to Kong Plugin Hub
  • githubEdit this page
  • report-issueReport an issue
  • Exported Data
  • Usage
  • Install
    • Luarocks
    • Source Code
  • Configuration Reference
    • Enabling the plugin globally
    • Parameters
About this Plugin
Made by SmartParkingTechnology
Categories
  • Logging
DB-less compatible? Yes (Kong Gateway only)
Support github.com
Source
  • Code
  • License (Apache-2.0)
Compatibility
    Kong Community
  • 2.2.x
  • 2.1.x
Community Plugin: This plugin is developed, tested, and maintained by a third-party contributor.

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

You can configure this plugin using the Kong Admin API or through declarative configuration, which involves directly editing the Kong configuration file.

This plugin is compatible with requests with the following protocols:

  • http
  • https

This plugin is compatible with DB-less mode.

In DB-less mode, Kong does not have an Admin API. If using this mode, configure the plugin using declarative configuration.

Enabling 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.

Kong Admin API
Kubernetes
Declarative (YAML)

For example, configure this plugin globally with:

$ curl -X POST http://<admin-hostname>:8001/plugins/ \
    --data "name=google-logging" 

Create a KongClusterPlugin resource and label it as global:

apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
  name: <global-google-logging>
  annotations:
    kubernetes.io/ingress.class: kong
  labels:
    global: \"true\"
config:
  <optional_parameter>: <value>
plugin: google-logging

For example, configure this plugin using the plugins: entry in the declarative configuration file:

plugins:
- name: google-logging
  config:
    <optional_parameter>: <value>

Parameters

Here's a list of all the parameters which can be used in this plugin's configuration:

Form ParameterDescription
name

Type: string
The name of the plugin to use, in this case google-logging.
enabled

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: projects/[PROJECT_ID]/logs/[LOG_ID]. Also see LogEntry.

config.google_key
optional

The private key parameters of the Google service account. Either google_key or google_key_file must be specified.

config.google_key_file
optional

Path to the service account json file. The associated service account needs the scope: https://www.googleapis.com/auth/logging.write. Either google_key or google_key_file must be specified.

config.resource
optional

The Google monitor resource. Also see MonitoredResource.

config.retry_count
optional

Default value: 0

Kong batch queue retry_count.

config.flush_timeout
optional

Default value: 2

Kong batch queue flush_timeout in seconds.

config.batch_max_size
optional

Default value: 200

Kong batch queue batch_max_size.

Thank you for your feedback.
Was this page useful?
  • Kong
    THE CLOUD CONNECTIVITY COMPANY

    Kong powers reliable digital connections across APIs, hybrid and multi-cloud environments.

    • Company
    • Customers
    • Events
    • Investors
    • Careers Hiring!
    • Partners
    • Press
    • Contact
  • Products
    • Kong Gateway
    • Kong Enterprise
    • Get Started
    • Subscriptions
  • Resources
    • eBooks
    • Webinars
    • Briefs
    • Blog
    • API Gateway
    • Microservices
  • Open Source
    • Install Kong Gateway
    • Kong Community
    • Kubernetes Ingress
    • Kuma
    • Insomnia
  • Solutions
    • Decentralize
    • Secure & Govern
    • Create a Dev Platform
    • API Gateway
    • Kubernetes
    • Service Mesh
Star
  • Terms•Privacy
© Kong Inc. 2021