Skip to content

Commit 9d52956

Browse files
Merge pull request #23 from kube-logging/demo-openobserve
feat(demo): add demo using OpenObserve's OTLP GRPC ingestion
2 parents 065442c + 3f2c6c8 commit 9d52956

File tree

7 files changed

+326
-50
lines changed

7 files changed

+326
-50
lines changed

api/telemetry/v1alpha1/oteloutput_types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ type OtelOutputSpec struct {
3232

3333
// OTLP grpc exporter config ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go
3434
type OTLPgrpc struct {
35-
QueueConfig QueueSettings `json:"sending_queue,omitempty"`
36-
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty"`
37-
TimeoutSettings `json:",inline"`
38-
GRPCClientSettings `json:",inline"`
35+
QueueConfig QueueSettings `json:"sending_queue,omitempty" yaml:"sending_queue,omitempty"`
36+
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty" yaml:"retry_on_failure,omitempty"`
37+
TimeoutSettings `json:",inline" yaml:",inline"`
38+
GRPCClientSettings `json:",inline" yaml:",inline"`
3939
}
4040

4141
// OtelOutputStatus defines the observed state of OtelOutput
@@ -52,15 +52,15 @@ type OtelOutput struct {
5252
metav1.TypeMeta `json:",inline"`
5353
metav1.ObjectMeta `json:"metadata,omitempty"`
5454

55-
Spec OtelOutputSpec `json:"spec,omitempty"`
56-
Status OtelOutputStatus `json:"status,omitempty"`
55+
Spec OtelOutputSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
56+
Status OtelOutputStatus `json:"status,omitempty" `
5757
}
5858

5959
//+kubebuilder:object:root=true
6060

6161
// OtelOutputList contains a list of OtelOutput
6262
type OtelOutputList struct {
63-
metav1.TypeMeta `json:",inline"`
63+
metav1.TypeMeta `json:",inline" yaml:",inline"`
6464
metav1.ListMeta `json:"metadata,omitempty"`
6565
Items []OtelOutput `json:"items"`
6666
}

api/telemetry/v1alpha1/otlp_config.go

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,101 +23,101 @@ import (
2323
type TimeoutSettings struct {
2424
// Timeout is the timeout for every attempt to send data to the backend.
2525
// A zero timeout means no timeout.
26-
Timeout time.Duration `json:"timeout,omitempty"`
26+
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
2727
}
2828

2929
// QueueSettings defines configuration for queueing batches before sending to the consumerSender.
3030
type QueueSettings struct {
3131
// Enabled indicates whether to not enqueue batches before sending to the consumerSender.
32-
Enabled bool `json:"enabled,omitempty"`
32+
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
3333
// NumConsumers is the number of consumers from the queue.
34-
NumConsumers int `json:"num_consumers,omitempty"`
34+
NumConsumers int `json:"num_consumers,omitempty" yaml:"num_consumers,omitempty"`
3535
// QueueSize is the maximum number of batches allowed in queue at a given time.
36-
QueueSize int `json:"queue_size,omitempty"`
36+
QueueSize int `json:"queue_size,omitempty" yaml:"queue_size,omitempty"`
3737
// StorageID if not empty, enables the persistent storage and uses the component specified
3838
// as a storage extension for the persistent queue
39-
StorageID string `json:"storage,omitempty"` //TODO this is *component.ID at Otel
39+
StorageID string `json:"storage,omitempty" yaml:"storage,omitempty"` //TODO this is *component.ID at Otel
4040
}
4141

4242
// BackOffConfig defines configuration for retrying batches in case of export failure.
4343
// The current supported strategy is exponential backoff.
4444
type BackOffConfig struct {
4545
// Enabled indicates whether to not retry sending batches in case of export failure.
46-
Enabled bool `json:"enabled,omitempty"`
46+
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
4747
// InitialInterval the time to wait after the first failure before retrying.
48-
InitialInterval time.Duration `json:"initial_interval,omitempty"`
48+
InitialInterval time.Duration `json:"initial_interval,omitempty" yaml:"initial_interval,omitempty" `
4949
// RandomizationFactor is a random factor used to calculate next backoffs
5050
// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
51-
RandomizationFactor string `json:"randomization_factor,omitempty"`
51+
RandomizationFactor string `json:"randomization_factor,omitempty" yaml:"randomization_factor,omitempty"`
5252
// Multiplier is the value multiplied by the backoff interval bounds
53-
Multiplier string `json:"multiplier,omitempty"`
53+
Multiplier string `json:"multiplier,omitempty" yaml:"multiplier,omitempty"`
5454
// MaxInterval is the upper bound on backoff interval. Once this value is reached the delay between
5555
// consecutive retries will always be `MaxInterval`.
56-
MaxInterval time.Duration `json:"max_interval,omitempty"`
56+
MaxInterval time.Duration `json:"max_interval,omitempty" yaml:"max_interval,omitempty"`
5757
// MaxElapsedTime is the maximum amount of time (including retries) spent trying to send a request/batch.
5858
// Once this value is reached, the data is discarded. If set to 0, the retries are never stopped.
59-
MaxElapsedTime time.Duration `json:"max_elapsed_time,omitempty"`
59+
MaxElapsedTime time.Duration `json:"max_elapsed_time,omitempty" yaml:"max_elapsed_time,omitempty"`
6060
}
6161

6262
// KeepaliveClientConfig exposes the keepalive.ClientParameters to be used by the exporter.
6363
// Refer to the original data-structure for the meaning of each parameter:
6464
// https://godoc.org/google.golang.org/grpc/keepalive#ClientParameters
6565
type KeepaliveClientConfig struct {
66-
Time time.Duration `json:"time,omitempty"`
67-
Timeout time.Duration `json:"timeout,omitempty"`
68-
PermitWithoutStream bool `json:"permit_without_stream,omitempty"`
66+
Time time.Duration `json:"time,omitempty" yaml:"time,omitempty"`
67+
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
68+
PermitWithoutStream bool `json:"permit_without_stream,omitempty" yaml:"permit_without_stream,omitempty"`
6969
}
7070

7171
// GRPCClientSettings defines common settings for a gRPC client configuration.
7272
type GRPCClientSettings struct {
7373
// The target to which the exporter is going to send traces or metrics,
7474
// using the gRPC protocol. The valid syntax is described at
7575
// https://github.com/grpc/grpc/blob/master/doc/naming.md.
76-
Endpoint string `json:"endpoint"`
76+
Endpoint string `json:"endpoint" yaml:"endpoint"`
7777

7878
// The compression key for supported compression types within collector.
79-
Compression configcompression.CompressionType `json:"compression,omitempty"`
79+
Compression configcompression.CompressionType `json:"compression,omitempty" yaml:"compression,omitempty"`
8080

8181
// TLSSetting struct exposes TLS client configuration.
82-
TLSSetting TLSClientSetting `json:"tls,omitempty"`
82+
TLSSetting TLSClientSetting `json:"tls,omitempty" yaml:"tls,omitempty"`
8383

8484
// The keepalive parameters for gRPC client. See grpc.WithKeepaliveParams.
8585
// (https://godoc.org/google.golang.org/grpc#WithKeepaliveParams).
86-
Keepalive *KeepaliveClientConfig `json:"keepalive,omitempty"`
86+
Keepalive *KeepaliveClientConfig `json:"keepalive,omitempty" yaml:"keepalive,omitempty"`
8787

8888
// ReadBufferSize for gRPC client. See grpc.WithReadBufferSize.
8989
// (https://godoc.org/google.golang.org/grpc#WithReadBufferSize).
90-
ReadBufferSize int `json:"read_buffer_size,omitempty"`
90+
ReadBufferSize int `json:"read_buffer_size,omitempty" yaml:"read_buffer_size,omitempty"`
9191

9292
// WriteBufferSize for gRPC gRPC. See grpc.WithWriteBufferSize.
9393
// (https://godoc.org/google.golang.org/grpc#WithWriteBufferSize).
94-
WriteBufferSize int `json:"write_buffer_size,omitempty"`
94+
WriteBufferSize int `json:"write_buffer_size,omitempty" yaml:"write_buffer_size,omitempty"`
9595

9696
// WaitForReady parameter configures client to wait for ready state before sending data.
9797
// (https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md)
98-
WaitForReady bool `json:"wait_for_ready,omitempty"`
98+
WaitForReady bool `json:"wait_for_ready,omitempty" yaml:"wait_for_ready,omitempty"`
9999

100100
// The headers associated with gRPC requests.
101-
Headers map[string]string `json:"headers,omitempty"`
101+
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
102102

103103
// Sets the balancer in grpclb_policy to discover the servers. Default is pick_first.
104104
// https://github.com/grpc/grpc-go/blob/master/examples/features/load_balancing/README.md
105-
BalancerName string `json:"balancer_name,omitempty"`
105+
BalancerName string `json:"balancer_name,omitempty" yaml:"balancer_name,omitempty"`
106106

107107
// WithAuthority parameter configures client to rewrite ":authority" header
108108
// (godoc.org/google.golang.org/grpc#WithAuthority)
109-
Authority string `json:"authority,omitempty"`
109+
Authority string `json:"authority,omitempty" yaml:"authority,omitempty"`
110110

111111
// Auth configuration for outgoing RPCs.
112-
Auth string `json:"auth,omitempty"` //TODO this is a reference *configauth.Authentication
112+
Auth string `json:"auth,omitempty" yaml:"auth,omitempty"` //TODO this is a reference *configauth.Authentication
113113
}
114114

115115
// TLSClientSetting contains TLS configurations that are specific to client
116116
// connections in addition to the common configurations. This should be used by
117117
// components configuring TLS client connections.
118118
type TLSClientSetting struct {
119119
// squash ensures fields are correctly decoded in embedded struct.
120-
//TLSSetting `json:",inline"`
120+
TLSSetting `json:",inline" yaml:",inline"`
121121

122122
// These are config options specific to client connections.
123123

@@ -127,13 +127,13 @@ type TLSClientSetting struct {
127127
// (InsecureSkipVerify in the tls Config). Please refer to
128128
// https://godoc.org/crypto/tls#Config for more information.
129129
// (optional, default false)
130-
Insecure bool `json:"insecure,omitempty"`
130+
Insecure bool `json:"insecure,omitempty" yaml:"insecure,omitempty"`
131131
// InsecureSkipVerify will enable TLS but not verify the certificate.
132-
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`
132+
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty" yaml:"insecure_skip_verify,omitempty"`
133133
// ServerName requested by client for virtual hosting.
134134
// This sets the ServerName in the TLSConfig. Please refer to
135135
// https://godoc.org/crypto/tls#Config for more information. (optional)
136-
ServerName string `json:"server_name_override,omitempty"`
136+
ServerName string `json:"server_name_override,omitempty" yaml:"server_name_override,omitempty"`
137137
}
138138

139139
// TLSSetting exposes the common client and server TLS configurations.
@@ -143,32 +143,32 @@ type TLSSetting struct {
143143
// Path to the CA cert. For a client this verifies the server certificate.
144144
// For a server this verifies client certificates. If empty uses system root CA.
145145
// (optional)
146-
CAFile string `json:"ca_file,omitempty"`
146+
CAFile string `json:"ca_file,omitempty" yaml:"ca_file,omitempty"`
147147

148148
// In memory PEM encoded cert. (optional)
149-
CAPem string `json:"ca_pem,omitempty"`
149+
CAPem string `json:"ca_pem,omitempty" yaml:"ca_pem,omitempty"`
150150

151151
// Path to the TLS cert to use for TLS required connections. (optional)
152-
CertFile string `json:"cert_file,omitempty"`
152+
CertFile string `json:"cert_file,omitempty" yaml:"cert_file,omitempty"`
153153

154154
// In memory PEM encoded TLS cert to use for TLS required connections. (optional)
155-
CertPem string `json:"cert_pem,omitempty"`
155+
CertPem string `json:"cert_pem,omitempty" yaml:"cert_pem,omitempty"`
156156

157157
// Path to the TLS key to use for TLS required connections. (optional)
158-
KeyFile string `json:"key_file,omitempty"`
158+
KeyFile string `json:"key_file,omitempty" yaml:"key_file,omitempty"`
159159

160160
// In memory PEM encoded TLS key to use for TLS required connections. (optional)
161-
KeyPem string `json:"key_pem,omitempty"`
161+
KeyPem string `json:"key_pem,omitempty" yaml:"key_pem,omitempty"`
162162

163163
// MinVersion sets the minimum TLS version that is acceptable.
164164
// If not set, TLS 1.2 will be used. (optional)
165-
MinVersion string `json:"min_version,omitempty"`
165+
MinVersion string `json:"min_version,omitempty" yaml:"min_version,omitempty"`
166166

167167
// MaxVersion sets the maximum TLS version that is acceptable.
168168
// If not set, refer to crypto/tls for defaults. (optional)
169-
MaxVersion string `json:"max_version,omitempty"`
169+
MaxVersion string `json:"max_version,omitempty" yaml:"max_version,omitempty"`
170170

171171
// ReloadInterval specifies the duration after which the certificate will be reloaded
172172
// If not set, it will never be reloaded (optional)
173-
ReloadInterval time.Duration `json:"reload_interval,omitempty"`
173+
ReloadInterval time.Duration `json:"reload_interval,omitempty" yaml:"reload_interval,omitempty"`
174174
}

api/telemetry/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/telemetry.kube-logging.dev_oteloutputs.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,23 @@ spec:
165165
tls:
166166
description: TLSSetting struct exposes TLS client configuration.
167167
properties:
168+
ca_file:
169+
description: |-
170+
Path to the CA cert. For a client this verifies the server certificate.
171+
For a server this verifies client certificates. If empty uses system root CA.
172+
(optional)
173+
type: string
174+
ca_pem:
175+
description: In memory PEM encoded cert. (optional)
176+
type: string
177+
cert_file:
178+
description: Path to the TLS cert to use for TLS required
179+
connections. (optional)
180+
type: string
181+
cert_pem:
182+
description: In memory PEM encoded TLS cert to use for TLS
183+
required connections. (optional)
184+
type: string
168185
insecure:
169186
description: |-
170187
In gRPC when set to true, this is used to disable the client transport security.
@@ -178,6 +195,30 @@ spec:
178195
description: InsecureSkipVerify will enable TLS but not verify
179196
the certificate.
180197
type: boolean
198+
key_file:
199+
description: Path to the TLS key to use for TLS required connections.
200+
(optional)
201+
type: string
202+
key_pem:
203+
description: In memory PEM encoded TLS key to use for TLS
204+
required connections. (optional)
205+
type: string
206+
max_version:
207+
description: |-
208+
MaxVersion sets the maximum TLS version that is acceptable.
209+
If not set, refer to crypto/tls for defaults. (optional)
210+
type: string
211+
min_version:
212+
description: |-
213+
MinVersion sets the minimum TLS version that is acceptable.
214+
If not set, TLS 1.2 will be used. (optional)
215+
type: string
216+
reload_interval:
217+
description: |-
218+
ReloadInterval specifies the duration after which the certificate will be reloaded
219+
If not set, it will never be reloaded (optional)
220+
format: int64
221+
type: integer
181222
server_name_override:
182223
description: |-
183224
ServerName requested by client for virtual hosting.

docs/demos/openobserve/demo.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: collector
5+
---
6+
apiVersion: v1
7+
kind: Namespace
8+
metadata:
9+
labels:
10+
nsSelector: example-tenant
11+
name: example-tenant-ns
12+
---
13+
apiVersion: telemetry.kube-logging.dev/v1alpha1
14+
kind: Collector
15+
metadata:
16+
name: example-collector
17+
spec:
18+
controlNamespace: collector
19+
tenantSelector:
20+
matchLabels:
21+
collectorLabel: example-collector
22+
---
23+
apiVersion: telemetry.kube-logging.dev/v1alpha1
24+
kind: Tenant
25+
metadata:
26+
labels:
27+
collectorLabel: example-collector
28+
name: example-tenant
29+
spec:
30+
subscriptionNamespaceSelectors:
31+
- matchLabels:
32+
nsSelector: example-tenant
33+
logSourceNamespaceSelectors:
34+
- matchLabels:
35+
nsSelector: example-tenant
36+
---
37+
apiVersion: telemetry.kube-logging.dev/v1alpha1
38+
kind: Subscription
39+
metadata:
40+
name: subscription-sample-1
41+
namespace: example-tenant-ns
42+
spec:
43+
ottl: 'route()'
44+
outputs:
45+
- name: otlp-openobserve
46+
namespace: collector
47+
---
48+
apiVersion: telemetry.kube-logging.dev/v1alpha1
49+
kind: Subscription
50+
metadata:
51+
name: subscription-sample-2
52+
namespace: example-tenant-ns
53+
spec:
54+
ottl: 'route()'
55+
outputs:
56+
- name: otlp-openobserve
57+
namespace: collector
58+
---
59+
apiVersion: telemetry.kube-logging.dev/v1alpha1
60+
kind: OtelOutput
61+
metadata:
62+
name: otlp-openobserve
63+
namespace: collector
64+
spec:
65+
otlp:
66+
endpoint: openobserve-otlp-grpc.openobserve.svc.cluster.local:5081
67+
headers:
68+
# echo -n username:org_pwd | base64
69+
Authorization: "Basic cm9vdEBleGFtcGxlLmNvbTpkREN6Z213eVVkMTlmVzZs"
70+
organization: default
71+
stream-name: default
72+
tls:
73+
insecure: true

0 commit comments

Comments
 (0)