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
- Check out the [examples](examples) directory to see how to configure `SpiceDBCluster` for production, including datastore backends, TLS, and Ingress.
83
+
- Check out the [examples](examples) directory to see how to configure `SpiceDBCluster` for production, including datastore backends, TLS, Ingress, and operator features like JSON logging.
84
84
- Learn how to use SpiceDB via the [docs](https://docs.authzed.com/) and [playground](https://play.authzed.com/).
85
85
- Ask questions and join the community in [discord](https://authzed.com/discord).
This example demonstrates how to configure the SpiceDB Operator to output logs in JSON format, which is useful for integration with log aggregation systems like ELK (Elasticsearch, Logstash, Kibana) stack, Splunk, or other structured logging solutions.
4
+
5
+
## Overview
6
+
7
+
By default, the SpiceDB Operator uses a text-based log format. However, for production environments where logs need to be parsed and analyzed by log aggregation systems, JSON format is often preferred.
8
+
9
+
## Configuration
10
+
11
+
### Using the Command Line Flag
12
+
13
+
The simplest way to enable JSON logging is by using the `--log-format` flag when starting the operator:
14
+
15
+
```bash
16
+
spicedb-operator run --log-format=json
17
+
```
18
+
19
+
### In Kubernetes Deployment
20
+
21
+
To enable JSON logging in a Kubernetes deployment, modify the operator's deployment manifest:
22
+
23
+
```yaml
24
+
apiVersion: apps/v1
25
+
kind: Deployment
26
+
metadata:
27
+
name: spicedb-operator
28
+
namespace: spicedb-operator
29
+
spec:
30
+
template:
31
+
spec:
32
+
containers:
33
+
- name: spicedb-operator
34
+
image: authzed/spicedb-operator:latest
35
+
args:
36
+
- "run"
37
+
- "--log-format=json"
38
+
# ... other flags
39
+
```
40
+
41
+
## Log Format Comparison
42
+
43
+
### Text Format (Default)
44
+
```
45
+
2024-01-15T10:30:45.123Z INFO controller Reconciling SpiceDBCluster {"namespace": "default", "name": "my-spicedb"}
46
+
2024-01-15T10:30:45.456Z INFO controller Created deployment {"namespace": "default", "name": "my-spicedb-spicedb"}
1.**Filebeat Configuration**: Configure Filebeat to read the operator logs:
60
+
```yaml
61
+
filebeat.inputs:
62
+
- type: container
63
+
paths:
64
+
- /var/log/containers/spicedb-operator-*.log
65
+
processors:
66
+
- decode_json_fields:
67
+
fields: ["message"]
68
+
target: ""
69
+
overwrite_keys: true
70
+
```
71
+
72
+
2. **Logstash Pipeline**: No special parsing is needed as the logs are already structured.
73
+
74
+
3. **Kibana**: You can directly query and visualize the structured log fields.
75
+
76
+
## Benefits
77
+
78
+
- **Structured Data**: Each log entry is a valid JSON object with consistent fields
79
+
- **Easy Parsing**: No need for complex regular expressions to parse log entries
80
+
- **Better Search**: Log aggregation systems can index individual fields for faster searching
81
+
- **Standardized Format**: Compatible with most modern logging infrastructure
82
+
- **Machine-Readable**: Easier to process logs programmatically for alerting or analysis
83
+
84
+
## Complete Example
85
+
86
+
See the [operator-with-json-logging.yaml](operator-with-json-logging.yaml) file for a complete example of deploying the SpiceDB Operator with JSON logging enabled.
0 commit comments