How to log message into loggly

2 3 1,809

Apigee Edge Management platform has introduced a feature in cloud release "160330_01", whereby we can log message into loggly server using MessageLogging policy in a format required by loggly server. This can be achieved with the help of a new flag "FormatMessage" introduced, which should be set to true. The documentation is avaliable here:

Here's an example of message-logging policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MessageLogging async="false" continueOnError="false" enabled="true" name="Message-Logging-1">
    <DisplayName>Message Logging-1</DisplayName>
    <Syslog>
        <Message>[{loggly-token}@41058 tag="apigee-edge" tag="{apiproxy.name}"] Sample Log Message</Message>
        <Host>logs-01.loggly.com</Host>
        <Port>514</Port>
        <FormatMessage>true</FormatMessage>
    </Syslog>
</MessageLogging>

In above example, we have to set "loggly-token" value to unique loggly account token for each loggly account. After sending message, we will notice that apigee message has been tagged under "apiproxy" name and "apigee-edge" in loggly UI. With this feature change, we no longer prefix "loggly" tokens in raw message of loggly. Attaching the loggly UI screenshot.

2507-screen-shot-2016-04-21-at-12509-pm.png

Sample bundle has been attached. loggly-sample.zip

Comments
cladius_fernand
New Member

Thanks for adding this feature. Now I am able to push valid JSON messages into Loggly and thus make use of Loggly's attribute search and in-built analytics (which was previously not possible).

Not applicable

How do I send JSON data in the <Message> tag?

I have tried this:

<Message>[key@41058 tag="{organization.name}.{apiproxy.name}.{environment.name}"] {message.content, message.headers.names}</Message>

And in Loggly, the message is {message.content, message.headers.names}

If I send only one variable, it works:

<Message>[key@41058 tag="{organization.name}.{apiproxy.name}.{environment.name}"] {message.content}</Message>

What am I missing here?

Not applicable

@Daniel Gerep Apigee edge will try to resolve the variables present within the braces "{}".

In first case, edge is not able to resolve variable "message.content, message.headers.names".

In second case, edge returned the message payload after resolving the variable "message.content". So, second scenario worked.

In order to log an JSON payload, we need to change the variable prefix and suffix as mentioned below:

<Message variablePrefix="%" variableSuffix="#">[key@41058 tag="%organization.name#.%apiproxy.name#.%environment.name#"] { %message.content#, %message.headers.names# }</Message>

In this scenario, edge will try to resolve variables present within "%" and "#".

Version history
Last update:
‎04-21-2016 01:52 AM
Updated by: