@@ -374,6 +374,26 @@ processors:
374374 - set(resource.attributes["k8s.node.name"], attributes["node_name"]) where attributes["node_name"] != nil
375375
376376 resourcedetection/cw_k8s_ci_v0:
377+ {{- if eq .Values.k8sMode "AKS" }}
378+ detectors: [aks, azure]
379+ aks:
380+ resource_attributes:
381+ cloud.platform: { enabled: true }
382+ cloud.provider: { enabled: true }
383+ k8s.cluster.name: { enabled: false }
384+ azure:
385+ resource_attributes:
386+ azure.resourcegroup.name: { enabled: true }
387+ azure.vm.name: { enabled: true }
388+ azure.vm.scaleset.name: { enabled: true }
389+ azure.vm.size: { enabled: true }
390+ cloud.account.id: { enabled: true }
391+ cloud.platform: { enabled: true }
392+ cloud.provider: { enabled: true }
393+ cloud.region: { enabled: true }
394+ host.id: { enabled: true }
395+ host.name: { enabled: true }
396+ {{- else }}
377397 detectors: [eks, ec2]
378398 ec2:
379399 resource_attributes:
@@ -386,6 +406,7 @@ processors:
386406 cloud.region: { enabled: true }
387407 cloud.availability_zone: { enabled: true }
388408 cloud.account.id: { enabled: true }
409+ {{- end }}
389410
390411 transform/cw_k8s_ci_v0_clear_schema_url:
391412 error_mode: ignore
@@ -464,8 +485,19 @@ processors:
464485 metric_statements:
465486 - context: resource
466487 statements:
488+ {{- if eq .Values.k8sMode "AKS" }}
489+ {{/* azure.resourcegroup.name is the node's group, not the cluster's: AKS nodes live in an
490+ auto-generated MC_<clusterResourceGroup>_<cluster>_<region> group. */ }}
491+ - set(resource.attributes [" _tmp.azure.resourcegroup.name" ], resource.attributes [" azure.resourcegroup.name" ])
492+ where resource.attributes [" azure.resourcegroup.name" ] != nil
493+ - replace_pattern(resource.attributes [" _tmp.azure.resourcegroup.name" ], " ^MC_(.+)_{{ .Values.clusterName }}_[^_]+$" , " $$$1" )
494+ - set(resource.attributes [" cloud.resource_id" ], Concat([" /subscriptions/" , resource.attributes [" cloud.account.id" ], " /resourceGroups/" , resource.attributes [" _tmp.azure.resourcegroup.name" ], " /providers/Microsoft.ContainerService/managedClusters/" , resource.attributes [" k8s.cluster.name" ]], " " ))
495+ where resource.attributes [" cloud.account.id" ] != nil and resource.attributes [" _tmp.azure.resourcegroup.name" ] != nil and resource.attributes [" k8s.cluster.name" ] != nil
496+ - delete_key(resource.attributes , " _tmp.azure.resourcegroup.name" )
497+ {{- else }}
467498 - set(resource.attributes [" cloud.resource_id" ], Concat([" arn:aws:eks:" , resource.attributes [" cloud.region" ], " :" , resource.attributes [" cloud.account.id" ], " :cluster/" , resource.attributes [" k8s.cluster.name" ]], " " ))
468499 where resource.attributes [" cloud.region" ] != nil and resource.attributes [" cloud.account.id" ] != nil and resource.attributes [" k8s.cluster.name" ] != nil
500+ {{- end }}
469501
470502 metricstarttime/cw_k8s_ci_v0:
471503
@@ -486,6 +518,11 @@ processors:
486518 - set(resource.attributes [" k8s.workload.type" ], " CronJob" ) where resource.attributes [" k8s.cronjob.name" ] != nil and resource.attributes [" k8s.workload.type" ] == nil
487519 - set(resource.attributes [" k8s.workload.name" ], resource.attributes [" k8s.replicaset.name" ]) where resource.attributes [" k8s.workload.name" ] == nil and resource.attributes [" k8s.replicaset.name" ] != nil
488520 - set(resource.attributes [" k8s.workload.type" ], " ReplicaSet" ) where resource.attributes [" k8s.replicaset.name" ] != nil and resource.attributes [" k8s.workload.type" ] == nil
521+ {{- if eq .Values.k8sMode " AKS" }}
522+ - set(resource.attributes [" service.name" ], resource.attributes [" k8s.workload.name" ]) where resource.attributes [" service.name" ] == nil and resource.attributes [" k8s.workload.name" ] != nil
523+ - set(resource.attributes [" service.namespace" ], resource.attributes [" k8s.namespace.name" ]) where resource.attributes [" service.namespace" ] == nil and resource.attributes [" k8s.namespace.name" ] != nil
524+ - set(resource.attributes [" deployment.environment.name" ], Concat([resource.attributes [" cloud.platform" ], Concat([resource.attributes [" k8s.cluster.name" ], resource.attributes [" k8s.namespace.name" ]], " /" )], " :" )) where resource.attributes [" deployment.environment.name" ] == nil and resource.attributes [" cloud.platform" ] != nil and resource.attributes [" k8s.cluster.name" ] != nil and resource.attributes [" k8s.namespace.name" ] != nil
525+ {{- end }}
489526
490527 batch/cw_k8s_ci_v0_metrics_dest:
491528 send_batch_size: 500
@@ -667,8 +704,13 @@ processors:
667704 - set(attributes[" k8s.workload.name" ], attributes[" k8s.replicaset.name" ]) where attributes[" k8s.workload.name" ] == nil and attributes[" k8s.replicaset.name" ] != nil
668705 - set(attributes[" k8s.workload.type" ], " ReplicaSet" ) where attributes[" k8s.replicaset.name" ] != nil and attributes[" k8s.workload.type" ] == nil
669706 # Derive service.name from k8s.workload.name (OTEL logs semconv).
670- # Logs need service.name; metrics use k8s.workload.name directly.
707+ # Logs need service.name ; metrics use k8s.workload.name directly, except on
708+ # AKS — see transform/cw_k8s_ci_v0_set_workload.
671709 - set(attributes[" service.name" ], attributes[" k8s.workload.name" ]) where attributes[" service.name" ] == nil and attributes[" k8s.workload.name" ] != nil
710+ {{- if eq .Values.k8sMode " AKS" }}
711+ - set(attributes[" service.namespace" ], attributes[" k8s.namespace.name" ]) where attributes[" service.namespace" ] == nil and attributes[" k8s.namespace.name" ] != nil
712+ - set(attributes[" deployment.environment.name" ], Concat([attributes[" cloud.platform" ], Concat([attributes[" k8s.cluster.name" ], attributes[" k8s.namespace.name" ]], " /" )], " :" )) where attributes[" deployment.environment.name" ] == nil and attributes[" cloud.platform" ] != nil and attributes[" k8s.cluster.name" ] != nil and attributes[" k8s.namespace.name" ] != nil
713+ {{- end }}
672714
673715 transform/cw_k8s_ci_v0_logs_set_cluster_and_node:
674716 error_mode: ignore
@@ -683,8 +725,18 @@ processors:
683725 log_statements:
684726 - context: resource
685727 statements:
728+ {{- if eq .Values.k8sMode " AKS" }}
729+ {{/* Node group -> cluster group, as in transform/cw_k8s_ci_v0_set_cloud_resource_id. */ }}
730+ - set(attributes[" _tmp.azure.resourcegroup.name" ], attributes[" azure.resourcegroup.name" ])
731+ where attributes[" azure.resourcegroup.name" ] != nil
732+ - replace_pattern(attributes[" _tmp.azure.resourcegroup.name" ], " ^MC_(.+)_{{ .Values.clusterName }}_[^_]+$" , " $$$1" )
733+ - set(attributes[" cloud.resource_id" ], Concat([" /subscriptions/" , attributes[" cloud.account.id" ], " /resourceGroups/" , attributes[" _tmp.azure.resourcegroup.name" ], " /providers/Microsoft.ContainerService/managedClusters/" , attributes[" k8s.cluster.name" ]], " " ))
734+ where attributes[" cloud.account.id" ] != nil and attributes[" _tmp.azure.resourcegroup.name" ] != nil and attributes[" k8s.cluster.name" ] != nil
735+ - delete_key(attributes, " _tmp.azure.resourcegroup.name" )
736+ {{- else }}
686737 - set(attributes[" cloud.resource_id" ], Concat([" arn:aws:eks:" , attributes[" cloud.region" ], " :" , attributes[" cloud.account.id" ], " :cluster/" , attributes[" k8s.cluster.name" ]], " " ))
687738 where attributes[" cloud.region" ] != nil and attributes[" cloud.account.id" ] != nil and attributes[" k8s.cluster.name" ] != nil
739+ {{- end }}
688740
689741 transform/cw_k8s_ci_v0_logs_clear_schema_url:
690742 error_mode: ignore
0 commit comments