Skip to main content
Find the part of the stack that’s struggling, give that part more room, and check the number instead of trusting the command.
A dark-themed diagram titled "Bob's Rule" showing a three-step flow: "Find the part" (heartbeat icon) → "Give it room" (stacked layers) → "Check the number" (checkmark in a circle), with arrows between each step.
This walkthrough follows Bob’s troubleshooting process on an EFK (Elasticsearch, Fluentd, Kibana) stack: identify the bottleneck, add capacity where needed, and verify the result.

1) Find the bottleneck: check the index primaries in Kibana

Bob starts in Kibana → Index Management and inspects today’s Fluentd index. Under the column Primaries it shows 1. That number is the count of primary shards.
  • A shard is a slice of an index. Each shard can live on a different Elasticsearch node and be queried in parallel.
  • With one primary shard, all indexing and searching go through that single shard, which quickly becomes a throughput and query bottleneck.
You might be tempted to change the shard count on a live index, but that is unsafe.
You cannot safely change the number of primary shards on an existing, live index. Changing primary shard count in-place risks data corruption or loss. The recommended method is to create a new index with the desired shard count and reindex into it.
A dark teal dashboard screen titled "Not on a Live Index" showing a small blue robot mascot on a platform, a disabled progress bar with a red X, and a circular widget on the right reading "1 shards" with an orange progress arc. The KodeKloud logo appears in the lower-left corner.
Create a new index with an increased number of primary shards and reindex data from the old index into the new one. Example Elasticsearch HTTP requests (default port 9200):
Reindex documents from your existing Fluentd index pattern into the new index:
After reindexing, refresh indices in Kibana. MyIndex should now show 5 under Primaries. Relevant reading:

2) Give the collector room: Fluentd buffering and DaemonSet limitations

What happens when Fluentd sees a sudden 10× increase in logs? Fluentd buffers records in small batches and flushes them on a schedule or when size thresholds are reached. Tuning these buffers reduces backpressure on Elasticsearch.
A dark-themed slide titled "Ten Times the Lines" shows two smiling blue robot icons sitting on a controlplane device at the lower left. To the right is a dotted square labeled "Buffer" and the KodeKloud logo appears in the bottom-left corner.
Example Fluentd output (match) section that flushes more frequently and retries indefinitely if Elasticsearch is unavailable:
After updating the Fluentd config you typically restart the pod (for a DaemonSet, delete the pod and the DaemonSet will recreate it with the new config). However, remember the DaemonSet semantics.
A stylized diagram titled "One Pod per Node" showing three server nodes labeled controlplane, node01, and node02. Each node has a small blue pod-like icon sitting on it, illustrating pod placement across nodes.
A DaemonSet ensures exactly one pod per node (matching the DaemonSet pod template). If a single node produces a disproportionate amount of logs, the single Fluentd pod on that node may be overwhelmed — the DaemonSet will not create a second pod on the same node by itself. To allow multiple collectors on a busy node, you can adopt the DaemonSet pod spec into a ReplicaSet (or Deployment) and scale replicas. Note: a ReplicaSet does not guarantee placement on the same node — the scheduler decides placement based on resources, node selectors, and affinity/anti-affinity rules. If you want multiple pods specifically colocated on one node you must use nodeSelector/nodeAffinity or relax anti-affinity constraints. Example ReplicaSet manifest (abbreviated):
If you scale up and the scheduler places multiple collectors on the busy node, the node now has multiple collectors sharing the load.
A dark-themed diagram titled "Three Collectors, One Node" showing several glowing blue collector mascots standing on a single platform. The platform is labeled "controlplane."

3) Check the number: Elasticsearch resources, autoscaling, and metrics

You saw heap/CPU alerts earlier. One step is to give Elasticsearch pods reasonable CPU requests and limits so Kubernetes schedules them appropriately and the kube-scheduler can make autoscaling decisions. Example StatefulSet container resource settings:
A millicore (m) is one-thousandth of a CPU core: 250m reserves a quarter core, 500m enforces a half-core ceiling. The request influences scheduling decisions; the limit caps CPU usage.
An infographic titled "Reserved and Ceiling" showing a small blue robot on the left and a vertical 1 CPU core bar on the right with a green "Request 250m" marker and a red "Limit 500m" marker. It visually explains CPU request vs limit allocation.
Apply the updated StatefulSet and verify:
Scaling up a pod’s resources helps, but scaling out is handled by autoscaling. The Horizontal Pod Autoscaler (HPA) can increase replica counts based on metrics (e.g., CPU). Those metrics come from the Metrics Server. Install Metrics Server (example uses v0.5.0). In lab environments you may add --kubelet-insecure-tls to avoid kubelet certificate issues (do NOT use this in production):
Example metrics-server args snippet to add:
Wait a few seconds and confirm the pod is running in kube-system:
With metrics available, create an HPA targeting the Elasticsearch StatefulSet:
This HPA attempts to keep average CPU utilization at 80%, scaling between 1 and 3 pods. Test the autoscaler by deleting elasticsearch-0. During startup the replacement pod typically spikes CPU; the HPA will react to sustained high CPU and increase replicas.

4) Security and access control — don’t forget this when you scale

Weeks after scaling shards, collectors, and autoscalers, a developer runs a benign test pod that performs a single query against Elasticsearch.
An illustration titled "One Stray Request" showing two smiling pod-like characters on separate server platforms—one labeled "test pod"—against a dark background with a small KodeKloud logo.
A single unrestricted query can return massive datasets (for example, months of logs with usernames and other sensitive fields) if indices are open and queries are unfiltered.
An illustration titled "Open to Anyone" with a centered stack of five login notifications reading "USER1 logged in" through "USER5 logged in." Two cute pod-like characters sit on platform blocks at left and right (left labeled "test pod"), with a small KodeKloud logo in the bottom-left.
Scaling and availability are critical, but security is equally important. Ensure Elasticsearch endpoints and indices are secured with authentication, authorization, and TLS. Apply strict query and index access controls to prevent accidental or malicious data exposure.
Our stack in this example is currently in exactly that exposed state — make security part of your scaling plan.

Quick action checklist

Follow Bob’s rule: locate the stressed component, give it room (more shards, collectors, or pods), and then check the numbers (Kibana primaries, pod readiness, HPA behavior) to confirm the problem is resolved.

Watch Video

Practice Lab