Google Stackdriver Logging Extension

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

Version 1.3.7

Write entries to Stackdriver Logging logs.

This content provides reference for configuring and using this extension.

Prerequisites

Before using this extension from an API proxy, you must:

  1. In IAM, assign the Logging > Logs Writer and Logging > Logs Viewer role to the project member that will represent your extension to the Stackdriver Logging system. For instructions on how to grant roles, see Granting roles to a service account for specific resources. For more on logging roles, see Access Control Guide.

  2. Use the GCP Console to generate a key for the service account.

  3. Use the contents of the resulting key JSON file when adding and configuring the extension using the configuration reference.

This extension supports being called by an ExtensionCallout policy located in PostClientFlow. If you want to use the ExtensionCallout policy to call this extension from a PostClientFlow, ensure that the features.allowExtensionsInPostClientFlow flag is set to true in your organization.

  • If you are an Apigee Edge for Public Cloud customer, you must contact Apigee Edge Support to ensure that the features.allowExtensionsInPostClientFlow flag is set to true in your organization.

  • If you are an Apigee Edge for Private Cloud customer, use the Update organization properties API to set the features.allowExtensionsInPostClientFlow flag to true.

About Stackdriver Logging

Stackdriver Logging is part of the Stackdriver suite of products in Google Cloud Platform (GCP). It includes storage for logs, a user interface called the Logs Viewer, and an API to manage logs programmatically. With Stackdriver Logging, you can read and write log entries, search and filter your logs, export your logs, and create logs-based metrics.

This extension currently writes entries to the log. For more, see the Stackdriver Logging docs.

Samples

The following examples illustrate how to configure support for Stackdriver Logging extension actions using the ExtensionCallout policy.

Global log

The following policy writes the message "This is a test" to a log called example-log in the Stackdriver Global resource. In actual use, you'd probably have the message be contained in a flow variable whose value you set elsewhere in the API proxy.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ConnectorCallout async="false" continueOnError="true" enabled="true" name="Logging-Extension">
    <DisplayName>Logging Connector</DisplayName>
    <Connector>stackdriver-extension-sample</Connector>
    <Action>log</Action>
    <Input><![CDATA[{
        "logName": "example-log",
        "metadata": {
            "resource": {
                "type": "global",
                "labels": {
                    "project_id": "my-test"
                }
            }
        },
        "message": "This is a test"
    }]]></Input>
</ConnectorCallout>

This content provides reference for configuring and using this extension. For steps to configure an extension using the Apigee console, see Adding and configuring an extension.

Actions

log

Writes a message to the log.

This action writes a Stackdriver log entry. Log entries consist of metadata and the entry data. For more about log entries, see the Entry reference. For information about contents of the metadata property, see the LogEntry object in the Stackdriver Logging documentation.

Syntax

<Action>log</Action>
<Input><![CDATA[{
  "logName" : "stackdriver-log-name-to-use",
  "metadata" : JSON-structured-metadata,
  "message" : "data-to-log-as-entry"
}]]></Input>

Example

<Action>log</Action>
<Input><![CDATA[{
  "logName" : "stackdriver-log-name-to-use",
  "metadata" : { "resource" : { "type" : "global" } },
  "message" : "data-to-log-as-entry"
}]]></Input>

Request parameters

Parameter Description Type Default Required
logName The name of the log to which this entry belongs. String None. Yes.
metadata Metadata about the log entry.
For more information and options on setting type and labels in metadata see MonitoredResource.
JSON None. No.
message Data to use as the value for this log entry. String None. Yes.

Response

None if the message was written to the log. Otherwise, the request will return an error. See also Debugging an extension.

Configuration Reference

Use the following when you're configuring and deploying this extension for use in API proxies.

Common extension properties

The following properties are present for every extension.

Property Description Default Required
name Name you're giving this configuration of the extension. None Yes
packageName Name of the extension package as given by Apigee Edge. None Yes
version Version number for the extension package from which you're configuring an extension. None Yes
configuration Configuration value specific to the extension you're adding. See Properties for this extension package None Yes

Properties for this extension package

Specify values for the following configuration properties specific to this extension.

Property Description Default Required
projectId The GCP project ID where logs should be created. None. Yes.
credentials When entered in the Apigee Edge console, this is the contents of your service account key file. When sent via the management API, it is a base64-encoded value generated from the service account key file. None. Yes.