Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Logging for dev env

Hello, 

I have two Apigee environments: Dev and Testing. I created an API proxy and deployed it to both environments. The proxy includes a logging policy, which is configured to log data to Cloud Logging.

When I checked the logs in Cloud Logging for the Testing environment, I could see the logs being recorded as expected. However, when I checked for logs from the Development environment, I did not find any logs, even though the logging policy appears to have executed successfully in both environments.

0 3 156
3 REPLIES 3

Hello,

Are you sure everything was deployed the exact same, including the following:

1. Service account utilization, is it the same service account that is deployed within the environment construct or are they different? If different, are the same IAM roles used?

2. What does the underlying message logging policy look like? Are there any descrepencies/null variables being populated that would result in a log not being written for a given environment?

  • yes everything is the same service account, IAM roles everything

  • <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <MessageLogging continueOnError="false" enabled="true" name="ML-LogSuccessRequestToCloudLogs">
      <DisplayName>ML-LogSuccessRequestToCloudLogs</DisplayName>
      <CloudLogging>
        <LogName>projects/{projectId}/logs/{apiproxy.name}</LogName>
        <Message contentType="application/json">
          {
            "proxyGeneralInfo": {
                "environmentName": "{environment.name}",
                "apiProxyName": "{apiproxy.name}",
                "apiProxyRevision": "{apiproxy.revision}",
                "apiProductName": "{apiproduct.name}",
                "appName": "{developer.app.name}",
                "clientId": "{client_id}",
                "correlationId": "{messageid}",
                "developerEmail": "{escapeJSON(developer.email)}",
                "callingIPAddress": "{escapeJSON(client.ip)}"
            },
            "requestInfo":{
              "requestUrl": "{request.url}",
              "verb": "{request.verb}",
              "requestReceivedAt": "{client.received.end.time}",
              "requestFormParameters": "{request.formstring}",
              "requestHeaderNames":"{request.headers.names.string}",
              "requestQueryParameters": "{request.querystring}",
              "requestPayload": "{escapeJSON(request.content)}",
              "originalServerResponse":"{escapeJSON(original-server-response)}"
            },
            "responseInfo":{
              "responseStatusCode": "{message.status.code}",
              "responseHeaders":"{message.headers.names.string}",
              "responseSentAt": "{client.sent.end.time}",
              "responsePayload": "{escapeJSON(message.content)}",
              "originalServerResponse":"{escapeJSON(original-server-response)}"
            },
            "proxyExecutedPolicies":{
              "OAuthV2-ValidateAuthToken":{
                "failed":"{oauthV2.OAuthV2-ValidateAuthToken.failed}"
              },
              "KVM-GetEnvironmentVariables":{
                "rateLimit":"{rateLimit}",
                "projectNumber":"{projectNumber}",
                "maximoSecretsName":"{maximoSecretsName}",
                "projectId":"{projectId}"
              },
              "Q-ApplyQuota":{
                "failed":"{ratelimit.Q-ApplyQuota.failed}",
                "allowedCount":"{ratelimit.Q-ApplyQuota.allowed.count}",
                "usedCount":"{ratelimit.Q-ApplyQuota.used.count}",
                "remainingCount":"{ratelimit.Q-ApplyQuota.available.count}",
                "identifier":"{ratelimit.Q-ApplyQuota.identifier}"
              },
              "SA-ApplySpikeArrest":{
                "failed":"{ratelimit.SA-ApplySpikeArrest.failed}"
              },
              "SC-CallSecretManagerAPI":{
                "failed":"{servicecallout.SC-CallSecretManagerAPI.failed}",
                "targetUrl":"{servicecallout.SC-CallSecretManagerAPI.target.url}"
              },
              "AM-DecodeSecretValue":{
                "failed":"{assignmessage.AM-DecodeSecretValue.failed}"
              },
              "EV-ExtractSecretValues":{
                "failed":"{extractvariables.EV-ExtractSecretValues.failed}"
              },
              "AM-AssignAPIKeyHeader":{
                "failed":"{assignmessage.AM-AssignAPIKeyHeader.failed}"
              },
              "AM-FormatSuccessResponse":{
                "failed":"{assignmessage.AM-FormatSuccessResponse.failed}"
              }
            },
            "extraDetails":{
              "requestReceivedAtTimestamp":"{client.received.end.timestamp}",
              "responseSentAtTimestamp":"{client.sent.end.timestamp}",
              "targetEndpointName":"{route.target}",
              "routeRuleName":"{route.name}",
              "targetEndpointSentResponseAt":"{target.received.end.time}",
              "targetEndpointSentResponseAtTimestamp":"{target.received.end.timestamp}",
              "targetEndpointReceivedRequestAt":"{target.sent.end.time}",
              "targetEndpointReceivedRequestAt":"{target.sent.end.timestamp}"
            }
          }
        </Message>
        <ResourceType>api</ResourceType>
      </CloudLogging>
      <logLevel>INFO</logLevel>
    </MessageLogging>

I'm assuming debug shows that the underlying request in development was successful, correct (how is this being validated)?

Additionally, how is the {projectId} variable being set (property set), etc. I typically use the organization.name flow variable (noted here: https://cloud.google.com/apigee/docs/api-platform/reference/variables-reference#organization) which is available out of the box - I wonder if that value is coming in as null (which debug would help with)

Thanks!