Skip to content

Commit fd4dd19

Browse files
logging docs: mention other sinks (#471)
* Updated text and image * Updated formatting * Update modules/concepts/pages/logging.adoc Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> * more info * Removed HDFS mentions * Added tutorial * link to tutorial from the concepts page * Update modules/concepts/pages/logging.adoc Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> * Update modules/tutorials/examples/logging-aggregator/main.sh Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> * Update modules/tutorials/examples/logging-aggregator/main.sh Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> * Updated ZK manifest * Made main.sh executable * Removed WebHDFS from the diagram * fixes for nightly * Update modules/tutorials/pages/logging-vector-aggregator.adoc Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> * Update modules/tutorials/pages/logging-vector-aggregator.adoc Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> * Update modules/tutorials/examples/logging-aggregator/main.sh Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> * Update modules/tutorials/examples/logging-aggregator/main.sh Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> * Changed install command * removed sleep in favor of server-side apply * Install listener * shell script improvements * fixed typo --------- Co-authored-by: Siegfried Weber <mail@siegfriedweber.net>
1 parent e65105e commit fd4dd19

9 files changed

Lines changed: 265 additions & 18 deletions

File tree

modules/concepts/images/logging_architecture.drawio.svg

Lines changed: 2 additions & 2 deletions
Loading

modules/concepts/pages/logging.adoc

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,59 @@
11
= Logging
2+
:description: A conceptual explanation of the logging architecture of the Stackable Data Platform, and how it is configured.
3+
:keywords: logging, observability, log aggregation, Kubernetes, k8s, Vector, Elasticsearch, OpenSearch
24

35
// Abstract
4-
Logging is important for observability of the platform. Stackable provides human-readable plaintext logs for each running container, as well as aggregated and persisted logs with identical structure across the whole platform. Log levels can be set for individual modules and configuration is identical across all products, but custom logging configuration files can be supplied as well.
6+
Logging is important for observability of the platform.
7+
Stackable provides human-readable plaintext logs for each running container, as well as aggregated and persisted logs with identical structure across the whole platform.
8+
Log levels can be set for individual modules and configuration is identical across all products, but custom logging configuration files can be supplied as well.
59

610
image::logging_overview.drawio.svg[]
711

812
== Motivation
913

10-
**Aggregate and persist** - The logging on the platform was designed to aggregate logs from all parts of the platform to make it easy to correlate events from different parts. For this, logs should share the same structure, and should be viewable in a central location. Logs should also be persisted in a central location, so if a component crashes, the logs are still there to identify the reason.
14+
**Aggregate and persist** - The logging on the platform was designed to aggregate logs from all parts of the platform to make it easy to correlate events from different parts.
15+
For this, logs should share the same structure, and should be viewable in a central location.
16+
Logs should also be persisted in a central location, so if a component crashes, the logs are still there to identify the reason.
1117

12-
**Easy to read on the fly** - At the same time, logs should still be accessible in an easy to read format on the containers, to allow for easy on the fly inspection of each part of the platform. The logging configuration also supports setting different thresholds for the logs readable on the container and the aggregated logs. This way you can get a detailed view of the operations of a component while viewing it on the container, but aggregate logs at a coarser granularity when aggregating across the whole platform.
18+
**Easy to read on the fly** - At the same time, logs should still be accessible in an easy to read format on the containers, to allow for easy on the fly inspection of each part of the platform.
19+
The logging configuration also supports setting different thresholds for the logs readable on the container and the aggregated logs.
20+
This way you can get a detailed view of the operations of a component while viewing it on the container, but aggregate logs at a coarser granularity when aggregating across the whole platform.
1321

14-
**Consistent configuration** - Finally, logging should be always configured the same way, no matter which product and which underlying technology is used to produce the logs. Logging for each product is configured in the ProductCluster resource. It is still supported to supply custom logging configuration files, these are then product specific.
22+
**Consistent configuration** - Finally, logging should be always configured the same way, no matter which product and which underlying technology is used to produce the logs.
23+
Logging for each product is configured in the ProductCluster resource.
24+
It is still supported to supply custom logging configuration files, these are then product specific.
1525

1626
== Architecture
1727

18-
Below you can see the overall architecture using ZooKeeper as an example. Stackable uses https://vector.dev/[Vector] for log aggregation and https://opensearch.org/[OpenSearch] as the sink to persist logs in.
28+
Below you can see the overall architecture using ZooKeeper as an example.
29+
Stackable uses https://vector.dev/[Vector] for log aggregation and any of the supported https://vector.dev/docs/reference/configuration/sinks/[sinks] can be used to persist the logs.
1930

2031
image::logging_architecture.drawio.svg[]
2132

22-
You configure your logging in the resource describing the cluster, seen in the top left in the diagram (see the <<configuration, configuration>> section below). The operator reads this resource and creates the appropriate log configuration files in the ConfigMap which also holds other product configuration. The ConfigMap is then mounted into the containers. The ZooKeeper Pod has three containers: The `prepare` sidecar container, the `zookeeper` container and the `vector` https://vector.dev/docs/setup/deployment/roles/#sidecar[sidecar container]. All logs get written into a shared mounted directory, from which the Vector agent reads them and sends them to the vector https://vector.dev/docs/setup/deployment/roles/#aggregator[aggregator].
33+
=== Log source
2334

24-
The aggregator is configured to use the OpenSearch sink. It sends all logs to the sink. If the sink is unavailable, it will buffer the log messages. It is also the single point where the sink is configured, so the sink is decoupled from the individual product configurations and only needs to be configured in this single location for the whole platform.
35+
You configure your logging settings in the resource describing the cluster (ZookeeperCluster in this example), seen in the top left in the diagram (see the <<configuration, configuration>> section below).
36+
The operator reads this resource and creates the appropriate log configuration files in the ConfigMap which also holds other product configuration.
37+
The ConfigMap is then mounted into the containers.
38+
The ZooKeeper Pod has three containers: The `prepare` sidecar container, the `zookeeper` container and the `vector` https://vector.dev/docs/setup/deployment/roles/#sidecar[sidecar container].
39+
All logs get written into a shared mounted directory, from which the Vector agent reads them and sends them to the Vector https://vector.dev/docs/setup/deployment/roles/#aggregator[aggregator].
40+
41+
=== Aggregator and sinks
42+
43+
The aggregator is configured to use one or multiple https://vector.dev/docs/reference/configuration/sinks/[sinks] (for example OpenSearch, Elasticsearch), it sends all logs to all sinks.
44+
If a sink is unavailable, it will buffer the log messages.
45+
It is also the single point where the sinks are configured, so the sinks are decoupled from the individual product configurations and only needs to be configured in this single location for the whole platform.
2546

2647
[#configuration]
27-
== Identical configuration in each product
48+
== Configuration
49+
50+
=== Identical configuration structure in each product
2851

29-
Logging configuration usually requires configuration what to log, where to log it and in which format. Usually you want to persist logs but also view them on the fly in a console, and possibly both of these in different formats. Stackable provides configuration for this out of the box. You only need to enable log aggregation and configure _what_ you want to log. As part of the logging configuration, individual modules can be configured with different log levels:
52+
Logging configuration usually requires configuration what to log, where to log it and in which format.
53+
Usually you want to persist logs but also view them on the fly in a console, and possibly both of these in different formats.
54+
Stackable provides configuration for this out of the box.
55+
You only need to enable log aggregation and configure _what_ you want to log.
56+
As part of the logging configuration, individual modules can be configured with different log levels:
3057

3158
[source,yaml]
3259
----
@@ -57,17 +84,29 @@ vectorAggregatorConfigMapName: vector-aggregator-discovery // <1>
5784
<5> Console and file appenders can have different log level thresholds.
5885
<6> Setting log levels for individual modules is also possible.
5986

60-
**Log levels per module** - In the `loggers` section the log levels for each module are configured. Note the `ROOT` module. This is a special module and refers to the default log level for the container. The log levels are the commonly used ones (TRACE, DEBUG, INFO, WARN, ERROR, FATAL) as well as the NONE level to turn of logging. The default log level is `INFO`.
87+
**Log levels per module** - In the `loggers` section the log levels for each module are configured.
88+
Note the `ROOT` module.
89+
This is a special module and refers to the default log level for the container.
90+
The log levels are the commonly used ones (TRACE, DEBUG, INFO, WARN, ERROR, FATAL) as well as the NONE level to turn of logging.
91+
The default log level is `INFO`.
6192

62-
**Log levels for console and file** - The configuration supports setting another level threshold for the console and the file output from which the aggregation is done. A typical use case is that the log level for the console is set to a more detailed level to allow for detailed inspection of a container, but less information in the aggregated log store.
93+
**Log levels for console and file** - The configuration supports setting another level threshold for the console and the file output from which the aggregation is done.
94+
A typical use case is that the log level for the console is set to a more detailed level to allow for detailed inspection of a container, but less information in the aggregated log store.
6395

64-
**Per container configuration** - A Pod actually consists of multiple containers and you might want different log levels for each of them. Also the log levels per module are container specific.
96+
**Per container configuration** - A Pod actually consists of multiple containers and you might want different log levels for each of them.
97+
Also the log levels per module are container specific.
6598

6699
Following the Stackable xref::roles-and-role-groups.adoc[roles and role groups] concept, this configuration fragment can be set either at role or role group level.
67100

101+
=== Configuring the Aggregator
102+
103+
Follow the https://vector.dev/docs/setup/installation/package-managers/helm/#aggregator[installation instructions] for the aggregator.
104+
Configure a https://vector.dev/docs/reference/configuration/sources/vector/[Vector source] at adress `0.0.0.0:6000` and configure sinks and additional settings according to your needs.
105+
68106
=== Configuring the aggregator location
69107

70-
Every product also has a `vectorAggregatorConfigMapName` property in its spec that needs to be set to the name of the ConfigMap that contains the address of the aggregator. The field is called `ADDRESS` and the value could be `vector-aggregator:6000` if you're running the aggregator behind a service named `vector-aggregator`.
108+
Every product also has a `vectorAggregatorConfigMapName` property in its spec that needs to be set to the name of the ConfigMap that contains the address of the aggregator.
109+
The field is called `ADDRESS` and the value could be `vector-aggregator:6000` if you're running the aggregator behind a service named `vector-aggregator`.
71110

72111
== Custom overrides
73112

@@ -85,6 +124,7 @@ logging:
85124
<1> The vector logging agent is not deployed
86125
<2> A custom logging configuration is loaded from a ConfigMap called `my-configmap`
87126

88-
== Further Reading
127+
== Further reading
89128

90-
To get some hands on experience and see logging in action, try out the xref:demos:logging.adoc[logging demo].
129+
To get some hands on experience and see logging in action, try out the xref:demos:logging.adoc[logging demo] or follow the xref:tutorials:logging-vector-aggregator.adoc[logging tutorial].
130+
The Vector documentation contains more information about the https://vector.dev/docs/setup/deployment/topologies/#centralized[deployment topology] and https://vector.dev/docs/reference/configuration/sinks/[sinks].
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
echo "Installing ZooKeeper Operator"
4+
# tag::zk-op[]
5+
stackablectl release install -i secret -i commons -i listener -i zookeeper 23.11
6+
# end::zk-op[]
7+
8+
# tag::vector-agg[]
9+
helm install \
10+
--wait \
11+
--values vector-aggregator-values.yaml \
12+
vector-aggregator vector/vector
13+
# end::vector-agg[]
14+
15+
# tag::vector-discovery[]
16+
kubectl apply -f vector-aggregator-discovery.yaml
17+
# end::vector-discovery[]
18+
19+
# tag::zk[]
20+
kubectl apply -f zookeeper.yaml
21+
# end::zk[]
22+
23+
# Wait until the zookeeper-operator deployed the StatefulSet
24+
kubectl wait \
25+
--for=condition=available \
26+
--timeout=5m \
27+
zookeeperclusters.zookeeper.stackable.tech/simple-zk
28+
29+
# tag::grep[]
30+
kubectl logs vector-aggregator-0 | grep "zookeeper.version=" | jq
31+
# end::grep[]
32+
33+
if [ "${PIPESTATUS[1]}" -eq 0 ]
34+
then
35+
echo "it worked"
36+
else
37+
echo "it didn't work"
38+
fi
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: vector-aggregator-discovery
5+
data:
6+
ADDRESS: vector-aggregator:6000
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
role: Aggregator
2+
customConfig:
3+
sources:
4+
vector: # <1>
5+
address: 0.0.0.0:6000
6+
type: vector
7+
version: "2"
8+
sinks:
9+
console: # <2>
10+
type: console
11+
inputs:
12+
- vector
13+
encoding:
14+
codec: json
15+
target: stderr
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
apiVersion: zookeeper.stackable.tech/v1alpha1
3+
kind: ZookeeperCluster
4+
metadata:
5+
name: simple-zk
6+
spec:
7+
image:
8+
productVersion: 3.8.0
9+
stackableVersion: "0.0.0-dev"
10+
clusterConfig:
11+
vectorAggregatorConfigMapName: vector-aggregator-discovery # <1>
12+
servers:
13+
roleGroups:
14+
default:
15+
replicas: 3
16+
config:
17+
logging: # <2>
18+
enableVectorAgent: true
19+
containers:
20+
vector:
21+
file:
22+
level: WARN
23+
zookeeper:
24+
console:
25+
level: INFO
26+
file:
27+
level: INFO
28+
loggers:
29+
ROOT:
30+
level: INFO
31+
org.apache.zookeeper.server.NettyServerCnxn:
32+
level: NONE

modules/tutorials/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* xref:tutorials:index.adoc[]
22
** xref:authentication_with_openldap.adoc[]
3+
** xref:logging-vector-aggregator.adoc[]
34
** xref:enabling_verification_of_image_signatures.adoc[]

modules/tutorials/pages/authentication_with_openldap.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ more about authentication in the Stackable Platform on the xref:concepts:authent
77
Prerequisites:
88

99
* a k8s cluster available, or https://kind.sigs.k8s.io/[kind] installed
10-
* xref:management::stackablectl/index.adoc installed
10+
* xref:management:stackablectl:index.adoc[] installed
1111
* basic knowledge of how to create resources in Kubernetes (i.e. `kubectl apply -f <filename>.yaml`) and inspect them
1212
(`kubectl get` or a tool like https://k9scli.io/[k9s])
1313
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
= Logging with a Vector log aggregator
2+
:description: A tutorial on how to set up a Vector log aggregator to use with the Stackable Data Platform.
3+
:keywords: logging, observability, log aggregation, Kubernetes, k8s, Vector, ZooKeeper
4+
5+
This tutorial teaches you how to deploy a Vector aggregator together with a product - in this case ZooKeeper - and how to configure both of them so the logs are sent from the product to the aggregator.
6+
Logging on the Stackable Data Platform is always configured in the same way, so you can use this knowledge to configure logging in any product that you want to deploy.
7+
8+
Prerequisites:
9+
10+
* a k8s cluster available, or https://kind.sigs.k8s.io/[kind] installed
11+
* xref:management:stackablectl:index.adoc[] installed
12+
* https://helm.sh/[Helm] installed to deploy Vector
13+
* basic knowledge of how to create resources in Kubernetes (i.e. `kubectl apply -f <filename>.yaml`) and inspect them
14+
(`kubectl get` or a tool like https://k9scli.io/[k9s])
15+
16+
== Install the ZooKeeper operator
17+
18+
Install the Stackable Operator for Apache ZooKeeper and its dependencies, so you can deploy a ZooKeeper instance later.
19+
20+
[source,bash]
21+
include::example$logging-aggregator/main.sh[tag=zk-op]
22+
23+
== Install the Vector aggregator
24+
25+
Install the Vector aggregator using Helm.
26+
First, create a `vector-aggregator-values.yaml` file with the Helm values:
27+
28+
[source,yaml]
29+
include::example$logging-aggregator/vector-aggregator-values.yaml[]
30+
31+
<1> define a source of `type` `vector` which listens to incoming log messages at port 6000.
32+
<2> define a `console` sink, logging all received logs to `stderr`.
33+
34+
Deploy Vector with these values using Helm:
35+
36+
[source,bash]
37+
include::example$logging-aggregator/main.sh[tag=vector-agg]
38+
39+
This is a minimal working configuration. The source should be defined in this way, but you can configure different sinks, depending on your needs.
40+
You can find an https://vector.dev/docs/reference/configuration/sinks/[overview] of all sinks in the Vector documentation, specifically the https://vector.dev/docs/reference/configuration/sinks/elasticsearch/[Elasticsearch] sink might be useful, it also works when configured with OpenSearch.
41+
42+
To make the Vector aggregator discoverable to ZooKeeper, deploy a xref:concepts:service_discovery.adoc[discovery ConfigMap] called `vector-aggregator-discovery`.
43+
Create a file called `vector-aggregator-discovery.yaml`:
44+
45+
[source,yaml]
46+
include::example$logging-aggregator/vector-aggregator-discovery.yaml[]
47+
48+
and apply it:
49+
50+
[source,bash]
51+
include::example$logging-aggregator/main.sh[tag=vector-discovery]
52+
53+
== Install ZooKeeper
54+
55+
Now that the aggregator is running, you can install a ZooKeeper cluster which is configured to send logs to the aggregator.
56+
57+
Create a file called `zookeeper.yaml` with the following ZookeeperCluster definition:
58+
59+
[source,yaml]
60+
include::example$logging-aggregator/zookeeper.yaml[]
61+
62+
<1> This is the reference to the discovery ConfigMap created in the previous step.
63+
<2> This is the logging configuration, where logging is first enabled and then a few settings are made.
64+
65+
and apply it:
66+
67+
[source,bash]
68+
include::example$logging-aggregator/main.sh[tag=zk]
69+
70+
TIP: You can learn more about how to configure logging in a product at the xref:concepts:logging.adoc[logging concept documentation].
71+
72+
== Watch the logs
73+
74+
During startup, ZooKeeper already prints out log messages.
75+
Vector was configured to print the aggregated logs to `stderr`, so if you look at the logs of the Vector pod, you will see the ZooKeeper logs:
76+
77+
78+
[source,bash]
79+
include::example$logging-aggregator/main.sh[tag=grep]
80+
81+
You should see a JSON object per ZooKeeper replica printed that looks like
82+
83+
[source,json]
84+
{
85+
"cluster": "simple-zk",
86+
"container": "zookeeper",
87+
"file": "zookeeper.log4j.xml",
88+
"level": "INFO",
89+
"logger": "org.apache.zookeeper.server.ZooKeeperServer",
90+
"message": "Server environment:zookeeper.version=3.8.0-5a02a05eddb59aee6ac762f7ea82e92a68eb9c0f, built on 2022-02-25 08:49 UTC",
91+
"namespace": "default",
92+
"pod": "simple-zk-server-default-0",
93+
"role": "server",
94+
"roleGroup": "default",
95+
"source_type": "vector",
96+
"timestamp": "2023-11-06T10:30:40.223Z"
97+
}
98+
99+
The JSON object contains a timestamp, the log message, log level and some additional information.
100+
101+
You can see the same log line in the log output of the ZooKeeper container:
102+
103+
[source]
104+
kubectl logs \
105+
--container=zookeeper simple-zk-server-default-0 \
106+
| grep "zookeeper.version="
107+
108+
[source]
109+
2023-11-06 10:30:40,223 [myid:1] - INFO [main:o.a.z.Environment@98] - Server environment:zookeeper.version=3.8.0-5a02a05eddb59aee6ac762f7ea82e92a68eb9c0f, built on 2022-02-25 08:49 UTC
110+
111+
Congratulations, this concludes the tutorial!
112+
113+
== What's next?
114+
115+
Look into different sink configurations which are more suited to production use in the https://vector.dev/docs/reference/configuration/sinks/[sinks overview documetation] or learn more about how logging works on the platform in the xref:concepts:logging.adoc[concepts documentation].

0 commit comments

Comments
 (0)