Skip to content

Commit 2dbc366

Browse files
feat(containerinsights): Add KEDA solution pipeline and fix Karpenter test
Add KEDA metrics scraping as a new solution alongside Karpenter in the OTel Container Insights translator. The KEDA pipeline discovers the keda-operator pod via K8s service discovery and scrapes its Prometheus metrics endpoint, dropping generic Go runtime metrics that conflict with the apiserver pipeline. Changes: - Add keda.yaml pipeline template with receiver, processors, and pipeline wiring matching the helm chart config - Register keda solution in translator.go with solutionEnabled gate - Add keda schema entry in schema.json - Add golden test (input JSON + expected YAML) for KEDA pipeline - Fix Karpenter test: update JSON to use correct key paths (opentelemetry.cluster_name, role instead of mode) and regenerate expected YAML to match current translator output
1 parent 77cab1a commit 2dbc366

8 files changed

Lines changed: 1357 additions & 3 deletions

File tree

translator/config/schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,16 @@
19001900
}
19011901
},
19021902
"additionalProperties": false
1903+
},
1904+
"keda": {
1905+
"type": "object",
1906+
"properties": {
1907+
"enabled": {
1908+
"description": "Whether to collect KEDA metrics",
1909+
"type": "boolean"
1910+
}
1911+
},
1912+
"additionalProperties": false
19031913
}
19041914
},
19051915
"additionalProperties": false

translator/tocwconfig/sampleConfig/opentelemetry/container_insights_karpenter_config.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
"region": "us-east-1"
44
},
55
"opentelemetry": {
6+
"cluster_name": "TestCluster",
67
"collect": {
78
"container_insights": {
8-
"cluster_name": "TestCluster",
99
"collection_interval": 30,
10-
"mode": "cluster",
10+
"role": "cluster",
1111
"solutions": {
1212
"karpenter": {
1313
"enabled": true
14+
},
15+
"keda": {
16+
"enabled": false
1417
}
1518
}
1619
}

translator/tocwconfig/sampleConfig/opentelemetry/container_insights_karpenter_config.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ processors:
134134
labels:
135135
- from: pod
136136
key_regex: (.*)
137-
tag_name: k8s.pod.label.$$1
137+
tag_name: k8s.pod.label.$$$$1
138138
metadata:
139139
- k8s.pod.uid
140140
- k8s.node.name
@@ -722,6 +722,7 @@ processors:
722722
- set(resource.attributes["service.name"], resource.attributes["k8s.container.name"]) where resource.attributes["service.name"] == nil and resource.attributes["k8s.container.name"] != nil
723723
- set(resource.attributes["service.name"], "unknown_service") where resource.attributes["service.name"] == nil
724724
- set(resource.attributes["cloud.resource_id"], Format("arn:aws:eks:%s:%s:cluster/%s", [resource.attributes["cloud.region"], resource.attributes["cloud.account.id"], resource.attributes["k8s.cluster.name"]])) where resource.attributes["cloud.resource_id"] == nil and resource.attributes["k8s.cluster.name"] != nil and resource.attributes["cloud.platform"] == "aws_eks"
725+
- set(resource.attributes["cloud.resource_id"], Format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s", [resource.attributes["cloud.account.id"], resource.attributes["azure.resourcegroup.name"], resource.attributes["k8s.cluster.name"]])) where resource.attributes["cloud.resource_id"] == nil and resource.attributes["k8s.cluster.name"] != nil and resource.attributes["azure.resourcegroup.name"] != nil and resource.attributes["cloud.platform"] == "azure_aks"
725726
- set(resource.attributes["k8s.workload.name"], resource.attributes["k8s.deployment.name"]) where resource.attributes["k8s.deployment.name"] != nil
726727
- set(resource.attributes["k8s.workload.type"], "Deployment") where resource.attributes["k8s.deployment.name"] != nil and resource.attributes["k8s.workload.type"] == nil
727728
- set(resource.attributes["k8s.workload.name"], resource.attributes["k8s.statefulset.name"]) where resource.attributes["k8s.workload.name"] == nil and resource.attributes["k8s.statefulset.name"] != nil
@@ -763,6 +764,7 @@ processors:
763764
- set(resource.attributes["service.name"], resource.attributes["k8s.container.name"]) where resource.attributes["service.name"] == nil and resource.attributes["k8s.container.name"] != nil
764765
- set(resource.attributes["service.name"], "unknown_service") where resource.attributes["service.name"] == nil
765766
- set(resource.attributes["cloud.resource_id"], Format("arn:aws:eks:%s:%s:cluster/%s", [resource.attributes["cloud.region"], resource.attributes["cloud.account.id"], resource.attributes["k8s.cluster.name"]])) where resource.attributes["cloud.resource_id"] == nil and resource.attributes["k8s.cluster.name"] != nil and resource.attributes["cloud.platform"] == "aws_eks"
767+
- set(resource.attributes["cloud.resource_id"], Format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s", [resource.attributes["cloud.account.id"], resource.attributes["azure.resourcegroup.name"], resource.attributes["k8s.cluster.name"]])) where resource.attributes["cloud.resource_id"] == nil and resource.attributes["k8s.cluster.name"] != nil and resource.attributes["azure.resourcegroup.name"] != nil and resource.attributes["cloud.platform"] == "azure_aks"
766768
- set(resource.attributes["k8s.workload.name"], resource.attributes["k8s.deployment.name"]) where resource.attributes["k8s.deployment.name"] != nil
767769
- set(resource.attributes["k8s.workload.type"], "Deployment") where resource.attributes["k8s.deployment.name"] != nil and resource.attributes["k8s.workload.type"] == nil
768770
- set(resource.attributes["k8s.workload.name"], resource.attributes["k8s.statefulset.name"]) where resource.attributes["k8s.workload.name"] == nil and resource.attributes["k8s.statefulset.name"] != nil
@@ -804,6 +806,7 @@ processors:
804806
- set(resource.attributes["service.name"], resource.attributes["k8s.container.name"]) where resource.attributes["service.name"] == nil and resource.attributes["k8s.container.name"] != nil
805807
- set(resource.attributes["service.name"], "unknown_service") where resource.attributes["service.name"] == nil
806808
- set(resource.attributes["cloud.resource_id"], Format("arn:aws:eks:%s:%s:cluster/%s", [resource.attributes["cloud.region"], resource.attributes["cloud.account.id"], resource.attributes["k8s.cluster.name"]])) where resource.attributes["cloud.resource_id"] == nil and resource.attributes["k8s.cluster.name"] != nil and resource.attributes["cloud.platform"] == "aws_eks"
809+
- set(resource.attributes["cloud.resource_id"], Format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s", [resource.attributes["cloud.account.id"], resource.attributes["azure.resourcegroup.name"], resource.attributes["k8s.cluster.name"]])) where resource.attributes["cloud.resource_id"] == nil and resource.attributes["k8s.cluster.name"] != nil and resource.attributes["azure.resourcegroup.name"] != nil and resource.attributes["cloud.platform"] == "azure_aks"
807810
- set(resource.attributes["k8s.workload.name"], resource.attributes["k8s.deployment.name"]) where resource.attributes["k8s.deployment.name"] != nil
808811
- set(resource.attributes["k8s.workload.type"], "Deployment") where resource.attributes["k8s.deployment.name"] != nil and resource.attributes["k8s.workload.type"] == nil
809812
- set(resource.attributes["k8s.workload.name"], resource.attributes["k8s.statefulset.name"]) where resource.attributes["k8s.workload.name"] == nil and resource.attributes["k8s.statefulset.name"] != nil
@@ -828,6 +831,24 @@ processors:
828831
- delete_key(resource.attributes, "app.kubernetes.io/instance")
829832
- delete_key(resource.attributes, "app.kubernetes.io/name")
830833
- delete_key(resource.attributes, "app.kubernetes.io/version")
834+
transform/set_cluster_name:
835+
error_mode: ignore
836+
flatten_data: false
837+
log_statements:
838+
- context: resource
839+
error_mode: ignore
840+
statements:
841+
- set(resource.attributes["k8s.cluster.name"], "TestCluster")
842+
metric_statements:
843+
- context: resource
844+
error_mode: ignore
845+
statements:
846+
- set(resource.attributes["k8s.cluster.name"], "TestCluster")
847+
trace_statements:
848+
- context: resource
849+
error_mode: ignore
850+
statements:
851+
- set(resource.attributes["k8s.cluster.name"], "TestCluster")
831852
receivers:
832853
prometheus/cw_k8s_ci_v0_apiserver:
833854
config:
@@ -981,6 +1002,7 @@ service:
9811002
processors:
9821003
- resourcedetection/opentelemetry
9831004
- k8sattributes/opentelemetry
1005+
- transform/set_cluster_name
9841006
- transform/identity
9851007
- batch/opentelemetry_metrics
9861008
receivers:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"agent": {
3+
"region": "us-east-1"
4+
},
5+
"opentelemetry": {
6+
"cluster_name": "TestCluster",
7+
"collect": {
8+
"container_insights": {
9+
"collection_interval": 30,
10+
"role": "cluster",
11+
"solutions": {
12+
"karpenter": {
13+
"enabled": false
14+
},
15+
"keda": {
16+
"enabled": true
17+
}
18+
}
19+
}
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)