Skip to content
Latest (currently 2026.10.2) has the newest features, bug fixes, and CVE patches of Solo Enterprise for agentgateway.

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

Page as Markdown

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

  1. Set up an agentgateway proxy.
  2. Install the management UI for Solo Enterprise for agentgateway. The management UI includes the built-in telemetry stack. The enterprise-agentgateway-ui-telemetry-collector accepts OTLP logs on port 4317 and 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
EOF

Access 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.

  1. Send a request to the httpbin app on the www.example.com domain.

    curl -i http://$INGRESS_GW_ADDRESS:80/get -H "host: www.example.com"
    curl -i localhost:8080/get -H "host: www.example.com"
  2. 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)
  3. 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}
  4. Query the access log table. The following examples show common queries. Log fields are stored in the LogAttributes column 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 the http.status field from the stdout log. Other renamed fields include server.address for http.host, url.path for http.path, and http.request.method for http.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.

  1. Update the EnterpriseAgentgatewayPolicy resource to add an otlp.filter expression. 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'
    EOF
  2. Send 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"
  3. 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"
  4. 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}
  5. Query the access log table. The following examples show common queries. Log fields are stored in the LogAttributes column 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"}} │
    ...
    
  6. Check the proxy logs and verify that both requests appear in stdout. The otlp.filter expression 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 -2

    Example 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.

  1. Update the EnterpriseAgentgatewayPolicy to add an otlp.attributes configuration. In this example, you add a trace_id field from the x-trace-id request header and remove the request host from OTLP exports. In the OTLP export, the host is the server.address field, so you remove server.address, not the http.host name from the stdout log. Because no top-level accessLog.attributes are 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
    EOF
  2. Send a request through agentgateway with the x-trace-id header.

    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"
  3. Check the agentgateway proxy logs and verify that http.host still appears in stdout and that you do not see the trace_id field, because the otlp.attributes field 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=2ms
    
  4. Check the collector logs. Verify that the trace_id field appears with the value from the request header and that the server.address field is not present because it was removed by the otlp.attributes.remove configuration.

    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