Skip to content

Commit

Permalink
Add Loki documentation (#203)
Browse files Browse the repository at this point in the history
* Add Loki documentation

* Apply suggestions from code review

Co-authored-by: Tobias Brunner <[email protected]>

* Add Loki documentation

---------

Co-authored-by: Tobias Brunner <[email protected]>
  • Loading branch information
DebakelOrakel and tobru authored Dec 31, 2024
1 parent 831a61e commit 814e3fc
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 36 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
* xref:how-to/choose-node-class.adoc[]
.Logging
* xref:how-to/access-logs-through-kibana.adoc[]
* xref:tutorials/logging/getting-started.adoc[Getting Started]
* xref:tutorials/logging/query-logs.adoc[]
.Monitoring
* xref:tutorials/monitoring/index.adoc[Getting Started]
Expand Down
35 changes: 0 additions & 35 deletions docs/modules/ROOT/pages/how-to/access-logs-through-kibana.adoc

This file was deleted.

99 changes: 99 additions & 0 deletions docs/modules/ROOT/pages/tutorials/logging/getting-started.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
= Getting started with logging

This tutorial explains how to view the logs of an application on the OpenShift Web Console with the LokiStack.


== Requirements

To follow this guide, please make sure that you have the following tools installed:

`oc`:: You can download the OpenShift command directly from OpenShift Web Console. Open the help menu (marked as a question mark at the top right) and select the "Command line tools" entry.


== Step 1: Deploy Fortune application

. Create a new namespace called `demo-fortune`
+
[source,shell]
--
oc new-project demo-fortune
--
+
[TIP]
====
If you get an error that the namespace already exists, please pick another name and try again.
We recommend prefixing the name with the name of your organization to minimize potential for name collisions.
====

. Create Fortune application manifest
+
.Manifest for Fortune application
[source,yaml]
--
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: fortune-cookie
name: fortune-cookie
spec:
replicas: 1
selector:
matchLabels:
app: fortune-cookie
template:
metadata:
labels:
app: fortune-cookie
spec:
containers:
- image: registry.gitlab.com/vshn/applications/fortune-go:latest
imagePullPolicy: IfNotPresent
name: fortune-cookie
---
apiVersion: v1
kind: Service
metadata:
labels:
app: fortune-cookie
name: fortune-cookie
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
name: web
selector:
app: fortune-cookie
type: ClusterIP
--

. Deploy Fortune application manifest
+
[source,shell]
--
oc apply -f fortune.yaml
--

. Expose Fortune application
+
[source,shell]
--
oc expose svc/fortune-cookie
--


== Step 2: View Fortune application logs

* The current / live logs can be viewed from the logs tab of the pod
+
image::logging/fortune-podlogs.png[]

* To access the aggregated logs from all pods, change to the aggregated logs tab
+
[source]
--
{ kubernetes_container_name="fortune-cookie" } | json
--
+
image::logging/fortune-aggregated.png[]
38 changes: 38 additions & 0 deletions docs/modules/ROOT/pages/tutorials/logging/query-logs.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
= Query application logs
:page-aliases: how-to/access-logs-through-kibana.adoc

[NOTE]
====
Kibana is deprecated and has been replaced with LokiStack.
====

Open the console in the `Administrator` view and switch to `Logs` in the `Observe` section.
You can query the logs using Grafanas https://grafana.com/docs/loki/latest/logql[LogQL].


== View namespace logs

* View logs by selecting namespace in the UI
+
image::logging/namespace-logs.png[]

* Or use the query language
+
[source]
--
{ kubernetes_namespace_name="demo-fortune" } | json
--


== View error logs

* Filter by logtype `error` in the UI
+
image::logging/error-logs.png[]

* Or use the query language
+
[source]
--
{ kubernetes_namespace_name="syn-kyverno" } | json | level=~"error|err|eror"
--

0 comments on commit 814e3fc

Please sign in to comment.