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.
- Admin API
- ADC
- Ingress Controller
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
Export the complete plugin metadata collection before changing the Loggly entry:
adc dump -o adc-metadata.yaml --with-id \
--include-resource-type plugin_metadata
Add or update the Loggly entry in adc-metadata.yaml while preserving every other metadata entry:
plugin_metadata:
# Preserve every other plugin metadata entry from the exported file.
loggly:
host: logs-01.loggly.com
protocol: https
Create the labeled service separately:
services:
- name: loggly-service
labels:
docs-example: loggly
routes:
- name: loggly-route
uris:
- /anything/loggly
plugins:
loggly:
customer_token: "${LOGGLY_CUSTOMER_TOKEN}"
tags:
- api7-docs
batch_max_size: 1
upstream:
type: roundrobin
nodes:
- host: httpbin.org
port: 80
weight: 1
Preview the complete metadata collection and confirm that the diff contains no unintended updates or deletions:
adc diff -f adc-metadata.yaml \
--include-resource-type plugin_metadata
Review diff.yaml, then synchronize the plugin metadata collection:
adc sync -f adc-metadata.yaml \
--include-resource-type plugin_metadata
Preview the labeled service:
adc diff -f adc.yaml \
--include-resource-type service \
--label-selector docs-example=loggly
Review diff.yaml, then synchronize the service:
adc sync -f adc.yaml \
--include-resource-type service \
--label-selector docs-example=loggly
Add the HTTPS Loggly entry under spec.pluginMetadata in the complete GatewayProxy manifest used by the deployment:
pluginMetadata:
# Preserve every other plugin metadata entry.
loggly:
host: logs-01.loggly.com
protocol: https
Apply the updated complete GatewayProxy manifest through the deployment's normal Kubernetes or GitOps workflow.
Next, attach the plugin to the route with the Kubernetes API used by the deployment:
- Gateway API
- APISIX CRD
apiVersion: v1
kind: Service
metadata:
namespace: aic
name: httpbin-external-domain
spec:
type: ExternalName
externalName: httpbin.org
ports:
- port: 80
---
apiVersion: apisix.apache.org/v1alpha1
kind: PluginConfig
metadata:
namespace: aic
name: loggly-route
spec:
plugins:
- name: loggly
config:
customer_token: replace-with-customer-token
tags:
- api7-docs
batch_max_size: 1
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
namespace: aic
name: loggly-route
spec:
parentRefs:
- name: apisix
rules:
- matches:
- path:
type: Exact
value: /anything/loggly
filters:
- type: ExtensionRef
extensionRef:
group: apisix.apache.org
kind: PluginConfig
name: loggly-route
backendRefs:
- name: httpbin-external-domain
port: 80
apiVersion: v1
kind: Service
metadata:
namespace: aic
name: httpbin-external-domain
spec:
type: ExternalName
externalName: httpbin.org
ports:
- port: 80
---
apiVersion: apisix.apache.org/v2
kind: ApisixPluginConfig
metadata:
namespace: aic
name: loggly-route
spec:
ingressClassName: apisix
plugins:
- name: loggly
enable: true
config:
customer_token: replace-with-customer-token
tags:
- api7-docs
batch_max_size: 1
---
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
namespace: aic
name: loggly-route
spec:
ingressClassName: apisix
http:
- name: loggly-route
match:
paths:
- /anything/loggly
backends:
- serviceName: httpbin-external-domain
servicePort: 80
plugin_config_name: loggly-route
Apply the route configuration:
kubectl apply -f loggly-ic.yaml
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.
- Admin API
- ADC
- Ingress Controller
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"
}
}'
In the complete plugin metadata collection used by the deployment, replace the Loggly entry:
plugin_metadata:
# Preserve every other plugin metadata entry.
loggly:
host: logs-01.loggly.com
protocol: https
log_format_extra:
request_method: $request_method
request_uri: $request_uri
response_status: $status
Preview the complete metadata change and confirm that it contains no unintended updates or deletions:
adc diff -f adc-metadata.yaml \
--include-resource-type plugin_metadata
Review diff.yaml, then synchronize the plugin metadata collection:
adc sync -f adc-metadata.yaml \
--include-resource-type plugin_metadata
Replace the Loggly entry under spec.pluginMetadata in the complete GatewayProxy manifest used by the deployment:
pluginMetadata:
# Preserve every other plugin metadata entry.
loggly:
host: logs-01.loggly.com
protocol: https
log_format_extra:
request_method: $request_method
request_uri: $request_uri
response_status: $status
Apply the updated complete manifest through the deployment's normal Kubernetes or GitOps workflow.
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
}