You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/observability/logs/README.md
+24-4
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,29 @@
1
+
---
2
+
description: >-
3
+
NAIS offers several mechanisms for collecting and storing logs from your
4
+
applications. This page describes the different options and how to use them.
5
+
---
1
6
# Application Logs
2
7
3
-
## Purpose
8
+
## Purpose of logs
4
9
5
10
Logs are a way to understand what is happening in your application. They are usually text-based and are often used for debugging. Since the format of logs is usually not standardized, it can be difficult to query and aggregate logs and thus we recommend using metrics for dashboards and alerting.
6
11
7
12
There are many types of logs, and they can be used for different purposes. Some logs are used for debugging, some are used for auditing, and some are used for security. Our primary use case for logs is to understand the flow of a request through a system.
8
13
9
14
Application logs in nais is first and foremost a tool for developers to debug their applications. It is not intended to be used for auditing or security purposes. We do not condone writing sensitive information to application logs.
10
15
11
-
## Overview
16
+
## Good practice
17
+
18
+
-[x]**Establish a clear logging strategy** for your application. What do you want to log? What do you not want to log? What is the purpose of your logs?
19
+
-[x]**Use log levels** to different- [x]**Use log levels** to differentiate between different types of logs. We recommend using the following log levels: `INFO`, `WARN`, `ERROR`, and `FATAL`.
20
+
-[x]**Use structured logging**. This means that your logs must be written in a JSON format. This makes it easier to query and aggregate logs.
21
+
-[x]**Write meaningful log messages** and attach relevant metadata to your logs. This makes it easier to understand what is happening in your application.
22
+
-[ ]**Do not log sensitive information**. This includes personal information, passwords, and secrets. If you need to log sensitive information, use [secure logs](#secure-logs) or [audit logs](#audit-logs).
23
+
-[ ]**Do not underestimate the cost and performance** of logging. Logging is a trade-off between observability, performance, and cost. Logging can be computational and financial expensive, so make sure you log only what you actually need.
24
+
-[ ]**Do not use rely on logs for monitoring**. Use metrics for monitoring, visualization, and alerting as your first line of defense and use logs for debugging when something goes wrong.
25
+
26
+
## Technical overview
12
27
13
28
Logs that are sent to console (also known as `stdout`) are collected automatically by an agent inside the cluster. This agent can be configured to send logs for persistent storage and querying based on team- and application specific configuration.
14
29
@@ -24,11 +39,16 @@ graph LR
24
39
25
40
[FluentD]: https://www.fluentd.org/
26
41
27
-
## Configuration
42
+
## Log collection
43
+
44
+
Log collection is automatically configured for persistent storage, but can be changed in the following two ways:
28
45
46
+
1. By changing the default logging destination for all applications in your team namespace (not yet fully implemented)
47
+
2. By changing the logging destination for a single application using the `spec.observability.logging.destinations` field in the [nais manifest](../../nais-application/application.md).
29
48
49
+
The most recent log will always be available in nais console and using the `kubectl logs` command.
0 commit comments