Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
g41797 committed Oct 29, 2023
1 parent d272fc8 commit 171d369
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 25 deletions.
104 changes: 103 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,109 @@ Examples of producer:
- [producer for NATS](https://github.com/g41797/syslog2nats/blob/main/msgproducer.go)
- [producer for Memphis](https://github.com/g41797/memphis-protocol-adapter/blob/master/pkg/syslog/msgproducer.go)


## Advanced configuration

[syslog.conf](https://linux.die.net/man/5/syslog.conf) file contains logging rules for syslogd.

syslogsidecar support similar functionality via *syslogconf.json* file within configurations folder.

*syslogconf.json* file should be provided by developer of the syslogsidecar for specific broker.


Example of syslogconf.json used by syslogsidecar in e2e test:
```json
[
{
"Selector": "local0.err,crit,alert,emerg",
"Target": "app-critical"
},
{
"Selector": "info,notice",
"Target": "informative_station"
},
{
"Selector": "err,crit,alert",
"Target": "system critical subjects"
},
{
"Selector": "kern",
"Target": "kernel-logs"
},
{
"Selector": "emerg",
"Target": "emergency messages"
},
{
"Selector": "data",
"Target": "badmessages-topic"
},
]
```


*Selector* contains rule based on facilities and or severities of the message in question.

*Target* contains where message should be published to. It may be topic, station, subject, folder, etc - it depends on functionality of specific broker.

E.g. for the configuration above:

All *local0* messages with severity from the list *err,crit,alert,emerg* should be published to "app-critical"

```json
{
"Selector": "local0.err,crit,alert,emerg",
"Target": "app-critical"
},
```

Message with severity info or notice should be published to "informative_station"
```json
{
"Selector": "info,notice",
"Target": "informative_station"
}
```


All kernel messages should be published to "kernel-logs"
```json
{
"Selector": "kern",
"Target": "kernel-logs"
}
```

All badly formatted messages should be published to "badmessages-topic"
```json
{
"Selector": "data",
"Target": "badmessages-topic"
}
```

List of targets for the message producer can get from *syslogsidecar.Targets* function:
```go
// Returns list of "targets" for the message according to facility and severity
// of the message and content of syslogconf.json file.
// Usually error returned for the case of absent or wrong syslogconf.json file.
// nil, nil - means no defined targets for the message.
// Decision for this case on producer, e.g. use default target(topic, station, etc)
// Sidecar transfers targets to producer with solely processing -
// trim spaces on both sides of the string.
// Target may be any non-empty valid for JSON format string.
func Targets(msg sputnik.Msg) ([]string, error)
```

Example of possible usage by producer:
```go
.......................................
topics, _ := syslogsidecar.Targets(msg)

for _, topic := range topics {
mpr.produceToTopic(msg, topic)
}
.......................................
```

## Implementations are based on syslogsidecar

Expand Down
2 changes: 1 addition & 1 deletion e2e/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func syslogClientBlockFactory() *sputnik.Block {
return block
}

const max_LOG_MESSAGES = 50 // was 1000000
const max_LOG_MESSAGES = 1000000

type client struct {
conf syslogsidecar.SyslogConfiguration
Expand Down
45 changes: 22 additions & 23 deletions internal/cmd/syslog-e2e/conf/syslogconf.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
[
{
"Selector": "data",
"Target": "badmessages-topic"
},
{
"Selector": "local0.err,crit,alert,emerg",
"Target": "app-critical"
},
{
"Selector": "info,notice",
"Target": "informative_station"
},
{
"Selector": "err,crit,alert",
"Target": "system critical subjects"
},
{
"Selector": "kern.warning",
"Target": "kern/warning"
},
{
"Selector": "data",
"Target": "badmessages-topic"
},
{
"Selector": "local0.err,crit,alert,emerg",
"Target": "app-critical"
},
{
"Selector": "info,notice",
"Target": "informative_station"
},
{
"Selector": "err,crit,alert",
"Target": "system critical subjects"
},
{
"Selector": "kern.warning",
"Target": "kern/warning"
},
{
"Selector": "emerg",
"Target": "emergency messages"
}
]

}
]

0 comments on commit 171d369

Please sign in to comment.