CR Telemetry

  • An optional Telemetry CR can be created to configure different telemetry aspects:
  • Access log

General tips for working with CRs

  • CLI:
  • Use kubectl explain <replace with CRD name> --recursive to list all available options and the YAML structure.
  • Check the CRD description texts with kubectl explain <replace with CRD name and path> of the available options for more details.
  • API Reference documentation:
  • Click on the link to open the CR-related documentation in a new browser tab or window: CRD Reference documentation. See also the API Reference documentation links at the end article.

Access log

Airlock Microgateway includes a default access log configuration sufficient for most use cases.

Nevertheless, it is possible to customize the access log format using the Envoy format dictionary style. Both standard Envoy command operators and Airlock Microgateway custom command operators may be used in the configuration.

The CR Telemetry reference documentation contains the default access log configuration. It can be used as a starting point for customization.

Example:

copy
apiVersion: microgateway.airlock.com/v1alpha1 
kind: Telemetry 
metadata: 
  name: example-telemetry
spec: 
  logging: 
    accessLog: 
      format: 
        json: 
          '@timestamp': '%START_TIME(%Y-%m-%dT%H:%M:%S.%fZ)%' 
          log: 
            level: info 
            logger: access 
          request:
            protocol: '%PROTOCOL%'  
          ... 

Following our example settings, a formatted log message for a request looks like this:

{
  "@timestamp": "2023-01-06T13:45:20.146204824Z",
  "log": {
    "level": "info",
    "logger": "access"
  },
  "request": {
    "protocol": "HTTP/1.1"
  }
}

The different log types, such as access or application logs, can be printed using the kubectl logs as mixed output. You may filter the printed logs according to your needs for better orientation.

  • Use kubectl logs <POD> -c airlock-microgateway-engine to print the logs for the engine container in a pod. For more options, see kubectl logs reference.
  • Use grep <query> to filter the log-message output according to your requirements.
  • With the jq-JSON processor (or equivalent) installed, you may pipe the logs output to the processor for better formatting and readability. See JQ for further information.

See also the API Reference documentation link at the end of this article.

Reference in CR SidecarGateway

The CR Telemetry has to be referenced in the CR SidecarGateway.

copy
apiVersion: microgateway.airlock.com/v1alpha1  
kind: SidecarGateway  
metadata:  
  name: example-backend 
spec: 
  podSelector: 
    matchLabels: 
      app: example-backend 
  applications: 
    - containerPort: 80 
      telemetryRef: 
        name: example-telemetry
...

Replace the name in our example with the actual name from the metadata section of the respective Telemetry CR.

See also the API Reference documentation link at the end of this article.