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

chore(metrics): route based on job attributes #3296

Merged
merged 1 commit into from
Sep 22, 2023
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
1 change: 0 additions & 1 deletion deploy/helm/sumologic/conf/metrics/otelcol/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ receivers:
write_timeout = "30s"
service_address = ":9888"
data_format = "prometheusremotewrite"
path_tag = true
paths = [
{{ include "metric.endpoints" . | indent 10 }}
]
Expand Down
3 changes: 0 additions & 3 deletions deploy/helm/sumologic/conf/metrics/otelcol/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ processors:
{{- end }}
- batch
{{- if eq .Values.sumologic.metrics.sourceType "http" }}
- transform/prepare_routing
- routing
{{- else }}
- transform/drop_routing_attribute
{{- end }}
receivers:
- telegraf
Expand Down
56 changes: 9 additions & 47 deletions deploy/helm/sumologic/conf/metrics/otelcol/processors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,57 +127,42 @@ resource/remove_k8s_pod_pod_name:
key: k8s.pod.pod_name

{{- if eq .Values.sumologic.metrics.sourceType "http" }}
## NOTE: below listed rules could be simplified if routingprocessor
## supports regex matching. At this point we could group route entries
## going to the same set of exporters.
routing:
attribute_source: resource
default_exporters:
- sumologic/default
drop_resource_routing_attribute: true
from_attribute: http_listener_v2_path
error_mode: ignore
table:
## apiserver metrics
- exporters:
- sumologic/apiserver
value: /prometheus.metrics.apiserver
statement: route() where resource.attributes["job"] == "apiserver"
## control-plane metrics
- exporters:
- sumologic/control_plane
value: /prometheus.metrics.control-plane.coredns
statement: route() where resource.attributes["job"] == "coredns"
- exporters:
- sumologic/control_plane
value: /prometheus.metrics.control-plane.kube-etcd
statement: route() where resource.attributes["job"] == "kube-etcd"
## controller metrics
- exporters:
- sumologic/controller
value: /prometheus.metrics.controller-manager
statement: route() where resource.attributes["job"] == "kube-controller-manager"
## kubelet metrics
- exporters:
- sumologic/kubelet
value: /prometheus.metrics.kubelet
statement: route() where resource.attributes["job"] == "kubelet"
## node metrics
- exporters:
- sumologic/node
value: /prometheus.metrics.node
statement: route() where resource.attributes["job"] == "node-exporter"
## scheduler metrics
- exporters:
- sumologic/scheduler
value: /prometheus.metrics.scheduler
statement: route() where resource.attributes["job"] == "kube-scheduler"
## state metrics
- exporters:
- sumologic/state
value: /prometheus.metrics.state
## custom metrics
## These entries are necessary due to a bug in routing processor that prevents the routing key from being deleted
## if the default exporter is chosen
## See: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/24644
- exporters:
- sumologic/default
value: /prometheus.metrics.applications.custom
- exporters:
- sumologic/default
value: /prometheus.metrics
statement: route() where resource.attributes["job"] == "kube-state-metrics"
{{- end }}

## Configuration for Source Processor
Expand All @@ -192,29 +177,6 @@ source:
sumologic_schema:
add_cloud_namespace: false

{{- if eq .Values.sumologic.metrics.sourceType "http" }}
transform/prepare_routing:
error_mode: ignore
metric_statements:
- context: metric
statements:
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.apiserver") where resource.attributes["job"] == "apiserver"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.control-plane.coredns") where resource.attributes["job"] == "coredns"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.control-plane.kube-etcd") where resource.attributes["job"] == "kube-etcd"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.controller-manager") where resource.attributes["job"] == "kubelet" and IsMatch(name, "^cloudprovider_.*")
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.kubelet") where resource.attributes["job"] == "kubelet" and not IsMatch(name, "^cloudprovider_.*")
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.node") where resource.attributes["job"] == "node-exporter"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.scheduler") where resource.attributes["job"] == "kube-scheduler"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.state") where resource.attributes["job"] == "kube-state-metrics"
{{ else }}
transform/drop_routing_attribute:
error_mode: ignore
metric_statements:
- context: resource
statements:
- delete_key(attributes, "http_listener_v2_path")
{{- end }}

transform/remove_name:
error_mode: ignore
metric_statements:
Expand Down
3 changes: 0 additions & 3 deletions tests/helm/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func TestMetadataMetricsOtelConfigExtraProcessors(t *testing.T) {
"transform/remove_name",
"filter/drop_unnecessary_metrics",
"batch",
"transform/prepare_routing",
"routing",
}

Expand Down Expand Up @@ -182,10 +181,8 @@ sumologic:
assert.Len(t, otelConfig.Exporters.Rest, 0)
assert.NotContains(t, otelConfig.Processors, "routing")
assert.NotContains(t, otelConfig.Processors, "transform/prepare_routing")
assert.Contains(t, otelConfig.Processors, "transform/drop_routing_attribute")
assert.NotContains(t, otelConfig.Service.Pipelines.Metrics.Processors, "routing")
assert.NotContains(t, otelConfig.Service.Pipelines.Metrics.Processors, "transform/prepare_routing")
assert.Contains(t, otelConfig.Service.Pipelines.Metrics.Processors, "transform/drop_routing_attribute")
assert.Equal(t, otelConfig.Service.Pipelines.Metrics.Exporters, []string{"sumologic/default"})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,69 +197,40 @@ data:
- action: delete
key: k8s.pod.pod_name
routing:
attribute_source: resource
default_exporters:
- sumologic/default
drop_resource_routing_attribute: true
from_attribute: http_listener_v2_path
error_mode: ignore
table:
- exporters:
- sumologic/apiserver
value: /prometheus.metrics.apiserver
statement: route() where resource.attributes["job"] == "apiserver"
- exporters:
- sumologic/control_plane
value: /prometheus.metrics.control-plane.coredns
statement: route() where resource.attributes["job"] == "coredns"
- exporters:
- sumologic/control_plane
value: /prometheus.metrics.control-plane.kube-etcd
statement: route() where resource.attributes["job"] == "kube-etcd"
- exporters:
- sumologic/controller
value: /prometheus.metrics.controller-manager
statement: route() where resource.attributes["job"] == "kube-controller-manager"
- exporters:
- sumologic/kubelet
value: /prometheus.metrics.kubelet
statement: route() where resource.attributes["job"] == "kubelet"
- exporters:
- sumologic/node
value: /prometheus.metrics.node
statement: route() where resource.attributes["job"] == "node-exporter"
- exporters:
- sumologic/scheduler
value: /prometheus.metrics.scheduler
statement: route() where resource.attributes["job"] == "kube-scheduler"
- exporters:
- sumologic/state
value: /prometheus.metrics.state
- exporters:
- sumologic/default
value: /prometheus.metrics.applications.custom
- exporters:
- sumologic/default
value: /prometheus.metrics
statement: route() where resource.attributes["job"] == "kube-state-metrics"
source:
collector: kubernetes
exclude:
k8s.namespace.name: ""
sumologic_schema:
add_cloud_namespace: false
transform/prepare_routing:
error_mode: ignore
metric_statements:
- context: metric
statements:
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.apiserver")
where resource.attributes["job"] == "apiserver"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.control-plane.coredns")
where resource.attributes["job"] == "coredns"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.control-plane.kube-etcd")
where resource.attributes["job"] == "kube-etcd"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.controller-manager")
where resource.attributes["job"] == "kubelet" and IsMatch(name, "^cloudprovider_.*")
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.kubelet")
where resource.attributes["job"] == "kubelet" and not IsMatch(name, "^cloudprovider_.*")
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.node")
where resource.attributes["job"] == "node-exporter"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.scheduler")
where resource.attributes["job"] == "kube-scheduler"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.state")
where resource.attributes["job"] == "kube-state-metrics"
transform/remove_name:
error_mode: ignore
metric_statements:
Expand Down Expand Up @@ -289,7 +260,6 @@ data:
write_timeout = "30s"
service_address = ":9888"
data_format = "prometheusremotewrite"
path_tag = true
paths = [
"/prometheus.metrics",
"/prometheus.metrics.custom",
Expand Down Expand Up @@ -326,7 +296,6 @@ data:
- transform/remove_name
- filter/drop_unnecessary_metrics
- batch
- transform/prepare_routing
- routing
receivers:
- telegraf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,69 +197,40 @@ data:
- action: delete
key: k8s.pod.pod_name
routing:
attribute_source: resource
default_exporters:
- sumologic/default
drop_resource_routing_attribute: true
from_attribute: http_listener_v2_path
error_mode: ignore
table:
- exporters:
- sumologic/apiserver
value: /prometheus.metrics.apiserver
statement: route() where resource.attributes["job"] == "apiserver"
- exporters:
- sumologic/control_plane
value: /prometheus.metrics.control-plane.coredns
statement: route() where resource.attributes["job"] == "coredns"
- exporters:
- sumologic/control_plane
value: /prometheus.metrics.control-plane.kube-etcd
statement: route() where resource.attributes["job"] == "kube-etcd"
- exporters:
- sumologic/controller
value: /prometheus.metrics.controller-manager
statement: route() where resource.attributes["job"] == "kube-controller-manager"
- exporters:
- sumologic/kubelet
value: /prometheus.metrics.kubelet
statement: route() where resource.attributes["job"] == "kubelet"
- exporters:
- sumologic/node
value: /prometheus.metrics.node
statement: route() where resource.attributes["job"] == "node-exporter"
- exporters:
- sumologic/scheduler
value: /prometheus.metrics.scheduler
statement: route() where resource.attributes["job"] == "kube-scheduler"
- exporters:
- sumologic/state
value: /prometheus.metrics.state
- exporters:
- sumologic/default
value: /prometheus.metrics.applications.custom
- exporters:
- sumologic/default
value: /prometheus.metrics
statement: route() where resource.attributes["job"] == "kube-state-metrics"
source:
collector: kubernetes
exclude:
k8s.namespace.name: ""
sumologic_schema:
add_cloud_namespace: false
transform/prepare_routing:
error_mode: ignore
metric_statements:
- context: metric
statements:
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.apiserver")
where resource.attributes["job"] == "apiserver"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.control-plane.coredns")
where resource.attributes["job"] == "coredns"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.control-plane.kube-etcd")
where resource.attributes["job"] == "kube-etcd"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.controller-manager")
where resource.attributes["job"] == "kubelet" and IsMatch(name, "^cloudprovider_.*")
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.kubelet")
where resource.attributes["job"] == "kubelet" and not IsMatch(name, "^cloudprovider_.*")
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.node")
where resource.attributes["job"] == "node-exporter"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.scheduler")
where resource.attributes["job"] == "kube-scheduler"
- set(resource.attributes["http_listener_v2_path"], "/prometheus.metrics.state")
where resource.attributes["job"] == "kube-state-metrics"
transform/remove_name:
error_mode: ignore
metric_statements:
Expand Down Expand Up @@ -289,7 +260,6 @@ data:
write_timeout = "30s"
service_address = ":9888"
data_format = "prometheusremotewrite"
path_tag = true
paths = [
"/prometheus.metrics"
]
Expand Down Expand Up @@ -324,7 +294,6 @@ data:
- transform/remove_name
- filter/drop_unnecessary_metrics
- batch
- transform/prepare_routing
- routing
receivers:
- telegraf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ data:
k8s.namespace.name: ""
sumologic_schema:
add_cloud_namespace: false
transform/drop_routing_attribute:
error_mode: ignore
metric_statements:
- context: resource
statements:
- delete_key(attributes, "http_listener_v2_path")
transform/remove_name:
error_mode: ignore
metric_statements:
Expand Down Expand Up @@ -167,7 +161,6 @@ data:
write_timeout = "30s"
service_address = ":9888"
data_format = "prometheusremotewrite"
path_tag = true
paths = [
"/prometheus.metrics"
]
Expand Down Expand Up @@ -195,7 +188,6 @@ data:
- transform/remove_name
- filter/drop_unnecessary_metrics
- batch
- transform/drop_routing_attribute
receivers:
- telegraf
- otlp
Expand Down
Loading