Add Native Syslog support to CloudWatch Agent - #2125
Conversation
|
This PR was marked stale due to lack of activity. |
|
This PR was marked stale due to lack of activity. |
|
This PR was marked stale due to lack of activity. |
|
This PR was marked stale due to lack of activity. |
| } | ||
|
|
||
| func escapeOTTL(s string) string { | ||
| s = strings.ReplaceAll(s, `\`, `\\`) |
There was a problem hiding this comment.
escapeOTTL escapes backslashes and double-quotes, which stops a value from breaking out of the string literal — but any other regex metacharacters in a hostname, app-name, or filter expression still flow through into IsMatch. Since these values end up in a regex, I'd escape the full metacharacter set (or regexp.QuoteMeta the user input before interpolating) so a stray character can't silently change what a rule matches. This overlaps with the glob comment above — handling it once at the point we build the condition string can cover both.
| - logs/syslog_0_default | ||
| error_mode: ignore | ||
| table: | ||
| - condition: IsMatch(attributes["hostname"], "web-*") |
There was a problem hiding this comment.
The golden has IsMatch(attributes["hostname"], "web-*") (raw glob), but globToRegex emits "^web-.*$". It also omits max_log_size: 65536 which the translator hardcodes for TCP receivers. Should this file be regenerated from the translator output to keep it in sync?
| listener["listen_address"] = addr | ||
| } else { | ||
| // No listen_address specified — construct default based on TLS presence | ||
| if _, hasTLS := syslogConf["tls"]; hasTLS { |
There was a problem hiding this comment.
Both branches of this TLS check produce the same value:
if _, hasTLS := syslogConf["tls"]; hasTLS {
listener["listen_address"] = "tcp://"
} else {
listener["listen_address"] = "tcp://"
}Was the intention to default to "udp://" for the non-TLS case (since UDP does not support TLS)?
|
This PR was marked stale due to lack of activity. |
Description of the issue
The current CloudWatch Agent has no support for native syslog support. This means customers who have Syslog sources and using the CWA must use some other agent, some other bridging application, or write syslog to disk and have the CWA read those files. This adds complexity to customer configurations that want to use CWA or alternatively customers will use other agents.
Description of changes
This change adds native Syslog support to the CloudWatch Agent. Customers are able to define multiple Syslog listeners using tcp/udp and add various filters and routing rules to ensure log entries land on the correct log groups. These changes support both Syslog format RFCs, 5424 as well as legacy RFC 3164. Additionally, support for server and client side TLS support is included as part of the listener.
The changes are broken down in the following areas:
section level.
IsMatch(attributes["appname"], "...")).
collisions.
Example Config:
License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
translator/translate/otel/pipeline/syslogtranslator_test.go
TestNewTranslatorsNilConfTestNewTranslatorsNoSyslogKeyTestNewTranslatorsSingleListenerNoRulesTestNewTranslatorsWithRoutingRulesTestInputPipelineTranslateTestOutputPipelineTranslateTestDeriveReceiverNameTestBuildOTTLConditionTestIsGlobPatternTestToFiltersTestNewTranslatorsWithTLSTestFilterProcessorTranslator_IDTestFilterProcessorTranslator_TranslateTestRoutingConnectorTranslator_IDTestRoutingConnectorTranslator_TranslateTestSigV4AuthTranslator_IDTestSigV4AuthTranslator_TranslateTestSigV4AuthTranslator_NoRoleARNTestBuildFilterConditionsTestNewTranslatorsMultiSectionTestNewTranslatorsArrayFormSingleSectionTestNewTranslatorsDuplicateListenerAcrossSectionsTestNewTranslatorsUniqueListenersAcrossSectionsTestProvisionerTranslator_IDTestProvisionerTranslator_TranslateTestProvisionerTranslator_ZeroRetentionexporter_test.go
TestCWLExporterTranslator_IDTestCWLExporterTranslator_TranslateTestOTLPExporterTranslator_IDTestOTLPExporterTranslator_TranslateTestOTLPExporterTranslator_EndpointOverrideTestNewExporterTranslator_Dispatchtranslator/translate/otel/receiver/syslogTestTranslatorIDTestTranslateTCPTestTranslateUDPTestTranslateInvalidAddressTestTranslateUnsupportedProtocolTestTranslateRFC3164TestTranslateDefaultProtocolTestTranslateTCPWithTLSTestTranslateTCPWithClientCAFileTestTranslateUDPIgnoresTLSTestParseListenAddresstranslator/config— Schema ValidationTestSyslogSchema_SingleListenerTestSyslogSchema_MultipleListenersTestSyslogSchema_WithRoutingTestSyslogSchema_WithFiltersTestSyslogSchema_WithTLSTestSyslogSchema_WithProtocolTestSyslogSchema_WithRetentionTestSyslogSchema_FullConfigTestSyslogSchema_InvalidTopLevelKeyTestSyslogSchema_MissingListenAddressTestSyslogSchema_MissingLogGroupNameTestSyslogSchema_InvalidProtocolTestSyslogSchema_InvalidTLSMinVersionTestSyslogSchema_InvalidRetentionTestSyslogSchema_InvalidFacilityTestSyslogSchema_RoutingMissingMatchTestSyslogSchema_RoutingMissingLogGroupTestSyslogSchema_RoutingEmptyMatchTestSyslogSchema_UnknownListenerFieldTestSyslogSchema_UnknownTLSFieldTestSyslogSchema_WithClientCAFileTestSyslogSchema_UnknownMatchFieldTestSyslogSchema_ArrayForm_SingleSectionTestSyslogSchema_ArrayForm_MultipleSectionsTestSyslogSchema_ArrayForm_EmptyArrayTestSyslogSchema_ArrayForm_InvalidSectiontranslator/tocwconfig— End-to-EndTestSyslogConfigRequirements
Before commiting your code, please do the following steps.
make fmtandmake fmt-shmake lintIntegration Tests
To run integration tests against this PR, add the
ready for testinglabel.