dynatrace/dynatrace-for-ai

dt-obs-kubernetes

>- Kubernetes cluster, pod, node, and workload monitoring. Use when analyzing K8s health, resource optimization, pod failures, OOMKills, scheduling, or security posture. Also use for Kubernetes operational events like pod restarts, OOM events, evictions, and cluster event history. "namespace resource usage", "over-provisioned pods", "privileged containers", "pod placement", "K8s node capacity", "running containers by cluster", "workload scheduling", "pod evictions", "K8s labels and annotations"…

All-time #6340 Trending #5341 Hot #5373 First seen Apr 3, 2026
8-week activity · all time api

Installation

$ npx skills add dynatrace/dynatrace-for-ai --skill dt-obs-kubernetes

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from dynatrace/dynatrace-for-ai · top by installs.

npx skills add dynatrace/dynatrace-for-ai

Browse all from dynatrace/dynatrace-for-ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 135
License LICENSE
Default branch main
Open issues 7
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

LicenseApache-2.0

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 17,493 B
  • docs SUMMARY.md 902 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1,925 installs

SKILL.md

Infrastructure Kubernetes

Monitor and analyze Kubernetes infrastructure using Dynatrace DQL. Query cluster resources, monitor workload health, analyze pod placement, optimize costs, and assess security posture.

When to Use This Skill

  • Monitoring Kubernetes cluster health and capacity
  • Analyzing pod and container resource utilization
  • Investigating pod failures, OOMKills, evictions, or crash loops
  • Debugging degraded deployments, stuck rollouts, or node pressure
  • Optimizing Kubernetes resource costs
  • Assessing security posture and compliance
  • Troubleshooting workload scheduling and placement
  • Auditing ingress routing and network policies

Knowledge Base Structure

Core Monitoring (Start Here)

  1. Cluster Inventoryreferences/cluster-inventory.md - Clusters,

namespaces, resource distribution

  1. Node Monitoring - Node capacity, CPU/memory usage, pod density
  2. Pod Monitoring - Pod CPU, memory, lifecycle events
  3. Workload Monitoring - Deployment, StatefulSet, DaemonSet resources

Advanced Topics

  1. Configuration Analysisreferences/labels-annotations.md - Parse

k8s.object, labels, annotations

  1. Scheduling & Placementreferences/pod-node-placement.md - Node

selectors, affinity, taints, HA

  1. Cost Optimization - Right-sizing, waste detection, efficiency scoring
  2. Security & Compliance - Privileged containers, security contexts

Key Concepts

Entity Types

Workloads: K8SDEPLOYMENT, K8SSTATEFULSET, K8SDAEMONSET, K8SJOB, K8SCRONJOB, K8SHORIZONTALPODAUTOSCALER Infrastructure: K8SCLUSTER, K8SNAMESPACE, K8SNODE, K8SPOD Configuration: K8SSERVICE, K8SCONFIGMAP, K8SSECRET, K8SPERSISTENTVOLUMECLAIM, K8SPERSISTENTVOLUME, K8SINGRESS, K8S_NETWORKPOLICY

Query Types

smartscapeNodes - Query K8s entities:

smartscapeNodes K8S_POD
| filter k8s.namespace.name == "production"
| fields k8s.cluster.name, k8s.pod.name

timeseries - Monitor metrics over time:

timeseries cpu = sum(dt.kubernetes.container.cpu_usage),
  by: {k8s.pod.name, k8s.namespace.name}
| fieldsAdd avg_cpu = arrayAvg(cpu)

fetch logs - Analyze log events:

fetch logs
| filter k8s.namespace.name == "production" and loglevel == "ERROR"

Core Fields

  • k8s.cluster.name, k8s.namespace.name, k8s.pod.name, k8s.node.name
  • k8s.workload.name, k8s.workload.kind, k8s.container.name
  • k8s.object - Full JSON configuration for deep inspection
  • tags[label] - Access labels and annotations

Available Metrics

CPU: dt.kubernetes.container.cpuusage, cputhrottled, limitscpu, requestscpu Memory: dt.kubernetes.container.memoryworkingset, limitsmemory, requestsmemory Operations: dt.kubernetes.container.restarts, oomkills Node: dt.kubernetes.node.podsallocatable, cpuallocatable, memoryallocatable, dt.kubernetes.pods

Entity Disambiguation

K8S_POD vs CONTAINER: these are different entity types in Dynatrace.

  • K8S_POD — K8s-native entities with k8s.object JSON, scheduling state, conditions, and K8s metrics. Use this skill.
  • CONTAINER — Host-level container inventory (image, lifetime, host assignment). Use dt-obs-hosts skill instead.

The smartscape edge is CONTAINER --(ispartof)--> K8S_POD. To reach containers from a pod, traverse backward:

```dql-template smartscapeNodes K8SPOD | filter k8s.namespace.name == "<namespace>" | traverse edgeTypes: {ispart_of}, targetTypes: {CONTAINER}, direction: backward, fieldsKeep: {id} | fields k8s.cluster.name, k8s.namespace.name, k8s.pod.name, container.id=id


### Service → K8S_POD Correlation

No direct smartscape edge exists between `SERVICE` and `K8S_POD`. The correlation key is the shared dimension `k8s.workload.name`. See [Service → Pod Drill-Down](references/pod-debugging.md#service--pod-drill-down) in `references/pod-debugging.md` for the full two-step pattern.

## Common Workflows

### 1. Cluster Health Check

List all clusters:

smartscapeNodes K8S_CLUSTER | fields k8s.cluster.name, k8s.cluster.version, k8s.cluster.distribution


Check node capacity:

timeseries { currentpods = avg(dt.kubernetes.pods), maxpods = avg(dt.kubernetes.node.podsallocatable) }, by: {k8s.node.name, k8s.cluster.name} | fieldsAdd podcapacitypct = (arrayAvg(currentpods) / arrayAvg(maxpods)) * 100 | filter podcapacity_pct > 80


Identify pods in non-Running state:

smartscapeNodes K8S_POD | parse k8s.object, "JSON:config" | fieldsAdd phase = config[status][phase] | filter phase != "Running" | fields k8s.cluster.name, k8s.namespace.name, k8s.pod.name, phase


### 2. Resource Optimization

Find over-provisioned pods (usage < 30%):

timeseries { cpuusage = sum(dt.kubernetes.container.cpuusage), cpurequests = avg(dt.kubernetes.container.requestscpu) }, by: {k8s.pod.name, k8s.namespace.name, k8s.cluster.name} | fieldsAdd usagepct = (arrayAvg(cpuusage) / arrayAvg(cpurequests)) * 100 | filter usagepct < 30 and arrayAvg(cpu_requests) > 0


Identify containers without limits:

smartscapeNodes K8SPOD | parse k8s.object, "JSON:config" | expand container = config[spec][containers] | fieldsAdd containername = container[name], cpulimit = container[resources][limits][cpu], memorylimit = container[resources][limits][memory] | filter isNull(cpulimit) or isNull(memorylimit)


### 3. Troubleshooting Pod Issues

Pod troubleshooting benefits from combining **metrics** (timeseries) with
**Kubernetes events** (event stream) for a complete picture.

#### Metrics-Based Troubleshooting

Find pods with OOMKills:

timeseries oomkills = sum(dt.kubernetes.container.oomkills), by: {k8s.pod.name, k8s.namespace.name, k8s.cluster.name} | filter arraySum(oomkills) > 0 | fieldsAdd totaloomkills = arraySum(oomkills) | sort totaloomkills desc


Analyze pod restart patterns:

timeseries restarts = sum(dt.kubernetes.container.restarts), by: {k8s.pod.name, k8s.namespace.name, k8s.cluster.name} | fieldsAdd totalrestarts = arraySum(restarts) | filter totalrestarts > 5


#### Event-Based Troubleshooting

For operational events (pod restarts, OOM kills, evictions, scheduling failures),
Kubernetes events provide richer context than metrics alone — including event
reasons, messages, and timestamps.

**When to use Kubernetes events over metrics:**
- User asks about recent operational events ("show me pod restart events")
- User wants event details like reasons and messages
- User asks about events in a specific time window ("last 48 hours")
- User wants to correlate events with root causes

**Kubernetes events** are available through the `get-events-for-kubernetes-cluster`
tool. **Prefer this tool** when the user asks about OOM events, pod restarts,
evictions, or cluster-wide event history.

**Important: distinguish event types when filtering results.** Kubernetes events
cover many categories. When the user asks about a specific event type, filter
the results accordingly — do not report unrelated events:

| User Asks About | Relevant Event Reasons | NOT Related |
|-----------------|----------------------|-------------|
| Pod restarts | `BackOff`, `CrashLoopBackOff`, `Killing` | Readiness probe failures, CPU throttling |
| OOM events | `OOMKilling`, `OOMKilled` | Memory pressure warnings |
| Evictions | `Evicted`, `Preempting` | Node pressure |
| Scheduling failures | `FailedScheduling`, `Unschedulable` | Resource quotas |

**For a complete answer**, combine both approaches:
1. Use the **events tool** to get the event details (what happened, when, why)
2. Use **timeseries metrics** to show the quantitative impact (how many restarts,
   OOM kill counts over time)

#### Fetch Kubernetes Events via DQL

Pod restart and operational events can also be queried via DQL from the events
table:

fetch events | filter event.kind == "K8S_EVENT" | filter event.type == "Warning" | fields timestamp, k8s.cluster.name, k8s.namespace.name, k8s.pod.name, event.reason, event.message | sort timestamp desc | limit 50


Filter for specific event reasons:

fetch events | filter event.kind == "K8S_EVENT" | filter in(event.reason, {"OOMKilling", "BackOff", "Evicted", "FailedScheduling"}) | fields timestamp, k8s.cluster.name, k8s.namespace.name, k8s.pod.name, event.reason, event.message | sort timestamp desc


**Field names in `fetch events`:** Use `event.reason` and `event.message` — not
`dt.kubernetes.event.reason`. The `dt.kubernetes.*` prefix is for timeseries metrics,
not the events table. Queries using the wrong prefix return zero results.

### 4. Security Assessment

Identify privileged containers:

smartscapeNodes K8SPOD | parse k8s.object, "JSON:config" | expand container = config[spec][containers] | fieldsAdd containername = container[name], privileged = container[securityContext][privileged] | filter privileged == true


Find containers running as root:

smartscapeNodes K8SPOD | parse k8s.object, "JSON:config" | expand container = config[spec][containers] | fieldsAdd containername = container[name], runasuser = container[securityContext][runAsUser], runasnonroot = container[securityContext][runAsNonRoot] | filter (isNull(runasuser) or runasuser == 0) and runasnonroot != true


### 5. Scheduling Analysis

Verify pod distribution (HA compliance):

smartscapeNodes K8SPOD | filter k8s.workload.kind == "deployment" | summarize podcount = count(), nodecount = countDistinct(k8s.node.name), by: {k8s.cluster.name, k8s.namespace.name, k8s.workload.name} | fieldsAdd hacompliant = nodecount > 1 | filter podcount >= 2 and not ha_compliant


### 6. DAVIS Problems affecting K8s Entities

Find active DAVIS problems affecting K8s entities:

fetch dt.davis.problems, from:now() - 2h | filter not(dt.davis.isduplicate) and event.status == "ACTIVE" | filter iAny(startsWith(smartscape.affectedentities[][type], "K8S")) | fields displayid, event.name, event.category, affectedentityids = smartscape.affected_entities[][id]


`smartscape.affected_entities` is a record array; each record has `id`, `type`, and `name`. Use
`[][id]` to get the array of Smartscape IDs to look up the affected entity, or
`[id]` after `expand smartscape.affected_entities`. Without a preceding `expand`, `[id]` returns
`null` silently. A `filter` cannot take a bare iterative expression, so wrap it in `iAny(...)`.

## Best Practices

### Choosing the Right Data Source

| User Question | Best Approach | Why |
|---------------|---------------|-----|
| "Show me OOM events" | Events tool + metrics | Events give reasons/messages; metrics show trends |
| "Show me pod restart events" | Events tool + timeseries metrics | Events reveal the reason (BackOff, Killing, CrashLoopBackOff); `dt.kubernetes.container.restarts` metric gives the actual restart counts |
| "How many pod restarts?" | Timeseries metrics | Quantitative data over time |
| "What happened to my pods in the last 48h?" | Events tool | Operational event history with context |
| "Which pods are using the most CPU?" | Timeseries metrics | Resource utilization analysis |
| "List all clusters/namespaces" | smartscapeNodes | Entity discovery and inventory |
| "Are there scheduling failures?" | Events tool | Event reasons explain why |

### Query Performance

1. **Filter early** - Apply cluster/namespace filters immediately
2. **Use specific entity types** - Avoid wildcards
3. **Limit result sets** - Use `limit` for exploration
4. **Cache cluster lists** - Store in variables

### Monitoring Recommendations

1. Set resource limits on all containers
2. Monitor OOMKills and adjust memory limits
3. Track CPU throttling and adjust CPU limits
4. Review resource efficiency regularly (target 70-80%)
5. Implement security best practices (non-root, read-only filesystem)
6. Use specific image tags (avoid :latest)

### Configuration Standards

1. Use labels for organization (app, environment, team)
2. Set resource requests and limits
3. Configure health checks (liveness/readiness probes)
4. Use TLS for all ingress resources
5. Document with annotations

## Troubleshooting

| Problem | Cause | Solution |
|---------|-------|----------|
| No pod data returned | Wrong entity type or missing cluster filter | Use `K8S_POD` (not `POD`); add `k8s.cluster.name` filter |
| `k8s.object` parsing errors | Complex JSON structure | Use `parse k8s.object, "JSON:config"` then access nested fields |
| Pod network metrics unavailable | Not available in Grail | Use service mesh metrics or host-level network metrics |
| Large result sets | No time range or cluster filter | Add time range and filter by cluster/namespace early |
| Missing labels in output | Labels accessed incorrectly | Use `tags[label_name]` to access labels |

## Limitations

**Unavailable Metrics:**

- Pod network metrics (rx_bytes, tx_bytes) are NOT available in Grail
- Workaround: Use service mesh metrics or host-level network metrics

**Query Considerations:**

- Minimize result set size: Do not include the `k8s.object` field if not necessary
- Keep result set as simple as possible: Parsing k8s.object increases query complexity
- Large clusters may require pagination or time-range limits
- Some K8s status fields update asynchronously

## When to Load References

### Load cluster-inventory.md when:
- Performing cluster, namespace, or resource distribution analysis
- Auditing workload counts across clusters

→ [references/cluster-inventory.md](references/cluster-inventory.md)

### Load labels-annotations.md when:
- Filtering by labels or annotations
- Parsing `k8s.object` for detailed configuration inspection

→ [references/labels-annotations.md](references/labels-annotations.md)

### Load pod-node-placement.md when:
- Analyzing scheduling constraints (affinity, taints, tolerations)
- Verifying HA compliance and pod distribution

→ [references/pod-node-placement.md](references/pod-node-placement.md)

### Load pod-debugging.md when:
- Investigating pod exit codes, crash loops, or init container failures
- Diagnosing image pull errors or service-to-pod connectivity issues
- Drilling down from a service problem to pod-level details

→ [references/pod-debugging.md](references/pod-debugging.md)

### Load workload-health.md when:
- Investigating degraded deployments or stuck rollouts
- Checking node conditions, CPU throttling, or HPA scaling
- Analyzing StatefulSet ordering or DaemonSet coverage

→ [references/workload-health.md](references/workload-health.md)

### Load pv-pvc.md when:
- Working with persistent storage (PVC/PV lifecycle, orphaned volumes)
- Checking StorageClass configurations

→ [references/pv-pvc.md](references/pv-pvc.md)

### Load ingress.md when:
- Analyzing ingress routing rules or TLS certificates
- Auditing ingress controller configurations

→ [references/ingress.md](references/ingress.md)

### Load network-policies.md when:
- Listing or auditing network policies
- Checking namespace isolation configurations

→ [references/network-policies.md](references/network-policies.md)

## References

- [cluster-inventory.md](references/cluster-inventory.md) — Cluster, namespace, and resource distribution analysis
- [labels-annotations.md](references/labels-annotations.md) — Label/annotation filtering and k8s.object parsing
- [pod-node-placement.md](references/pod-node-placement.md) — Scheduling, affinity, taints, and HA patterns
- [pod-debugging.md](references/pod-debugging.md) — Exit codes, pod conditions, init containers, image pull errors, logs, service-to-pod drill-down
- [workload-health.md](references/workload-health.md) — Degraded deployments, stuck rollouts, node conditions, CPU throttling, HPA, StatefulSet ordering
- [pv-pvc.md](references/pv-pvc.md) — PVC/PV lifecycle, phase reference, orphaned volumes, StorageClass
- [ingress.md](references/ingress.md) — Routing rule parsing, TLS audit
- [network-policies.md](references/network-policies.md) — Policy listing, namespace isolation audit

## Related Skills

- **dt-obs-problems** — For problems associated with Kubernetes clusters (use `dt.smartscape_source.id` with K8S_ prefix filters)
- **dt-dql-essentials** — Core DQL syntax and query structure
- **dt-obs-hosts** — Host-level metrics for K8s nodes