liveBook · Manning

Monitoring

As explained in Kubernetes in Action, Second Edition

A log file is a file containing records of events and diagnostic messages emitted by a process or application.

Application monitoring uses logs to inspect events and diagnostic messages emitted by a running process. Containerized applications usually write to standard output (stdout) and standard error (stderr) instead of managing log files themselves. section 5.3.2

The container runtime intercepts this output, stores it consistently, and makes it available without requiring knowledge of the application’s internal file locations. Kubernetes exposes the container log through kubectl logs. section 5.3.2

Use kubectl logs to inspect application behavior:

  • Run kubectl logs kiada to display a pod’s container log. section 5.3.2
  • Add -f or --follow to stream new log lines while requests arrive. section 5.3.2
  • Add --timestamps=true to display the timestamp attached to every logged line. section 5.3.2
  • Use --since=2m, --since-time=<timestamp>, or --tail=10 to restrict the displayed output. section 5.3.2

Follow requests as they arrive

Run kubectl logs kiada -f, send requests to the application, and observe entries such as “Received request for / from …”. Press Ctrl-C to stop streaming.

$ kubectl logs kiada --timestamps=true
2020-02-01T09:44:40.954641934Z Kiada - Kubernetes in Action Demo Application
2020-02-01T09:44:40.954843234Z ---------------------------------------------
2020-02-01T09:44:40.955032432Z Kiada 0.1 starting...
2020-02-01T09:44:40.955123432Z Local hostname is kiada
2020-02-01T09:44:40.956435431Z Listening on port 8080
2020-02-01T09:50:04.978043089Z Received request for / from ...
2020-02-01T09:50:33.640897378Z Received request for / from ...
2020-02-01T09:50:44.781473256Z Received request for / from ...

Inspect timestamped startup and request entries to correlate application activity with time. section 5.3.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains stdout, stderr, runtime capture, retrieval, streaming, timestamps, and time filtering without detailing log aggregation.
Examples
Demonstrates Node.js startup messages, request entries, kubectl logs, live streaming, timestamps, and output limits.
What it assumes
Assumes a running containerized application and introduces Kubernetes log access through concrete pod commands.
What you can do after
Operate kubectl logs to retrieve, stream, timestamp, and limit logs from a running application pod.
How it connects
Connects application logs with stdout, stderr, container runtimes, pods, and kubectl.

Also explained in

Compare how 40 books explain monitoring →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.