From 65a3b1f567befafc705535e6f6468fd97309126e Mon Sep 17 00:00:00 2001 From: Andrew Crump Date: Fri, 27 Oct 2023 21:52:51 +0000 Subject: [PATCH] Include optional environment identifier - Operators are already able to tag emitted log lines with the BOSH Director name with the `director` structured data parameter. - Add a new `environment` structured data parameter for cases where log lines should be tagged with an operator provided string but need to vary from the director name. - Don't add the environment SD-PARAM when the BOSH property is not provided by the operator. This prevents any log parsing breakage that might occur if log processors were to be string matching rather than parsing syslog messages correctly. Signed-off-by: Carson Long --- jobs/syslog_forwarder_windows/spec | 4 +++- .../templates/blackbox_config.yml.erb | 3 +++ tests/acceptance_test.go | 2 +- tests/manifests/tcp.yml | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jobs/syslog_forwarder_windows/spec b/jobs/syslog_forwarder_windows/spec index 52bb7e0..6a94266 100644 --- a/jobs/syslog_forwarder_windows/spec +++ b/jobs/syslog_forwarder_windows/spec @@ -19,7 +19,9 @@ properties: String to be used in "director" field in structured data of forwarded logs. default: "" - + syslog.environment: + description: "Optional environment identifier" + default: "" syslog.transport: description: > Protocol that will be used when forwarding loglines diff --git a/jobs/syslog_forwarder_windows/templates/blackbox_config.yml.erb b/jobs/syslog_forwarder_windows/templates/blackbox_config.yml.erb index 4c3e733..b741c2c 100644 --- a/jobs/syslog_forwarder_windows/templates/blackbox_config.yml.erb +++ b/jobs/syslog_forwarder_windows/templates/blackbox_config.yml.erb @@ -36,6 +36,9 @@ structured_data_id: "instance@47450" structured_data_map: deployment: <%= spec.deployment %> director: <%= p('syslog.director') %> +<% if p('syslog.environment') != '' -%> + environment: "<%= p('syslog.environment') %>" +<% end -%> group: <%= spec.name %> az: <%= spec.az %> id: <%= spec.id %> diff --git a/tests/acceptance_test.go b/tests/acceptance_test.go index a783f3d..28c0959 100644 --- a/tests/acceptance_test.go +++ b/tests/acceptance_test.go @@ -20,7 +20,7 @@ var _ = Describe("Forwarding Loglines", func() { }) It("annotates logs with structured data specific to the instance", func() { - ExpectedStructuredDataRegexp := fmt.Sprintf("\\[instance@47450 az=\".*\" deployment=\"%s\" director=\"test-env\" group=\"forwarder\" id=\".*\"\\]", DeploymentName()) + ExpectedStructuredDataRegexp := fmt.Sprintf(`\[instance@47450 az=".*" deployment="%s" director="test-env" environment="some-environment-identifier" group="forwarder" id=".*"\]`, DeploymentName()) message := counterString(500, "A") Eventually(WriteToTestFile(message)).Should(MatchRegexp(ExpectedStructuredDataRegexp)) }) diff --git a/tests/manifests/tcp.yml b/tests/manifests/tcp.yml index d7cbb93..133532a 100644 --- a/tests/manifests/tcp.yml +++ b/tests/manifests/tcp.yml @@ -31,6 +31,7 @@ instance_groups: properties: syslog: director: "test-env" + environment: "some-environment-identifier" - name: enable_ssh release: windows-utilities - name: enable_rdp