Skip to content

Commit 57e2e59

Browse files
Add logging section for agent k8s standalone containers (#4234)
## Summary Add a section to explain needed changes in order to log to a user defined path when running the agent in a standalone k8s container. ## Generative AI disclosure 1. Did you use a generative AI (GenAI) tool to assist in creating this contribution? - [ ] Yes - [x] No --------- Co-authored-by: Karen Metts <[email protected]>
1 parent ecd0f0c commit 57e2e59

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

reference/fleet/running-on-kubernetes-standalone.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,24 @@ If you are using Red Hat OpenShift, you need to specify additional settings in t
266266

267267
Refer to [Kubernetes autodiscovery with {{agent}}](/reference/fleet/elastic-agent-kubernetes-autodiscovery.md) for more information.
268268

269+
## Logging considerations
269270

271+
Altering the default logging in a standalone container requires additional considerations. By default the {{agent}} logs to `stderr` and an internal destination so that diagnostics can be properly collected.
272+
273+
274+
To log to a custom filepath, make these changes to the manifest file:
275+
- {{agent}} logging must be configured in the configmap for `agent.yml`:
276+
```yaml
277+
agent:
278+
logging:
279+
level: info
280+
to_files: true # Log to a custom filepath
281+
to_stderr: true # Also log to stderr so that commands such as kubectl logs works as intended
282+
files:
283+
path: ${LOGS_PATH} # Use the env var to determine the logging path.
284+
```
285+
- The `LOGS_PATH` environment variable must be defined as a part of the Daeomonset's container specification.
286+
- The default DaemonSet container args must be changed to remove the `-e` option:
287+
```yaml
288+
args: ["-c", "/etc/elastic-agent/agent.yml"]
289+
```

0 commit comments

Comments
 (0)