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 cluster field in metadata pipelines #2284

Merged
merged 1 commit into from
May 24, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- fix: set cluster field in metadata pipelines [#2284][#2284]

[#2284]: https://github.com/SumoLogic/sumologic-kubernetes-collection/pull/2284
[Unreleased]: https://github.com/SumoLogic/sumologic-kubernetes-collection/compare/v2.8.0...main

## [v2.8.0]

### Released 2022-05-10
Expand Down
7 changes: 7 additions & 0 deletions deploy/helm/sumologic/conf/events/events.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
<match fluentd.**>
@type null
</match>
# Set `cluster` metadata field
<filter **>
@type record_modifier
<record>
_sumo_metadata ${ {:fields => "cluster={{ template "sumologic.clusterNameReplaceSpaceWithDash" . }}"} }
</record>
</filter>
# expose the Fluentd metrics to Prometheus
<source>
@type prometheus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
@include logs.kubernetes.sumologic.filter.conf
exclude_namespace_regex {{ include "fluentd.excludeNamespaces" . }}
</filter>
<filter **>
@type record_modifier
<record>
_sumo_metadata ${record["_sumo_metadata"][:fields] = record["_sumo_metadata"].fetch(:fields, "").split(",").append("cluster={{ template "sumologic.clusterNameReplaceSpaceWithDash" . }}").join(","); record["_sumo_metadata"]}
</record>
</filter>
{{- .Values.fluentd.logs.containers.extraOutputPluginConf | nindent 4 }}
{{ if .Values.fluentd.logs.containers.overrideOutputConf }}
{{ .Values.fluentd.logs.containers.overrideOutputConf | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
exclude_priority_regex {{ .Values.fluentd.logs.default.excludePriorityRegex | quote }}
exclude_unit_regex {{ .Values.fluentd.logs.default.excludeUnitRegex | quote }}
</filter>
<filter **>
@type record_modifier
<record>
_sumo_metadata ${record["_sumo_metadata"][:fields] = record["_sumo_metadata"].fetch(:fields, "").split(",").append("cluster={{ template "sumologic.clusterNameReplaceSpaceWithDash" . }}").join(","); record["_sumo_metadata"]}
</record>
</filter>
{{- .Values.fluentd.logs.default.extraOutputPluginConf | nindent 4 }}
<match **>
@type copy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
exclude_priority_regex {{ .Values.fluentd.logs.kubelet.excludePriorityRegex | quote }}
exclude_unit_regex {{ .Values.fluentd.logs.kubelet.excludeUnitRegex | quote }}
</filter>
<filter **>
@type record_modifier
<record>
_sumo_metadata ${record["_sumo_metadata"][:fields] = record["_sumo_metadata"].fetch(:fields, "").split(",").append("cluster={{ template "sumologic.clusterNameReplaceSpaceWithDash" . }}").join(","); record["_sumo_metadata"]}
</record>
</filter>
{{- .Values.fluentd.logs.kubelet.extraOutputPluginConf | nindent 4 }}
{{ if .Values.fluentd.logs.kubelet.overrideOutputConf }}
{{ .Values.fluentd.logs.kubelet.overrideOutputConf | nindent 4}}
Expand Down Expand Up @@ -78,6 +84,12 @@
_sumo_metadata ${record["_sumo_metadata"][:source] = tag_parts[1]; record["_sumo_metadata"]}
</record>
</filter>
<filter **>
@type record_modifier
<record>
_sumo_metadata ${record["_sumo_metadata"][:fields] = record["_sumo_metadata"].fetch(:fields, "").split(",").append("cluster={{ template "sumologic.clusterNameReplaceSpaceWithDash" . }}").join(","); record["_sumo_metadata"]}
</record>
</filter>
{{- .Values.fluentd.logs.systemd.extraOutputPluginConf | nindent 4 }}
{{ if .Values.fluentd.logs.systemd.overrideOutputConf }}
{{ .Values.fluentd.logs.systemd.overrideOutputConf | nindent 4 }}
Expand Down
1 change: 0 additions & 1 deletion deploy/helm/sumologic/conf/setup/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ resource "sumologic_collector" "collector" {
name = var.collector_name
fields = {
{{- $fields := .Values.sumologic.collector.fields }}
{{ include "terraform.generate-key" (dict "Name" "cluster" "Value" "var.cluster_name" "SkipEscaping" true "KeyLength" (include "terraform.max-key-length" $fields)) }}
{{- range $name, $value := $fields }}
{{ include "terraform.generate-key" (dict "Name" $name "Value" $value "KeyLength" (include "terraform.max-key-length" $fields)) }}
{{- end}}
Expand Down
5 changes: 0 additions & 5 deletions deploy/helm/sumologic/conf/setup/variables.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
variable "cluster_name" {
type = string
default = "{{ template "sumologic.clusterNameReplaceSpaceWithDash" . }}"
}

variable "collector_name" {
type = string
{{- if .Values.sumologic.collectorName }}
Expand Down
15 changes: 12 additions & 3 deletions deploy/helm/sumologic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3453,7 +3453,6 @@ otelcol:
## extract the following well-known metadata fields
- containerId
- containerName
- clusterName
- daemonSetName
- deploymentName
- hostName
Expand Down Expand Up @@ -3839,6 +3838,9 @@ metadata:
- key: _origin # add "_origin" metadata to metrics to keep the same format as for metrics from Fluentd
value: kubernetes
action: upsert
- key: cluster
value: '{{ .Values.sumologic.clusterName | quote }}'
action: upsert
resource/remove_k8s_pod_pod_name:
attributes:
- action: delete
Expand Down Expand Up @@ -3923,7 +3925,6 @@ metadata:
extract:
metadata:
## extract the following well-known metadata fields
- clusterName
- daemonSetName
- deploymentName
- nodeName
Expand Down Expand Up @@ -4169,6 +4170,11 @@ metadata:
attributes:
- pattern: ^pod_annotations_.*
action: delete
resource/add_cluster:
attributes:
- key: cluster
value: '{{ .Values.sumologic.clusterName | quote }}'
action: upsert
groupbyattrs/containers:
keys:
- k8s.container.id
Expand All @@ -4185,7 +4191,6 @@ metadata:
## extract the following well-known metadata fields
- containerId
- containerName
- clusterName
- daemonSetName
- deploymentName
- hostName
Expand Down Expand Up @@ -4358,6 +4363,7 @@ metadata:
- attributes/containers
- groupbyattrs/containers
- k8s_tagger
- resource/add_cluster
- source/containers
- resource/drop_annotations
- attributes/remove_fluent_tag
Expand All @@ -4378,6 +4384,7 @@ metadata:
# - memory_limiter
# - groupbyattrs/containers
# - k8s_tagger
# - resource/add_cluster
# - source/containers
# - resource/drop_annotations
# - resource/containers_copy_node_to_host
Expand All @@ -4397,6 +4404,7 @@ metadata:
- filter/exclude_systemd_priority
- filter/exclude_systemd_unit
- groupbyattrs/systemd
- resource/add_cluster
- source/systemd
- attributes/remove_fluent_tag
- batch
Expand All @@ -4414,6 +4422,7 @@ metadata:
- filter/exclude_kubelet_priority
- filter/exclude_kubelet_unit
- groupbyattrs/systemd
- resource/add_cluster
- source/kubelet
- attributes/remove_fluent_tag
- batch
Expand Down
7 changes: 7 additions & 0 deletions tests/helm/events/static/apiServerUrl.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ data:
<match fluentd.**>
@type null
</match>
# Set `cluster` metadata field
<filter **>
@type record_modifier
<record>
_sumo_metadata ${ {:fields => "cluster=kubernetes"} }
</record>
</filter>
# expose the Fluentd metrics to Prometheus
<source>
@type prometheus
Expand Down
7 changes: 7 additions & 0 deletions tests/helm/events/static/apiServerUrl_null.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ data:
<match fluentd.**>
@type null
</match>
# Set `cluster` metadata field
<filter **>
@type record_modifier
<record>
_sumo_metadata ${ {:fields => "cluster=kubernetes"} }
</record>
</filter>
# expose the Fluentd metrics to Prometheus
<source>
@type prometheus
Expand Down
7 changes: 7 additions & 0 deletions tests/helm/events/static/default.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ data:
<match fluentd.**>
@type null
</match>
# Set `cluster` metadata field
<filter **>
@type record_modifier
<record>
_sumo_metadata ${ {:fields => "cluster=kubernetes"} }
</record>
</filter>
# expose the Fluentd metrics to Prometheus
<source>
@type prometheus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ data:
<match fluentd.**>
@type null
</match>
# Set `cluster` metadata field
<filter **>
@type record_modifier
<record>
_sumo_metadata ${ {:fields => "cluster=kubernetes"} }
</record>
</filter>
# expose the Fluentd metrics to Prometheus
<source>
@type prometheus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ data:
<match fluentd.**>
@type null
</match>
# Set `cluster` metadata field
<filter **>
@type record_modifier
<record>
_sumo_metadata ${ {:fields => "cluster=kubernetes"} }
</record>
</filter>
# expose the Fluentd metrics to Prometheus
<source>
@type prometheus
Expand Down
9 changes: 8 additions & 1 deletion tests/helm/metadata_logs_otc/static/basic.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ data:
metadata:
- containerId
- containerName
- clusterName
- daemonSetName
- deploymentName
- hostName
Expand All @@ -217,6 +216,11 @@ data:
check_interval: 5s
limit_percentage: 75
spike_limit_percentage: 20
resource/add_cluster:
attributes:
- action: upsert
key: cluster
value: "kubernetes"
resource/containers_copy_node_to_host:
attributes:
- action: upsert
Expand Down Expand Up @@ -281,6 +285,7 @@ data:
- attributes/containers
- groupbyattrs/containers
- k8s_tagger
- resource/add_cluster
- source/containers
- resource/drop_annotations
- attributes/remove_fluent_tag
Expand All @@ -300,6 +305,7 @@ data:
- filter/exclude_kubelet_priority
- filter/exclude_kubelet_unit
- groupbyattrs/systemd
- resource/add_cluster
- source/kubelet
- attributes/remove_fluent_tag
- batch
Expand All @@ -318,6 +324,7 @@ data:
- filter/exclude_systemd_priority
- filter/exclude_systemd_unit
- groupbyattrs/systemd
- resource/add_cluster
- source/systemd
- attributes/remove_fluent_tag
- batch
Expand Down
9 changes: 8 additions & 1 deletion tests/helm/metadata_logs_otc/static/templates.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ data:
metadata:
- containerId
- containerName
- clusterName
- daemonSetName
- deploymentName
- hostName
Expand All @@ -217,6 +216,11 @@ data:
check_interval: 5s
limit_percentage: 75
spike_limit_percentage: 20
resource/add_cluster:
attributes:
- action: upsert
key: cluster
value: "kubernetes"
resource/containers_copy_node_to_host:
attributes:
- action: upsert
Expand Down Expand Up @@ -281,6 +285,7 @@ data:
- attributes/containers
- groupbyattrs/containers
- k8s_tagger
- resource/add_cluster
- source/containers
- resource/drop_annotations
- attributes/remove_fluent_tag
Expand All @@ -300,6 +305,7 @@ data:
- filter/exclude_kubelet_priority
- filter/exclude_kubelet_unit
- groupbyattrs/systemd
- resource/add_cluster
- source/kubelet
- attributes/remove_fluent_tag
- batch
Expand All @@ -318,6 +324,7 @@ data:
- filter/exclude_systemd_priority
- filter/exclude_systemd_unit
- groupbyattrs/systemd
- resource/add_cluster
- source/systemd
- attributes/remove_fluent_tag
- batch
Expand Down
6 changes: 0 additions & 6 deletions tests/helm/terraform/static/all_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ data:
resource "sumologic_collector" "collector" {
name = var.collector_name
fields = {
cluster = var.cluster_name
}
}

Expand Down Expand Up @@ -660,11 +659,6 @@ data:

bash /etc/terraform/custom.sh
variables.tf: |
variable "cluster_name" {
type = string
default = "kubernetes"
}

variable "collector_name" {
type = string
default = "kubernetes"
Expand Down
6 changes: 0 additions & 6 deletions tests/helm/terraform/static/collector_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ data:
resource "sumologic_collector" "collector" {
name = var.collector_name
fields = {
cluster = var.cluster_name
here_is_very_long_field_name = "another_value"
test_fields = "test_value"
}
Expand Down Expand Up @@ -614,11 +613,6 @@ data:

bash /etc/terraform/custom.sh
variables.tf: |
variable "cluster_name" {
type = string
default = "kubernetes"
}

variable "collector_name" {
type = string
default = "kubernetes"
Expand Down
6 changes: 0 additions & 6 deletions tests/helm/terraform/static/conditional_sources.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ data:
resource "sumologic_collector" "collector" {
name = var.collector_name
fields = {
cluster = var.cluster_name
}
}

Expand Down Expand Up @@ -532,11 +531,6 @@ data:

bash /etc/terraform/custom.sh
variables.tf: |
variable "cluster_name" {
type = string
default = "kubernetes"
}

variable "collector_name" {
type = string
default = "kubernetes"
Expand Down