Skip to main content

Loggly

The loggly plugin sends gateway request and response logs to SolarWinds Loggly for search and analysis. HTTPS bulk delivery provides authenticated, acknowledged transport and is the recommended production path.

The optional Syslog path uses UDP and cannot verify provider receipt or retransmit packets dropped after the local send succeeds.

Examples​

The examples send default logs through HTTPS and add selected fields.

You do not deploy Loggly for this example. The gateway sends events to SolarWinds Loggly's hosted HTTPS bulk endpoint. Ensure that every gateway can reach logs-01.loggly.com over HTTPS on port 443. Sign in to Loggly, then from Source Setup → Customer Tokens, copy a customer token:

export LOGGLY_CUSTOMER_TOKEN="replace-with-customer-token"

Treat the customer token as a secret, and restrict access to both the token and the Loggly data.

Send Logs through HTTPS​

Configure Loggly plugin metadata for HTTPS delivery, then configure the route logger.

curl "http://127.0.0.1:9180/apisix/admin/plugin_metadata/loggly" -X PUT \
-H "X-API-KEY: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"host": "logs-01.loggly.com",
"protocol": "https"
}'

curl "http://127.0.0.1:9180/apisix/admin/routes/loggly-route" -X PUT \
-H "X-API-KEY: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"uri": "/anything/loggly",
"plugins": {
"loggly": {
"customer_token": "${LOGGLY_CUSTOMER_TOKEN}",
"tags": [
"api7-docs"
],
"batch_max_size": 1
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
}
}
}
EOF

Send a request, then search Loggly for tag:api7-docs. Indexing can take a few minutes.

curl "http://127.0.0.1:9080/anything/loggly"

The event should include:

{
"route_id": "loggly-route",
"request": {
"method": "GET",
"uri": "/anything/loggly"
},
"response": {
"status": 200
}
}

Add Selected Fields​

Update the Loggly plugin metadata to add selected fields to the default log entry. The log_format_extra object enriches the default entry; use log_format instead to replace the default entry with selected fields.

Avoid sending sensitive values to Loggly.

Replace the existing metadata with the delivery settings and focused fields:

curl "http://127.0.0.1:9180/apisix/admin/plugin_metadata/loggly" -X PUT \
-H "X-API-KEY: ${ADMIN_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"host": "logs-01.loggly.com",
"protocol": "https",
"log_format_extra": {
"request_method": "$request_method",
"request_uri": "$request_uri",
"response_status": "$status"
}
}'

Send another request and search Loggly for tag:api7-docs:

curl "http://127.0.0.1:9080/anything/loggly"

The new event should contain the selected fields alongside the default entry:

{
"request_method": "GET",
"request_uri": "/anything/loggly",
"response_status": 200
}