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/README.md
+5-8
Original file line number
Diff line number
Diff line change
@@ -67,17 +67,14 @@ graph LR
67
67
68
68
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.
69
69
70
-
Logs are collected automatically by [fluentd][fluentd], stored in [Elasticsearch][elasticsearch] and made accessible via [Kibana][kibana].
Copy file name to clipboardExpand all lines: docs/observability/logs/README.md
+79-25
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,76 @@
1
-
# Logs
1
+
# Application Logs
2
2
3
-
## Logging
3
+
## Purpose
4
4
5
-
Configure your application to log to console \(stdout/stderr\), it will be scraped by [FluentD](https://www.fluentd.org/) running inside the cluster and sent to [Elasticsearch](https://www.elastic.co/products/elasticsearch) and made available via [Kibana](https://www.elastic.co/products/kibana). Visit our Kibana at [logs.adeo.no](https://logs.adeo.no/).
5
+
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
6
7
-
If you want more information than just the log message \(loglevel, MDC, etc\), you should log in JSON format; the fields you provide will then be indexed.
7
+
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
8
9
-
## Working with Kibana
9
+
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
+
11
+
## Overview
12
+
13
+
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
+
15
+
Logs must be written in JSON format *and* preferably following the [Elastic Common Schema](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html) or [OpenTelemetry Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/).
|[Loki](#grafana-loki)|`loki`| Logs are available in Grafana. | All |
37
+
|[Elastic](#elastic-kibana)|`elastic`| Logs are available in Kibana. | NAV-only |
38
+
|[Secure Logs](#secure-logs)|`secure_logs`| Logs are stored in a secret place. | NAV-only |
39
+
40
+
## Grafana Loki
41
+
42
+
Grafana Loki is a log aggregation system inspired by Prometheus and integrated with Grafana. It is designed to be cost effective and easy to operate, as it does not index the contents of the logs, but rather a set of predefined labels for each log stream.
43
+
44
+
Grafana Loki is designed to be used in conjunction with metrics and tracing to provide a complete picture of an application's performance. Without the other two, it can be perceived as more cumbersome to use than a traditional logging system.
45
+
46
+
### Enabling Loki
47
+
48
+
Loki can be enabled by setting the list of logging destinations in your nais application manifest.
49
+
50
+
```yaml
51
+
…
52
+
spec:
53
+
observability:
54
+
logging:
55
+
destinations:
56
+
- id: loki
57
+
```
58
+
59
+
## Elastic Kibana
60
+
61
+
Elasticsearch is a
62
+
63
+
### Configuring Kibana
64
+
65
+
66
+
67
+
### Working with Kibana
10
68
11
69
When you open Kibana you are prompted to select a workspace, select "Nav Logs" to start viewing your application logs.
12
70
13
71
Once the page loads you will see an empty page with a search bar. This is the query bar, and it is used to search for logs. You can use the query bar to search for logs by message, by field, or by a combination of both.
14
72
15
-
The query language is called [Kibana Query Language](https://www.elastic.co/guide/en/kibana/current/kuery-query.html)\(KQL\). KQL is a simplified version of Lucene query syntax. You can use KQL to search for logs by message, by field, or by a combination of both.
73
+
The query language is called [Kibana Query Language](https://www.elastic.co/guide/en/kibana/current/kuery-query.html) (`KQL`). KQL is a simplified version of Lucene query syntax. You can use KQL to search for logs by message, by field, or by a combination of both.
16
74
17
75
There is also a time picker in the upper right corner of the page. You can use the time picker to select a time range to search for logs. The default time range is the last 15 minutes. If no logs shows up, try to increase the time range.
18
76
@@ -42,8 +100,7 @@ The following fields are common to all logs and can be used in the query bar:
42
100
| `message: "my message"AND level: "ERROR" AND NOT level: "WARN"` | Search for logs with the message "my message" and the level "ERROR" and not the level "WARN" |
43
101
| `message: "my message"AND level: "ERROR" OR level: "WARN"` | Search for logs with the message "my message" and the level "ERROR" or the level "WARN" |
44
102
45
-
46
-
## Gain access to logs.adeo.no
103
+
### Gain access to Kibana
47
104
48
105
In order to get access to logs.adeo.no you need to have the correct access rights added to your AD account. This can be requested through your Personnal Manager.
49
106
@@ -66,7 +123,7 @@ Secure logs can be enabled by setting the `secureLogs.enabled` flag in the appli
66
123
67
124
### Log files
68
125
69
-
With secure logs enabled a directory `/secure-logs/` will be mounted in the application container. Every `*.log` file in this directory will be monitored and the content transferred to Elasticsearch. Make sure that these files are readable for the log shipper \(the process runs as uid/gid 1065\).
126
+
With secure logs enabled a directory `/secure-logs/` will be mounted in the application container. Every `*.log` file in this directory will be monitored and the content transferred to Elasticsearch. Make sure that these files are readable for the log shipper (`the process runs as uid/gid 1065`).
70
127
71
128
The `/secure-logs/` directory has a size limit of 128Mb, and it's the application responsibility to ensure that this limit is not exceeded. **If the limit is exceeded the application pod will be evicted and restarted.** Use log rotation on file size to avoid this.
72
129
@@ -111,29 +168,20 @@ If you do not want to have these logs as files in the pod, it is also possible t
111
168
curl -X POST -d '{"log":"hello world","field1":"value1"}' -H 'Content-Type: application/json' http://localhost:19880/
112
169
```
113
170
114
-
## Audit logs
115
-
116
-
Most applications where a user processes data related to another user need to log audit statements, detailing which user did what action on which subject.
117
-
These logs need to follow a specific format and be accessible by ArcSight.
118
-
See [naudit](https://github.com/navikt/naudit) for how to set up the logging, and details on the log format.
119
-
120
-
## Overview
121
-
122
-

123
-
124
-
## Gaining access in kibana
171
+
### Gain access to Secure Logs
125
172
126
173
Once everything is configured, your secure logs will be sent to the `tjenestekall-*` index in kibana. To gain access to these logs, you need to do the following:
127
174
128
-
### 1 Create an AD-group
175
+
#### 1 Create an AD-group
129
176
130
177
To make sure you gain access to the proper logs, you need an AD-group connected to the nais-team. So the first thing you do is create this group.
131
178
132
179
Go to [Porten (service desk)](https://jira.adeo.no/plugins/servlet/desk/portal/542) and click `Melde sak til IT`. The follow the template below.
133
180
For IT to be able to correctly add the group to Remedy you need to specify the four digit department code for those who can be able to ask for permission to the group. E.g 2990 is the four digit code for the department IT-AVDELINGEN. If you are creating secure logs for your team and are unsure about which department your colleagues belong to then you can use [Delve](https://eur.delve.office.com/) to search for their profile. In their profile their department code will also be visible.
134
181
135
182
You can paste the template below into Jira:
136
-
```
183
+
184
+
```text
137
185
Ønsker å få opprettet en AD-gruppe for å få tilgang til sikker logg i Kibana for applikasjoner knyttet til <your project here>.
138
186
139
187
Gruppenavn: 0000-GA-SECURE_LOG_<SOMETHING>
@@ -148,20 +196,26 @@ Enheter i Nav som skal ha tilgang: <four digit department code>. E.g (2990 - IT-
148
196
149
197

150
198
151
-
### 2 Connect the AD group to your team in Kibana
199
+
#### 2 Connect the AD group to your team in Kibana
152
200
153
201
The logs your apps produces are linked with your [nais-team](../../basics/teams.md).
154
202
Administrators of Kibana will create a role for your team with read rights to those logs.
155
203
Whoever is in the AD-group (created in step 1) will get the Kibana role, and can thus read all logs produced by apps belonging to the nais-team.
156
204
157
205
Ask in the [#atom](https://nav-it.slack.com/archives/C7TQ25L9J) Slack channel to connect the AD-group (created in step 1) to your nais-team.
158
206
159
-
### 3 Put people into the AD-group
207
+
#### 3 Put people into the AD-group
160
208
161
209
This must be done by "identansvarlig". For NAV-IT employees, this is `[email protected]`. Send them an email and ask for access with a CC to whoever is your superior.
162
210
163
211
For everyone else, the team lead or who ever is their superior should know.
164
212
165
-
### What can go wrong?
213
+
#### What can go wrong?
166
214
167
215
Basically, the one thing that can go wrong here is that the AD-group is not registered in "identrutinen". If this happens, the group cannot be found by "identansvarlig". If this happens, make a new JIRA-ticket to the same people and tell them to transfer the group. Sadly this can take a few days.
216
+
217
+
## Audit logs
218
+
219
+
Most applications where a user processes data related to another user need to log audit statements, detailing which user did what action on which subject.
220
+
These logs need to follow a specific format and be accessible by ArcSight.
221
+
See [naudit](https://github.com/navikt/naudit) for how to set up the logging, and details on the log format.
0 commit comments