You're viewing Apigee Edge documentation.
Go to the
Apigee X documentation. info
Version 1.6.0
Write entries to Cloud Logging logs.
This content provides reference for configuring and using this extension.
Prerequisites
Before using this extension from an API proxy, you must:
In IAM, assign the Logging > Logs Writer role to the project member that will represent your extension to the Cloud 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.
Use the Google Cloud Console to generate a key for the service account.
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 totrue
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 totrue
.
About Cloud Logging
Cloud Logging is part of the Google Cloud's operations suite. It includes storage for logs, a user interface called the Logs explorer, and an API to manage logs programmatically. With Cloud Logging, you can read and write log entries, search and filter your logs, export your logs, and create logs-based metrics.
The Cloud Logging extension currently writes entries to the log. For more, see the Cloud Logging docs.
Samples
The following examples illustrate how to configure support for Cloud 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 Cloud 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>cloud-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 Cloud Logging log entry. Log entries consist of metadata
and the entry data. For more about log entries, see the
Entry reference.
For information about the contents of the metadata
property, see the
LogEntry
object in the Cloud Logging documentation.
Syntax
<Action>log</Action>
<Input><![CDATA[{
"logName" : "cloud-log-name-to-use",
"metadata" : JSON-structured-metadata,
"message" : "data-to-log-as-entry"
}]]></Input>
Example: String
<Action>log</Action>
<Input><![CDATA[{
"logName" : "example-log",
"metadata" : { "resource" : { "type" : "global" } },
"message": "This is a test."
}]]></Input>
Example: JSON
<Action>log</Action>
<Input><![CDATA[{
"logName" : "example-log",
"metadata" : { "resource" : { "type" : "global" } },
"message" : { "info" : "This is a test." }
}]]></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. You can specify a simple string or use JSON to log a more structured message. | String or JSON | 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 Google Cloud 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 |