Faberby FaberOps

Kubernetes OOMKill and CrashLoop Signature

Matches containers killed by the kernel OOM killer or stuck in CrashLoopBackOff, plus runtime heap exhaustion lines that precede an OOMKill.

Kind
Signature
Version
2.0.0
Tier
verified
Needs Faber
v2.0.0+
Digest prefix
sha256:7be74c17

Contract facts

Sources
4
kubernetes, loki, prometheus, victorialogs
Log patterns
6
RE2, replayed in CI
Kubernetes matchers
2
CEL on live objects
Samples
5 and 3
must match and must not

Inspect it

Inspect the contract and RBAC delta

$ faberctl catalog inspect signatures/k8s-oom-crashloop \ --source oci://ghcr.io/faberops/catalog:v2

How it works

  • Sources: kubernetes, loki, prometheus, victorialogs
  • Log patterns: 6 RE2 expressions, each proven by the samples.match and samples.noMatch lines that catalog CI replays
  • Ready queries: victorialogs, loki, promql

Use from a Playbook

Reference the pack by name from a connector trigger:

YAML7 lines
triggers:
  - name: signature-hit
    connector:
      connectorType: loki
      signaturePack: k8s-oom-crashloop
      window: 10m
      minMatches: 3

Signatures only describe what to look for. They never grant a Playbook any permission or action.

What it matches

Must match

  • Last State: Terminated Reason: OOMKilled Exit Code: 137
  • Memory cgroup out of memory: Killed process 4121 (java)
  • Warning BackOff kubelet Back-off restarting failed container api in pod api-7f9c
  • Exception in thread main java.lang.OutOfMemoryError: Java heap space
  • FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Must not match

  • Started container api
  • Readiness probe succeeded
  • GC pause 12ms heap 210MiB of 512MiB

Signature source

signature.yamlFailureSignature40 lines
apiVersion: catalog.faberops.dev/v2
kind: FailureSignature
metadata:
  name: k8s-oom-crashloop
spec:
  description: Matches containers killed by the kernel OOM killer or stuck in CrashLoopBackOff, plus runtime heap exhaustion lines that precede an OOMKill.
  sources:
    - kubernetes
    - loki
    - prometheus
    - victorialogs
  logPatterns:
    - '(?i)\bOOMKilled\b'
    - '(?i)Memory cgroup out of memory'
    - '(?i)Back-off restarting failed container'
    - 'java\.lang\.OutOfMemoryError'
    - '(?i)JavaScript heap out of memory'
    - '(?i)fatal error: runtime: out of memory'
  queries:
    victorialogs: '("OOMKilled" OR "Memory cgroup out of memory" OR "Back-off restarting failed container" OR "OutOfMemoryError")'
    loki: '{namespace=~".+"} |~ "(?i)(OOMKilled|Memory cgroup out of memory|Back-off restarting failed container|OutOfMemoryError)"'
    promql: 'increase(kube_pod_container_status_restarts_total[15m]) > 2 and on (namespace, pod, container) kube_pod_container_status_last_terminated_reason{reason="OOMKilled"} == 1'
  kubernetes:
    - apiVersion: v1
      kind: Pod
      match: 'has(object.status.containerStatuses) && object.status.containerStatuses.exists(c, has(c.lastState.terminated) && c.lastState.terminated.reason == "OOMKilled")'
    - apiVersion: v1
      kind: Pod
      match: 'has(object.status.containerStatuses) && object.status.containerStatuses.exists(c, has(c.state.waiting) && c.state.waiting.reason == "CrashLoopBackOff")'
  samples:
    match:
      - 'Last State: Terminated Reason: OOMKilled Exit Code: 137'
      - 'Memory cgroup out of memory: Killed process 4121 (java)'
      - 'Warning BackOff kubelet Back-off restarting failed container api in pod api-7f9c'
      - 'Exception in thread main java.lang.OutOfMemoryError: Java heap space'
      - 'FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory'
    noMatch:
      - 'Started container api'
      - 'Readiness probe succeeded'
      - 'GC pause 12ms heap 210MiB of 512MiB'
pack.yamlcatalog metadata11 lines
# Catalog metadata for signatures/k8s-oom-crashloop. Not applied to the cluster.
apiVersion: catalog.faberops.dev/v2
kind: CatalogPack
metadata:
  name: k8s-oom-crashloop
  category: signatures
  version: 2.0.0
spec:
  tier: verified
  minFaberVersion: v2.0.0
  digest: sha256:7be74c17c953802b63fef47378c73d81ddd968eafe9f24aaea2b44810d886566

Signatures are catalog data. A Playbook references one by name in a connector trigger. It is never applied on its own.