Skip to content

Commit

Permalink
Merge pull request #1227 from kube-logging/feature/syslog_mqtt
Browse files Browse the repository at this point in the history
MQTT support for syslog-ng
  • Loading branch information
ahma authored Mar 3, 2023
2 parents 8bd0eaf + 3d3243d commit f162b2c
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ test-e2e: ${KIND} docker-build generate fmt vet manifests ## Run E2E tests

.PHONY: tidy
tidy: ## Tidy Go modules
find . -iname "go.mod" | xargs -L1 sh -c 'cd $$(dirname $$0); go mod tidy'
find . -iname "go.mod" -not -path "./.devcontainer/*" | xargs -L1 sh -c 'cd $$(dirname $$0); go mod tidy'

.PHONY: vet
vet: ## Run go vet against code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,19 @@ spec:
required:
- token
type: object
mqtt:
properties:
address:
type: string
fallback-topic:
type: string
qos:
type: integer
template:
type: string
topic:
type: string
type: object
sumologic-http:
properties:
batch-bytes:
Expand Down
13 changes: 13 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_syslogngoutputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,19 @@ spec:
required:
- token
type: object
mqtt:
properties:
address:
type: string
fallback-topic:
type: string
qos:
type: integer
template:
type: string
topic:
type: string
type: object
sumologic-http:
properties:
batch-bytes:
Expand Down
1 change: 1 addition & 0 deletions pkg/sdk/logging/api/v1beta1/syslogng_output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type SyslogNGOutputSpec struct {
Loggly *output.Loggly `json:"loggly,omitempty" syslog-ng:"dest-drv"`
Syslog *output.SyslogOutput `json:"syslog,omitempty" syslog-ng:"dest-drv"`
File *output.FileOutput `json:"file,omitempty" syslog-ng:"dest-drv"`
MQTT *output.MQTT `json:"mqtt,omitempty" syslog-ng:"dest-drv"`
SumologicHTTP *output.SumologicHTTPOutput `json:"sumologic-http,omitempty" syslog-ng:"dest-drv"`
SumologicSyslog *output.SumologicSyslogOutput `json:"sumologic-syslog,omitempty" syslog-ng:"dest-drv"`
HTTP *output.HTTPOutput `json:"http,omitempty" syslog-ng:"dest-drv"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions pkg/sdk/logging/model/syslogng/output/mqtt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright © 2022 Cisco Systems, Inc. and/or its affiliates
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package output

// +name:"MQTT"
// +weight:"200"
type _hugoMQTT interface{} //nolint:deadcode,unused

// +docName:"Sending messages from a local network to an MQTT broker"
//
// ## Prerequisites
//
// ## Example
//
// {{< highlight yaml >}}
// apiVersion: logging.banzaicloud.io/v1beta1
// kind: SyslogNGOutput
// metadata:
//
// name: mqtt
// namespace: default
//
// spec:
//
// mqtt:
// address: tcp://mosquitto:1883
// template: |
// $(format-json --subkeys json~ --key-delimiter ~)
// topic: test/demo
//
// {{</ highlight >}}
type _docMQTT interface{} //nolint:deadcode,unused

// +name:"MQTT Destination"
// +url:"https://www.syslog-ng.com/technical-documents/doc/syslog-ng-open-source-edition/3.37/administration-guide/45#TOPIC-1829079"
// +description:"Sending messages over MQTT Protocol"
// +status:"Testing"
type _metaMQTT interface{} //nolint:deadcode,unused

// +kubebuilder:object:generate=true
type MQTT struct {
// Address of the destination host
Address string `json:"address,omitempty"`
// Topic defines in which topic syslog-ng stores the log message. You can also use templates here, and use, for example, the $HOST macro in the topic name hierarchy.
Topic string `json:"topic,omitempty"`
// fallback-topic is used when syslog-ng cannot post a message to the originally defined topic (which can include invalid characters coming from templates).
FallbackTopic string `json:"fallback-topic,omitempty"`
// Template where you can configure the message template sent to the MQTT broker. By default, the template is: “$ISODATE $HOST $MSGHDR$MSG”
Template string `json:"template,omitempty"`
// qos stands for quality of service and can take three values in the MQTT world. Its default value is 0, where there is no guarantee that the message is ever delivered.
QOS int `json:"qos,omitempty"`
}
15 changes: 15 additions & 0 deletions pkg/sdk/logging/model/syslogng/output/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f162b2c

Please sign in to comment.