Skip to main content
But here’s the rule now: Find the part of the stack that’s struggling, give that part more room, and check the number instead of trusting the command.
A slide titled "Bob's Rule" showing a three-step workflow—Find the part, Give it room, Check the number—represented by icons and arrows. The slide has a dark background with a small KodeKloud logo in the bottom-left.
This page walks through how Bob follows that rule across the EFK stack: identify a bottleneck (indices, collectors, or Elasticsearch), give it room (shards, buffers, CPU), and verify using metrics and controlled tests.

Index shard bottleneck — check the number

Bob starts at Kibana → Index Management and inspects today’s Fluentd index (fluentd-<date>). The UI shows “primaries: 1”. What does that “1” mean? It’s the number of primary shards for that index. A shard is a slice of an index that can live on a separate Elasticsearch node and be searched in parallel. With only one primary shard, all index operations and searches hit the same slice — a single bottleneck. Can you safely change the primary shard count on a live index? No. Increasing the number of primary shards on an existing index is not supported and doing so improperly can corrupt or make data unavailable.
A dark-themed dashboard screen that reads "Not on a Live Index," showing a circular widget labeled "1 shards" and a disabled input box with an X. A small blue mascot sits on a platform and the KodeKloud logo appears in the bottom-left.
Recommended approach: create a new index with the desired shard count, then reindex data from the old index into the new one. This avoids modifying an active index’s shard layout and keeps data safe. Example (assumes Elasticsearch reachable at http://localhost:9200):
Then copy documents from the old index to the new one using the Reindex API:
Back in Kibana click “Reload Indices” and you should see myindex with five primaries. Reindexing avoids changing shard allocation for an active index and preserves availability.
Before reindexing in production: take a snapshot of the source index (or the cluster) and validate snapshots on a restore cluster to prevent accidental data loss.

Collector (Fluentd) — buffer and replica options

When applications suddenly emit many more log lines, Fluentd buffers events in memory or files until it can flush them to Elasticsearch. A buffer acts as a waiting room that batches events for efficient delivery and retries on failure. Bob updates the Fluentd match configuration to flush batches every 5 seconds and to retry indefinitely if Elasticsearch becomes unavailable:
After saving the configuration, Bob deletes the Fluentd pod. The DaemonSet controller notices the missing pod and schedules a new one; the new pod picks up the updated configuration on startup. Note on placement: a DaemonSet runs one pod per node by design. That ensures cluster-wide collection but can become a bottleneck if one node has far more workload than others. To let a busy node run multiple collectors, run the fluentd pod spec as a ReplicaSet (or Deployment) with multiple replicas so the scheduler can place two or more collectors on the same node. Example ReplicaSet manifest:
After applying:
Use DaemonSets when you need exactly one collector per node (e.g., to access node-local logs). Use ReplicaSets/Deployments when you need multiple collectors on a single node to absorb bursty or uneven traffic.

Elasticsearch pod sizing — vertical scaling (requests & limits)

If Elasticsearch pods are hitting CPU or heap alerts, give them more resources. Bob edits the Elasticsearch StatefulSet container resources to request 250m (0.25 core) and limit 500m (0.5 core). Kubernetes will reserve the requested CPU and enforce the hard ceiling defined by the limit. Example StatefulSet container resources snippet:
An infographic titled "Reserved and Ceiling" showing a single CPU core column with a green "Request" at 250m and a red "Limit" at 500m. A small blue mascot sits on a server platform and points toward the CPU usage indicators.
Apply and confirm:
Vertical scaling increases capacity per pod. If the cluster needs more overall throughput or high availability, combine vertical sizing with horizontal scaling.

Horizontal scaling — HPA + Metrics Server

For automatic horizontal scaling, use a HorizontalPodAutoscaler (HPA). The HPA needs metrics (typically CPU) from the Kubernetes Metrics Server. Install Metrics Server (example uses v0.5.0 and the lab-only --kubelet-insecure-tls flag):
Snippet to add inside components.yaml:
The --kubelet-insecure-tls option disables kubelet certificate verification. It is fine for a lab environment but should NOT be used in production.
Apply and check:
Create an HPA targeting the Elasticsearch StatefulSet:
This HPA attempts to keep average CPU utilization near 80% across StatefulSet pods and will scale between 1 and 3 replicas. To test HPA behavior, force a temporary CPU spike (e.g., trigger heavy startup CPU use by deleting elasticsearch-0 so a new pod rebuilds and overshoots the target). The HPA observes the increased CPU usage via Metrics Server and scales up:
HPA reacts to metrics — it won’t proactively create pods without observed load.

Quick comparison: scaling options

Secure your Elasticsearch

A properly scaled stack is still vulnerable if Elasticsearch is left exposed without authentication, authorization, and TLS. In Bob’s lab a test pod issued a single request to the open Elasticsearch endpoint and could retrieve every log line from the month — potentially exposing usernames and PII.
A dark-themed illustration titled "Open to Anyone" with a central list showing "USER1 logged in" through "USER5 logged in." Two cute server avatars sit on platforms at left and right (the left one labeled "test pod") and a KodeKloud logo appears in the corner.
Secure Elasticsearch immediately in non-lab environments:
  • Enable authentication and role-based access control.
  • Use TLS (HTTPS) for both HTTP and transport layers.
  • Restrict network access with NetworkPolicies and service-level controls.
  • Audit and monitor access to sensitive indices.

Watch Video

Practice Lab