The AutoInstrumentation Custom Resource is the primary configuration interface for defining:
  • Which pods to instrument (selectors)
  • How to instrument them (provider, packages, environment)
  • Where to send telemetry data (OTLP configuration)
  • What attributes to include (resource attributes)

Resource Structure

Basic Structure

apiVersion: openlit.io/v1alpha1
kind: AutoInstrumentation
metadata:
  name: example-instrumentation
  namespace: default
spec:
  selector: {}           # Pod selection criteria
  ignore: {}             # Pods to ignore  
  python: {}             # Python instrumentation config
  otlp: {}               # OTLP endpoint configuration
  resource: {}           # Resource attributes
status: {}               # Resource status (read-only)

Pod Selection Configuration

Configure which pods should be instrumented using label selectors.

Selector Parameters

ParameterTypeDescriptionDefaultExample
spec.selectorLabelSelectorPods to instrumentRequiredSee examples below
spec.selector.matchLabelsmap[string]stringExact label matches{}{"app": "chatbot"}
spec.selector.matchExpressions[]LabelSelectorRequirementExpression-based matching[]See expressions table

Match Expressions

FieldTypeDescriptionValuesExample
keystringLabel key to matchAny label key"environment"
operatorstringMatching operatorIn, NotIn, Exists, DoesNotExist"In"
values[]stringValues to match (for In/NotIn)List of strings["prod", "staging"]
# Basic label matching
spec:
  selector:
    matchLabels:
      openlit.io/instrument: "true"
      app: "ai-chatbot"
      environment: "production"

# Advanced expression matching  
spec:
  selector:
    matchExpressions:
    - key: "environment"
      operator: In
      values: ["production", "staging"]
    - key: "ai-framework"
      operator: Exists
    - key: "legacy-app"
      operator: DoesNotExist

# Combined matching
spec:
  selector:
    matchLabels:
      team: "ai-platform"
    matchExpressions:
    - key: "version"
      operator: In
      values: ["v2", "v3"]
    - key: "experimental"
      operator: DoesNotExist

Ignore Configuration

ParameterTypeDescriptionDefaultExample
spec.ignoreLabelSelectorPods to skip even if they match selector{}See example
spec.ignore.matchLabelsmap[string]stringExact label matches to ignore{}{"debug": "true"}
spec.ignore.matchExpressions[]LabelSelectorRequirementExpression-based ignoring[]System pods
# Basic ignore configuration
spec:
  ignore:
    matchLabels:
      openlit.io/skip: "true"
      system-component: "true"
      debug-mode: "enabled"

# Advanced ignore with expressions
spec:
  ignore:
    matchLabels:
      team: "infrastructure"
    matchExpressions:
    - key: "debug-mode"
      operator: Exists
    - key: "monitoring-type"
      operator: In
      values: ["system", "infrastructure"]
    - key: "instrumentation-exempt"
      operator: Exists

# Ignore test and development pods
spec:
  ignore:
    matchExpressions:
    - key: "environment"
      operator: In
      values: ["test", "dev", "local"]
    - key: "app.kubernetes.io/component"
      operator: In
      values: ["test", "debug", "proxy"]

Python Instrumentation Configuration

Configure Python-specific instrumentation settings.

Instrumentation Parameters

ParameterTypeDescriptionDefaultExample
spec.python.instrumentation.enabledboolEnable Python instrumentationtruefalse
spec.python.instrumentation.providerstringInstrumentation provider"openlit""openinference"
spec.python.instrumentation.versionstringProvider version"latest""v1.0.0"
spec.python.instrumentation.customInitImagestringCustom init container image"""custom-registry.com/openlit:v1.0"
spec.python.instrumentation.imagePullPolicystringImage pull policy"IfNotPresent""Always"
spec.python.instrumentation.customPackagesstringAdditional pip packages"""langchain>=0.1.0,chromadb>=0.4.0"

Supported Providers

ProviderDescriptionUse CaseImage Repository
"openlit"Full OpenLIT instrumentationComplete AI observabilityghcr.io/openlit/openlit-ai-instrumentation
"openinference"OpenInference standardOpenTelemetry standard complianceghcr.io/openlit/openinference-ai-instrumentation
"openllmetry"OpenLLMetry instrumentationLLM-focused observabilityghcr.io/openlit/openllmetry-ai-instrumentation
"custom"Custom instrumentationCustom implementationUser-defined via customInitImage
# OpenLIT provider with custom packages
spec:
  python:
    instrumentation:
      enabled: true
      provider: "openlit"
      version: "latest"
      imagePullPolicy: "IfNotPresent"
      customPackages: "langchain>=0.1.0,chromadb>=0.4.0,numpy==1.21.0"

# OpenInference provider with specific version
spec:
  python:
    instrumentation:
      enabled: true
      provider: "openinference"
      version: "v0.5.0"
      imagePullPolicy: "Always"

# OpenLLMetry provider 
spec:
  python:
    instrumentation:
      enabled: true
      provider: "openllmetry"
      version: "v1.2.0"
      customPackages: "openai>=1.0.0,anthropic>=0.8.0"

# Custom provider with private registry
spec:
  python:
    instrumentation:
      enabled: true
      provider: "custom"
      customInitImage: "my-registry.com/custom-openlit:v2.0.0"
      imagePullPolicy: "Always"
      customPackages: "my-custom-package>=1.0.0"

# Disabled instrumentation
spec:
  python:
    instrumentation:
      enabled: false

Environment Variables

ParameterTypeDescriptionDefaultExample
spec.python.instrumentation.env[]EnvVarEnvironment variables for instrumented containers[]See examples
spec.python.instrumentation.env[].namestringEnvironment variable nameRequired"OPENLIT_API_KEY"
spec.python.instrumentation.env[].valuestringDirect value"""debug-mode"
spec.python.instrumentation.env[].valueFromEnvVarSourceValue from external sourcenilSecret/ConfigMap reference

Environment Variable Sources

Source TypeFieldDescriptionExample
secretKeyRefname, keyValue from Kubernetes Secret{name: "openlit-secret", key: "api-key"}
configMapKeyRefname, keyValue from ConfigMap{name: "openlit-config", key: "endpoint"}
fieldReffieldPathValue from pod/container field{fieldPath: "metadata.name"}
resourceFieldRefresourceValue from resource field{resource: "requests.cpu"}
spec:
  python:
    instrumentation:
      env:
      # Direct value
      - name: OPENLIT_DEBUG
        value: "true"
      - name: OPENLIT_ENVIRONMENT
        value: "production"
      
      # From secret
      - name: OPENLIT_API_KEY
        valueFrom:
          secretKeyRef:
            name: openlit-secret
            key: api-key
      - name: DATABASE_PASSWORD
        valueFrom:
          secretKeyRef:
            name: db-credentials
            key: password
      
      # From configmap
      - name: OPENLIT_ENDPOINT
        valueFrom:
          configMapKeyRef:
            name: openlit-config
            key: otlp-endpoint
      - name: LOG_LEVEL
        valueFrom:
          configMapKeyRef:
            name: app-config
            key: log-level
      
      # From pod metadata
      - name: POD_NAME
        valueFrom:
          fieldRef:
            fieldPath: metadata.name
      - name: POD_NAMESPACE
        valueFrom:
          fieldRef:
            fieldPath: metadata.namespace
      - name: NODE_NAME
        valueFrom:
          fieldRef:
            fieldPath: spec.nodeName
      
      # From resource requests/limits
      - name: CPU_REQUEST
        valueFrom:
          resourceFieldRef:
            resource: requests.cpu
      - name: MEMORY_LIMIT
        valueFrom:
          resourceFieldRef:
            resource: limits.memory

OTLP Configuration

Configure OpenTelemetry Protocol (OTLP) endpoint settings.

OTLP Parameters

ParameterTypeDescriptionDefaultExampleValidation
spec.otlp.endpointstringOTLP endpoint URLRequired"http://openlit:4318"Valid HTTP/HTTPS URL
spec.otlp.headersstringHTTP headers (comma-separated)"""authorization=Bearer token123"key=value format
spec.otlp.timeoutintRequest timeout in seconds30601-300 seconds

Endpoint Formats

FormatDescriptionExampleUse Case
Internal ServiceKubernetes service referencehttp://openlit:4318Same cluster deployment
Fully QualifiedFull service DNS namehttp://openlit.openlit.svc.cluster.local:4318Cross-namespace access
External HTTPSExternal secure endpointhttps://traces.example.com:4318Cloud/external services
Load BalancerLoad balancer endpointhttp://otlp-lb.company.com:4318High availability setup

Headers Format

Headers should be comma-separated key=value pairs:
Header TypeFormatExampleUse Case
Authorizationauthorization=Bearer <token>"authorization=Bearer abc123"API authentication
API Keyx-api-key=<key>"x-api-key=secret456"API key authentication
Multiple Headerskey1=val1,key2=val2"auth=token,x-trace-id=123"Multiple authentication
URL EncodedURL-encoded special chars"auth=Bearer%20token"Special characters
# Basic OTLP configuration
spec:
  otlp:
    endpoint: "http://openlit:4318"
    timeout: 30

# With authentication headers
spec:
  otlp:
    endpoint: "https://traces.example.com:4318"
    headers: "authorization=Bearer token123,x-api-key=secret456"
    timeout: 60

# Internal service with FQDN
spec:
  otlp:
    endpoint: "http://openlit.openlit.svc.cluster.local:4318"
    timeout: 45

# External SaaS provider
spec:
  otlp:
    endpoint: "https://otlp.company.datadog.com:443"
    headers: "DD-API-KEY=your-api-key,DD-APP-KEY=your-app-key"
    timeout: 30

# Load balancer with custom headers
spec:
  otlp:
    endpoint: "http://otlp-lb.company.com:4318"
    headers: "x-tenant-id=production,authorization=Bearer jwt-token"
    timeout: 120

# Local development
spec:
  otlp:
    endpoint: "http://localhost:4318"
    timeout: 10

Resource Attributes

Configure resource attributes that will be added to all telemetry data.

Resource Parameters

ParameterTypeDescriptionDefaultExampleOpenTelemetry Mapping
spec.resource.environmentstringDeployment environment"""production"deployment.environment
spec.resource.serviceNamestringService name override"""ai-chat-service"service.name
spec.resource.serviceNamespacestringService namespace"""ai-platform"service.namespace
spec.resource.serviceVersionstringService version"""v2.1.0"service.version

Automatic Attributes

The operator automatically sets these attributes (cannot be overridden):
AttributeSourceExampleDescription
k8s.pod.namePod metadata"chatbot-abc123"Kubernetes pod name
k8s.namespace.namePod namespace"production"Kubernetes namespace
k8s.deployment.nameOwner reference"ai-chatbot"Deployment name (if applicable)
k8s.replicaset.nameOwner reference"ai-chatbot-xyz789"ReplicaSet name (if applicable)
k8s.node.namePod spec"worker-node-1"Node where pod is running
# Basic resource attributes
spec:
  resource:
    environment: "production"
    serviceName: "customer-support-ai"
    serviceNamespace: "ai-platform"
    serviceVersion: "v2.1.0"

# Environment-specific configuration
spec:
  resource:
    environment: "staging"
    serviceName: "experiment-chatbot"
    serviceNamespace: "research"
    serviceVersion: "v1.0.0-beta"

# Microservice with detailed attributes
spec:
  resource:
    environment: "production"
    serviceName: "recommendation-engine"
    serviceNamespace: "ml-services"
    serviceVersion: "v3.2.1"

# Development environment
spec:
  resource:
    environment: "development"
    serviceName: "local-test-app"
    serviceNamespace: "dev-testing"
    serviceVersion: "latest"

# Multi-tenant service
spec:
  resource:
    environment: "production"
    serviceName: "tenant-ai-service"
    serviceNamespace: "multi-tenant"
    serviceVersion: "v1.5.2"