Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set source name and category in the FluentD output for events #2222

Merged
merged 3 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- fix: set source name and category in the FluentD output for events [#2222][#2222]
- docs: FluentD buffer size configuration [#2232][#2232]

[#2232]: https://github.com/SumoLogic/sumologic-kubernetes-collection/pull/2232
[#2222]: https://github.com/SumoLogic/sumologic-kubernetes-collection/pull/2222
[Unreleased]: https://github.com/SumoLogic/sumologic-kubernetes-collection/compare/v2.6.0...main

## [v2.7.0][v2.7.0]
Expand Down
1 change: 1 addition & 0 deletions deploy/docs/Installation_with_Helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ The following parameter is optional, but we recommend setting it.

- __sumologic.clusterName__ - An identifier for your Kubernetes cluster.
This is the name you will see for the cluster in Sumo Logic. Default is `kubernetes`.
Whitespaces in the cluster name will be replaced with dashes.

To install the chart, first add the `sumologic` private repo:

Expand Down
1 change: 1 addition & 0 deletions deploy/docs/existingPrometheusDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The following parameter is optional, but we recommend setting it.

- __sumologic.clusterName__ - An identifier for your Kubernetes cluster.
This is the name you will see for the cluster in Sumo Logic. Default is `kubernetes`.
Whitespaces in the cluster name will be replaced with dashes.

To install the chart, first add the `sumologic` private repo:

Expand Down
2 changes: 1 addition & 1 deletion deploy/docs/standAlonePrometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ If you are installing the collection in a cluster that requires proxying outboun

The following parameter is optional, but we recommend setting it.

- __sumologic.clusterName__ - An identifier for your Kubernetes cluster. This is the name you will see for the cluster in Sumo Logic. Default is `kubernetes`.
- __sumologic.clusterName__ - An identifier for your Kubernetes cluster. This is the name you will see for the cluster in Sumo Logic. Default is `kubernetes`. Whitespaces in the cluster name will be replaced with dashes.

To install the chart, first add the `sumologic` private repo:

Expand Down
3 changes: 2 additions & 1 deletion deploy/helm/sumologic/README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions deploy/helm/sumologic/conf/events/events.conf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
@id sumologic.endpoint.events
sumo_client {{ include "sumologic.sumo_client" . | quote }}
endpoint "#{ENV['SUMO_ENDPOINT_DEFAULT_EVENTS_SOURCE']}"
source_name {{ .Values.fluentd.events.sourceName }}
source_category {{ .Values.fluentd.events.source_category | default (printf "%s/%s" (include "sumologic.clusterNameReplaceSpaceWithDash" .) (.Values.fluentd.events.sourceName ))}}
data_type logs
disable_cookies true
verify_ssl {{ .Values.fluentd.verifySsl | quote }}
Expand Down
3 changes: 0 additions & 3 deletions deploy/helm/sumologic/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,6 @@ Example usage:
resource "sumologic_http_source" "{{ .Name }}" {
name = local.{{ .Name }}
collector_id = sumologic_collector.collector.id
{{- if $source.category }}
category = {{ if $ctx.fluentd.events.sourceCategory }}{{ $ctx.fluentd.events.sourceCategory | quote }}{{- else}}{{ "\"${var.cluster_name}/${local.default_events_source}\"" }}{{- end}}
{{- end }}
{{- if $source.properties }}
{{- range $fkey, $fvalue := $source.properties }}
{{- include "terraform.generate-object" (dict "Name" $fkey "Value" $fvalue "KeyLength" (include "terraform.max-key-length" $source.properties) "Indent" 2) -}}
Expand Down
5 changes: 3 additions & 2 deletions deploy/helm/sumologic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ sumologic:
default:
name: events
config-name: endpoint-events
category: true
traces:
default:
name: traces
Expand Down Expand Up @@ -909,8 +908,10 @@ fluentd:
## Override output section for events. Leave empty for the default output section
overrideOutputConf: |-

## Source name for the Events source. Default: "events"
sourceName: "events"
## Source category for the Events source. Default: "{clusterName}/events"
sourceCategory: ""
# sourceCategory: "kubernetes/events"
## Override Kubernetes resource types you want to get events for from different Kubernetes
## API versions. The key represents the name of the resource type and the value represents
## the API version.
Expand Down
2 changes: 2 additions & 0 deletions tests/helm/events/static/apiServerUrl.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ data:
@id sumologic.endpoint.events
sumo_client "k8s_%CURRENT_CHART_VERSION%"
endpoint "#{ENV['SUMO_ENDPOINT_DEFAULT_EVENTS_SOURCE']}"
source_name events
source_category kubernetes/events
data_type logs
disable_cookies true
verify_ssl "true"
Expand Down
2 changes: 2 additions & 0 deletions tests/helm/events/static/apiServerUrl_null.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ data:
@id sumologic.endpoint.events
sumo_client "k8s_%CURRENT_CHART_VERSION%"
endpoint "#{ENV['SUMO_ENDPOINT_DEFAULT_EVENTS_SOURCE']}"
source_name events
source_category kubernetes/events
data_type logs
disable_cookies true
verify_ssl "true"
Expand Down
2 changes: 2 additions & 0 deletions tests/helm/events/static/default.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ data:
@id sumologic.endpoint.events
sumo_client "k8s_%CURRENT_CHART_VERSION%"
endpoint "#{ENV['SUMO_ENDPOINT_DEFAULT_EVENTS_SOURCE']}"
source_name events
source_category kubernetes/events
data_type logs
disable_cookies true
verify_ssl "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ data:
@id sumologic.endpoint.events
sumo_client "k8s_%CURRENT_CHART_VERSION%"
endpoint "#{ENV['SUMO_ENDPOINT_DEFAULT_EVENTS_SOURCE']}"
source_name events
source_category kubernetes/events
data_type logs
disable_cookies true
verify_ssl "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ data:
@id sumologic.endpoint.events
sumo_client "k8s_%CURRENT_CHART_VERSION%"
endpoint "#{ENV['SUMO_ENDPOINT_DEFAULT_EVENTS_SOURCE']}"
source_name events
source_category kubernetes/events
data_type logs
disable_cookies true
verify_ssl "true"
Expand Down
1 change: 0 additions & 1 deletion tests/helm/terraform/static/all_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ data:
resource "sumologic_http_source" "default_events_source" {
name = local.default_events_source
collector_id = sumologic_collector.collector.id
category = "${var.cluster_name}/${local.default_events_source}"
}

resource "sumologic_http_source" "default_logs_source" {
Expand Down
1 change: 0 additions & 1 deletion tests/helm/terraform/static/collector_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ data:
resource "sumologic_http_source" "default_events_source" {
name = local.default_events_source
collector_id = sumologic_collector.collector.id
category = "${var.cluster_name}/${local.default_events_source}"
}

resource "sumologic_http_source" "default_logs_source" {
Expand Down
1 change: 0 additions & 1 deletion tests/helm/terraform/static/default.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ data:
resource "sumologic_http_source" "default_events_source" {
name = local.default_events_source
collector_id = sumologic_collector.collector.id
category = "${var.cluster_name}/${local.default_events_source}"
}

resource "sumologic_http_source" "default_logs_source" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ data:
resource "sumologic_http_source" "default_events_source" {
name = local.default_events_source
collector_id = sumologic_collector.collector.id
category = "${var.cluster_name}/${local.default_events_source}"
}

resource "sumologic_http_source" "default_logs_source" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ data:
resource "sumologic_http_source" "default_events_source" {
name = local.default_events_source
collector_id = sumologic_collector.collector.id
category = "${var.cluster_name}/${local.default_events_source}"
}

resource "sumologic_http_source" "default_logs_source" {
Expand Down
18 changes: 17 additions & 1 deletion tests/integration/helm_default_installation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func Test_Helm_Default_FluentD_Metadata(t *testing.T) {
tickDuration = 3 * time.Second
waitDuration = 5 * time.Minute
logsGeneratorCount uint = 1000
expectedEventCount uint = 100
)
expectedMetrics := internal.DefaultExpectedMetrics

Expand Down Expand Up @@ -356,5 +357,20 @@ func Test_Helm_Default_FluentD_Metadata(t *testing.T) {
Teardown(stepfuncs.KubectlDeleteNamespaceOpt(internal.LogsGeneratorNamespace)).
Feature()

testenv.Test(t, featInstall, featMetrics, featLogs)
featEvents := features.New("events").
Assess("events present", stepfuncs.WaitUntilExpectedLogsPresent(
expectedEventCount,
map[string]string{
"_sourceName": "events",
"_sourceCategory": fmt.Sprintf("%s/events", internal.ClusterName),
},
internal.ReceiverMockNamespace,
internal.ReceiverMockServiceName,
internal.ReceiverMockServicePort,
waitDuration,
tickDuration,
)).
Feature()

testenv.Test(t, featInstall, featMetrics, featLogs, featEvents)
}
4 changes: 4 additions & 0 deletions tests/integration/internal/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const (

YamlPathReceiverMock = "yamls/receiver-mock.yaml"

// default cluster name in Helm chart Config
// TODO: read this from values.yaml used for the test directly
ClusterName = "kubernetes"

ReceiverMockServicePort = 3000
ReceiverMockServiceName = "receiver-mock"
ReceiverMockNamespace = "receiver-mock"
Expand Down