For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Export logs to ClickHouse
Export agentgateway access logs as OTLP LogRecord objects to the enterprise telemetry collector for storage in ClickHouse.
By default, agentgateway writes access logs to stdout only. When you configure access log export, each log record is also sent to the enterprise telemetry collector and stored in ClickHouse, where you can query access logs directly.
Before you begin
- Set up an agentgateway proxy.
- Install the management UI for Solo Enterprise for agentgateway. The management UI includes the built-in telemetry stack. The
enterprise-agentgateway-ui-telemetry-collectoraccepts OTLP logs on port4317and automatically routes them to ClickHouse.
Configure access log export to ClickHouse
Create an EnterpriseAgentgatewayPolicy resource that points the agentgateway proxy at the enterprise telemetry collector for access logs.
kubectl apply -f- <<EOF
apiVersion: enterpriseagentgateway.solo.io/v1alpha1
kind: EnterpriseAgentgatewayPolicy
metadata:
name: access-logs
namespace: agentgateway-system
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: agentgateway-proxy
frontend:
accessLog:
otlp:
backendRef:
name: enterprise-agentgateway-ui-telemetry-collector
namespace: agentgateway-system
kind: Service
port: 4317
protocol: GRPC
EOFAccess logs in ClickHouse
After sending traffic through the gateway, query ClickHouse to confirm that log records arrive. Access logs are stored in the agentgateway.otel_logs_json table in ClickHouse.
Send a request to the httpbin app on the
www.example.comdomain.curl -i http://$INGRESS_GW_ADDRESS:80/get -H "host: www.example.com"curl -i localhost:8080/get -H "host: www.example.com"Get the ClickHouse credentials.
export CH_USER=$(kubectl get secret enterprise-agentgateway-clickhouse-auth -n agentgateway-system -o jsonpath='{.data.username}' | base64 -d) export CH_PASS=$(kubectl get secret enterprise-agentgateway-clickhouse-auth -n agentgateway-system -o jsonpath='{.data.password}' | base64 -d)Open a shell in the ClickHouse pod.
kubectl exec -it -n agentgateway-system enterprise-agentgateway-clickhouse-shard0-0 -- \ clickhouse-client --user ${CH_USER} --password ${CH_PASS}Query the access log table. The following examples show common queries. Log fields are stored in the
LogAttributescolumn as nested JSON.View the most recent log entries.
SELECT Timestamp, LogAttributes FROM agentgateway.otel_logs_json ORDER BY Timestamp DESC LIMIT 10;Filter by HTTP status code. The OTLP export uses OpenTelemetry semantic convention names, so the status code is stored as
http.response.status_code, not as thehttp.statusfield from the stdout log. Other renamed fields includeserver.addressforhttp.host,url.pathforhttp.path, andhttp.request.methodforhttp.method.SELECT Timestamp, LogAttributes FROM agentgateway.otel_logs_json WHERE JSONExtractInt(LogAttributes, 'http', 'response', 'status_code') >= 400 ORDER BY Timestamp DESC LIMIT 20;Filter by LLM provider.
SELECT Timestamp, LogAttributes FROM agentgateway.otel_logs_json WHERE JSONExtractString(LogAttributes, 'gen_ai', 'provider', 'name') = 'openai' ORDER BY Timestamp DESC LIMIT 20;
Filter logs before export
You can filter which access logs are exported to ClickHouse independently of what is written to stdout by using the otlp.filter field. This field determines the logs that are sent to the enterprise OTel collector and forwarded to ClickHouse. When otlp.filter is not set, the top-level accessLog.filter setting is used as a fallback for the OTLP export as well. When otlp.filter is set, it takes precedence over the top-level filter for the OTLP export only, so stdout and ClickHouse can each receive a different subset of logs.
Update the EnterpriseAgentgatewayPolicy resource to add an
otlp.filterexpression. In this example, you want to send only error responses to the OTLP collector. However, you continue to log all requests to stdout.kubectl apply -f- <<EOF apiVersion: enterpriseagentgateway.solo.io/v1alpha1 kind: EnterpriseAgentgatewayPolicy metadata: name: access-logs namespace: agentgateway-system spec: targetRefs: - group: gateway.networking.k8s.io kind: Gateway name: agentgateway-proxy frontend: accessLog: otlp: backendRef: name: enterprise-agentgateway-ui-telemetry-collector namespace: agentgateway-system port: 4317 protocol: GRPC filter: 'response.code >= 400' EOFSend a successful request through agentgateway.
curl -i http://$INGRESS_GW_ADDRESS:80/get -H "host: www.example.com"curl -i localhost:8080/get -H "host: www.example.com"Send a request that returns an error response.
curl -i http://$INGRESS_GW_ADDRESS:80/status/500 -H "host: www.example.com"curl -i localhost:8080/status/500 -H "host: www.example.com"Open a shell in the ClickHouse pod.
kubectl exec -it -n agentgateway-system enterprise-agentgateway-clickhouse-shard0-0 -- \ clickhouse-client --user ${CH_USER} --password ${CH_PASS}Query the access log table. The following examples show common queries. Log fields are stored in the
LogAttributescolumn as nested JSON.View the most recent log entries.
SELECT Timestamp, LogAttributes FROM agentgateway.otel_logs_json ORDER BY Timestamp DESC LIMIT 10;Example output:
... Query id: b4f36e8f-f710-445f-847f-e068c5d721ba ┌─────────────────────Timestamp─┬─LogAttributes──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ 1. │ 2026-09-01 20:45:58.081952253 │ {"client":{"address":"127.0.0.1"},"duration":"1ms","endpoint":"10.244.0.14:8080","gateway":"agentgateway-system\/agentgateway-proxy","http":{"request":{"method":"GET"},"response":{"status_code":500}},"listener":"http","network":{"protocol":{"version":"1.1"}},"protocol":"http","route":"httpbin\/httpbin","server":{"address":"www.example.com"},"span":{"id":"edefb5b67ea459dc"},"trace":{"id":"e0f75a81ead17c8cfbadbcc46a46a84c"},"url":{"path":"\/status\/500"}} │ ...Check the proxy logs and verify that both requests appear in stdout. The
otlp.filterexpression only controls what is exported to the collector. The stdout stream continues to receive all access log entries regardless of the filter.kubectl -n agentgateway-system logs deployments/agentgateway-proxy | tail -2Example output:
info request ... http.path=/get http.version=HTTP/1.1 http.status=200 protocol=http duration=0ms info request ... http.path=/status/500 http.version=HTTP/1.1 http.status=500 protocol=http duration=0ms
Tip
To send all requests to the OTLP collector while restricting stdout to errors only, set otlp.filter: 'true' and add a top-level filter for stdout:
frontend:
accessLog:
filter: 'response.code >= 400'
otlp:
backendRef:
name: enterprise-agentgateway-ui-telemetry-collector
namespace: agentgateway-system
port: 4317
protocol: GRPC
filter: 'true'Customize exported fields
You can customize which fields are exported over OTLP independently of what is written to stdout by using the otlp.attributes field. If the otlp.attributes section is set, it replaces any custom attributes that you set for the stdout stream in the accessLog.attributes section. This setup allows you to add specific fields to your stdout output, and to log a different set of fields when you export the access logs via OTLP.
Note
If you do not set custom OTLP attributes, but you set custom fields via the top-level accessLog.attributes section, the accessLog.attributes are also applied to the OTLP export. If you do not want the top-level attributes to also apply in your OTLP export, overwrite them or remove them in the otlp.attributes section.
Update the EnterpriseAgentgatewayPolicy to add an
otlp.attributesconfiguration. In this example, you add atrace_idfield from thex-trace-idrequest header and remove the request host from OTLP exports. In the OTLP export, the host is theserver.addressfield, so you removeserver.address, not thehttp.hostname from the stdout log. Because no top-levelaccessLog.attributesare defined, the access log output for stdout remains unchanged.kubectl apply -f- <<EOF apiVersion: enterpriseagentgateway.solo.io/v1alpha1 kind: EnterpriseAgentgatewayPolicy metadata: name: access-logs namespace: agentgateway-system spec: targetRefs: - group: gateway.networking.k8s.io kind: Gateway name: agentgateway-proxy frontend: accessLog: otlp: backendRef: name: enterprise-agentgateway-ui-telemetry-collector namespace: agentgateway-system port: 4317 protocol: GRPC attributes: add: - name: trace_id expression: 'request.headers["x-trace-id"]' remove: - server.address EOFSend a request through agentgateway with the
x-trace-idheader.curl -i http://$INGRESS_GW_ADDRESS:80/get -H "host: www.example.com" -H "x-trace-id: abc123"curl -i localhost:8080/get -H "host: www.example.com" -H "x-trace-id: abc123"Check the agentgateway proxy logs and verify that
http.hoststill appears in stdout and that you do not see thetrace_idfield, because theotlp.attributesfield only affects the OTLP export.kubectl logs deploy/agentgateway-proxy -n agentgateway-system | grep "http.host"Example output:
2026-08-27T19:46:25.383591Z info request gateway=agentgateway-system/agentgateway-proxy listener=http route=httpbin/httpbin endpoint=10.244.0.7:8080 src.addr=127.0.0.1:52632 http.method=GET http.host=www.example.com http.path=/get http.version=HTTP/1.1 http.status=200 protocol=http duration=2msCheck the collector logs. Verify that the
trace_idfield appears with the value from the request header and that theserver.addressfield is not present because it was removed by theotlp.attributes.removeconfiguration.kubectl logs deploy/opentelemetry-collector-logs -n telemetry | grep -A 20 "LogRecord"Example output:
LogRecord #0 ... Attributes: -> gateway: Str(agentgateway-system/agentgateway-proxy) -> listener: Str(http) -> route: Str(httpbin/httpbin) -> http.request.method: Str(GET) -> url.path: Str(/get) -> http.response.status_code: Int(200) -> trace_id: Str(abc123)
Cleanup
Delete the EnterpriseAgentgatewayPolicy resource.
kubectl delete EnterpriseAgentgatewayPolicy access-logs -n agentgateway-system