diff --git a/receiver/k8sclusterreceiver/documentation.md b/receiver/k8sclusterreceiver/documentation.md index e5d33cde60fe..d469f469141b 100644 --- a/receiver/k8sclusterreceiver/documentation.md +++ b/receiver/k8sclusterreceiver/documentation.md @@ -422,23 +422,30 @@ Current status reason of the pod (1 - Evicted, 2 - NodeAffinity, 3 - NodeLost, 4 | k8s.cluster.name | The k8s cluster name. | Any Str | true | | k8s.container.name | The k8s container name | Any Str | true | | k8s.cronjob.name | The k8s CronJob name | Any Str | true | +| k8s.cronjob.start_time | The start time of the Cronjob. | Any Str | true | | k8s.cronjob.uid | The k8s CronJob uid. | Any Str | true | | k8s.daemonset.name | The k8s daemonset name. | Any Str | true | +| k8s.daemonset.start_time | The start time of the Daemonset. | Any Str | true | | k8s.daemonset.uid | The k8s daemonset uid. | Any Str | true | | k8s.deployment.name | The name of the Deployment. | Any Str | true | +| k8s.deployment.start_time | The start time of the Deployment. | Any Str | true | | k8s.deployment.uid | The UID of the Deployment. | Any Str | true | | k8s.hpa.name | The k8s hpa name. | Any Str | true | | k8s.hpa.uid | The k8s hpa uid. | Any Str | true | | k8s.job.name | The k8s pod name. | Any Str | true | +| k8s.job.start_time | The start time of the Job. | Any Str | true | | k8s.job.uid | The k8s job uid. | Any Str | true | | k8s.namespace.name | The k8s namespace name. | Any Str | true | +| k8s.namespace.start_time | The start time of the Namespace. | Any Str | true | | k8s.namespace.uid | The k8s namespace uid. | Any Str | true | | k8s.node.name | The k8s node name. | Any Str | true | | k8s.node.start_time | The start time of the Node. | Any Str | true | | k8s.node.uid | The k8s node uid. | Any Str | true | | k8s.pod.name | The k8s pod name. | Any Str | true | +| k8s.pod.start_time | The start time of the Pod. | Any Str | true | | k8s.pod.uid | The k8s pod uid. | Any Str | true | | k8s.replicaset.name | The k8s replicaset name | Any Str | true | +| k8s.replicaset.start_time | The start time of the Replicaset. | Any Str | true | | k8s.replicaset.uid | The k8s replicaset uid | Any Str | true | | k8s.replicationcontroller.name | The k8s replicationcontroller name. | Any Str | true | | k8s.replicationcontroller.uid | The k8s replicationcontroller uid. | Any Str | true | @@ -451,6 +458,7 @@ Current status reason of the pod (1 - Evicted, 2 - NodeAffinity, 3 - NodeLost, 4 | k8s.service.uid | The UID of the service | Any Str | true | | k8s.service_account.name | The name of the Service-account | Any Str | true | | k8s.statefulset.name | The k8s statefulset name. | Any Str | true | +| k8s.statefulset.start_time | The start time of the Statefulset. | Any Str | true | | k8s.statefulset.uid | The k8s statefulset uid. | Any Str | true | | opencensus.resourcetype | The OpenCensus resource type. | Any Str | true | | openshift.clusterquota.name | The k8s ClusterResourceQuota name. | Any Str | true | diff --git a/receiver/k8sclusterreceiver/internal/cronjob/cronjobs.go b/receiver/k8sclusterreceiver/internal/cronjob/cronjobs.go index e7a49e6c15da..707826a53af6 100644 --- a/receiver/k8sclusterreceiver/internal/cronjob/cronjobs.go +++ b/receiver/k8sclusterreceiver/internal/cronjob/cronjobs.go @@ -26,6 +26,7 @@ func RecordMetrics(mb *metadata.MetricsBuilder, cj *batchv1.CronJob, ts pcommon. rb.SetK8sNamespaceName(cj.Namespace) rb.SetK8sCronjobUID(string(cj.UID)) rb.SetK8sCronjobName(cj.Name) + rb.SetK8sCronjobStartTime(cj.GetCreationTimestamp().String()) rb.SetOpencensusResourcetype("k8s") mb.EmitForResource(metadata.WithResource(rb.Emit())) } diff --git a/receiver/k8sclusterreceiver/internal/demonset/daemonsets.go b/receiver/k8sclusterreceiver/internal/demonset/daemonsets.go index 303e9c9a24d9..c19c16a23545 100644 --- a/receiver/k8sclusterreceiver/internal/demonset/daemonsets.go +++ b/receiver/k8sclusterreceiver/internal/demonset/daemonsets.go @@ -35,6 +35,7 @@ func RecordMetrics(mb *metadata.MetricsBuilder, ds *appsv1.DaemonSet, ts pcommon rb := mb.NewResourceBuilder() rb.SetK8sNamespaceName(ds.Namespace) rb.SetK8sDaemonsetName(ds.Name) + rb.SetK8sDaemonsetStartTime(ds.GetCreationTimestamp().String()) rb.SetK8sDaemonsetUID(string(ds.UID)) rb.SetOpencensusResourcetype("k8s") mb.EmitForResource(metadata.WithResource(rb.Emit())) diff --git a/receiver/k8sclusterreceiver/internal/deployment/deployments.go b/receiver/k8sclusterreceiver/internal/deployment/deployments.go index 207b5c5caaa0..756bbefea3a0 100644 --- a/receiver/k8sclusterreceiver/internal/deployment/deployments.go +++ b/receiver/k8sclusterreceiver/internal/deployment/deployments.go @@ -35,6 +35,7 @@ func RecordMetrics(mb *imetadata.MetricsBuilder, dep *appsv1.Deployment, ts pcom rb.SetK8sDeploymentName(dep.Name) rb.SetK8sDeploymentUID(string(dep.UID)) rb.SetK8sNamespaceName(dep.Namespace) + rb.SetK8sDeploymentStartTime(dep.GetCreationTimestamp().String()) rb.SetOpencensusResourcetype("k8s") mb.EmitForResource(metadata.WithResource(rb.Emit())) } diff --git a/receiver/k8sclusterreceiver/internal/jobs/jobs.go b/receiver/k8sclusterreceiver/internal/jobs/jobs.go index fdd0e4e07ade..7af534990d61 100644 --- a/receiver/k8sclusterreceiver/internal/jobs/jobs.go +++ b/receiver/k8sclusterreceiver/internal/jobs/jobs.go @@ -28,6 +28,7 @@ func RecordMetrics(mb *metadata.MetricsBuilder, j *batchv1.Job, ts pcommon.Times rb.SetK8sNamespaceName(j.Namespace) rb.SetK8sJobName(j.Name) rb.SetK8sJobUID(string(j.UID)) + rb.SetK8sJobStartTime(j.GetCreationTimestamp().String()) rb.SetOpencensusResourcetype("k8s") mb.EmitForResource(metadata.WithResource(rb.Emit())) } diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_config.go b/receiver/k8sclusterreceiver/internal/metadata/generated_config.go index 3cf2d79e43e9..3a5b951c3093 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_config.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_config.go @@ -211,6 +211,20 @@ func DefaultMetricsConfig() MetricsConfig { // ResourceAttributeConfig provides common config for a particular resource attribute. type ResourceAttributeConfig struct { Enabled bool `mapstructure:"enabled"` + + enabledSetByUser bool +} + +func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error { + if parser == nil { + return nil + } + err := parser.Unmarshal(rac, confmap.WithErrorUnused()) + if err != nil { + return err + } + rac.enabledSetByUser = parser.IsSet("enabled") + return nil } // ResourceAttributesConfig provides config for k8s_cluster resource attributes. @@ -221,23 +235,30 @@ type ResourceAttributesConfig struct { K8sClusterName ResourceAttributeConfig `mapstructure:"k8s.cluster.name"` K8sContainerName ResourceAttributeConfig `mapstructure:"k8s.container.name"` K8sCronjobName ResourceAttributeConfig `mapstructure:"k8s.cronjob.name"` + K8sCronjobStartTime ResourceAttributeConfig `mapstructure:"k8s.cronjob.start_time"` K8sCronjobUID ResourceAttributeConfig `mapstructure:"k8s.cronjob.uid"` K8sDaemonsetName ResourceAttributeConfig `mapstructure:"k8s.daemonset.name"` + K8sDaemonsetStartTime ResourceAttributeConfig `mapstructure:"k8s.daemonset.start_time"` K8sDaemonsetUID ResourceAttributeConfig `mapstructure:"k8s.daemonset.uid"` K8sDeploymentName ResourceAttributeConfig `mapstructure:"k8s.deployment.name"` + K8sDeploymentStartTime ResourceAttributeConfig `mapstructure:"k8s.deployment.start_time"` K8sDeploymentUID ResourceAttributeConfig `mapstructure:"k8s.deployment.uid"` K8sHpaName ResourceAttributeConfig `mapstructure:"k8s.hpa.name"` K8sHpaUID ResourceAttributeConfig `mapstructure:"k8s.hpa.uid"` K8sJobName ResourceAttributeConfig `mapstructure:"k8s.job.name"` + K8sJobStartTime ResourceAttributeConfig `mapstructure:"k8s.job.start_time"` K8sJobUID ResourceAttributeConfig `mapstructure:"k8s.job.uid"` K8sNamespaceName ResourceAttributeConfig `mapstructure:"k8s.namespace.name"` + K8sNamespaceStartTime ResourceAttributeConfig `mapstructure:"k8s.namespace.start_time"` K8sNamespaceUID ResourceAttributeConfig `mapstructure:"k8s.namespace.uid"` K8sNodeName ResourceAttributeConfig `mapstructure:"k8s.node.name"` K8sNodeStartTime ResourceAttributeConfig `mapstructure:"k8s.node.start_time"` K8sNodeUID ResourceAttributeConfig `mapstructure:"k8s.node.uid"` K8sPodName ResourceAttributeConfig `mapstructure:"k8s.pod.name"` + K8sPodStartTime ResourceAttributeConfig `mapstructure:"k8s.pod.start_time"` K8sPodUID ResourceAttributeConfig `mapstructure:"k8s.pod.uid"` K8sReplicasetName ResourceAttributeConfig `mapstructure:"k8s.replicaset.name"` + K8sReplicasetStartTime ResourceAttributeConfig `mapstructure:"k8s.replicaset.start_time"` K8sReplicasetUID ResourceAttributeConfig `mapstructure:"k8s.replicaset.uid"` K8sReplicationcontrollerName ResourceAttributeConfig `mapstructure:"k8s.replicationcontroller.name"` K8sReplicationcontrollerUID ResourceAttributeConfig `mapstructure:"k8s.replicationcontroller.uid"` @@ -250,6 +271,7 @@ type ResourceAttributesConfig struct { K8sServiceUID ResourceAttributeConfig `mapstructure:"k8s.service.uid"` K8sServiceAccountName ResourceAttributeConfig `mapstructure:"k8s.service_account.name"` K8sStatefulsetName ResourceAttributeConfig `mapstructure:"k8s.statefulset.name"` + K8sStatefulsetStartTime ResourceAttributeConfig `mapstructure:"k8s.statefulset.start_time"` K8sStatefulsetUID ResourceAttributeConfig `mapstructure:"k8s.statefulset.uid"` OpencensusResourcetype ResourceAttributeConfig `mapstructure:"opencensus.resourcetype"` OpenshiftClusterquotaName ResourceAttributeConfig `mapstructure:"openshift.clusterquota.name"` @@ -276,18 +298,27 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { K8sCronjobName: ResourceAttributeConfig{ Enabled: true, }, + K8sCronjobStartTime: ResourceAttributeConfig{ + Enabled: true, + }, K8sCronjobUID: ResourceAttributeConfig{ Enabled: true, }, K8sDaemonsetName: ResourceAttributeConfig{ Enabled: true, }, + K8sDaemonsetStartTime: ResourceAttributeConfig{ + Enabled: true, + }, K8sDaemonsetUID: ResourceAttributeConfig{ Enabled: true, }, K8sDeploymentName: ResourceAttributeConfig{ Enabled: true, }, + K8sDeploymentStartTime: ResourceAttributeConfig{ + Enabled: true, + }, K8sDeploymentUID: ResourceAttributeConfig{ Enabled: true, }, @@ -300,12 +331,18 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { K8sJobName: ResourceAttributeConfig{ Enabled: true, }, + K8sJobStartTime: ResourceAttributeConfig{ + Enabled: true, + }, K8sJobUID: ResourceAttributeConfig{ Enabled: true, }, K8sNamespaceName: ResourceAttributeConfig{ Enabled: true, }, + K8sNamespaceStartTime: ResourceAttributeConfig{ + Enabled: true, + }, K8sNamespaceUID: ResourceAttributeConfig{ Enabled: true, }, @@ -321,12 +358,18 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { K8sPodName: ResourceAttributeConfig{ Enabled: true, }, + K8sPodStartTime: ResourceAttributeConfig{ + Enabled: true, + }, K8sPodUID: ResourceAttributeConfig{ Enabled: true, }, K8sReplicasetName: ResourceAttributeConfig{ Enabled: true, }, + K8sReplicasetStartTime: ResourceAttributeConfig{ + Enabled: true, + }, K8sReplicasetUID: ResourceAttributeConfig{ Enabled: true, }, @@ -363,6 +406,9 @@ func DefaultResourceAttributesConfig() ResourceAttributesConfig { K8sStatefulsetName: ResourceAttributeConfig{ Enabled: true, }, + K8sStatefulsetStartTime: ResourceAttributeConfig{ + Enabled: true, + }, K8sStatefulsetUID: ResourceAttributeConfig{ Enabled: true, }, diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_config_test.go b/receiver/k8sclusterreceiver/internal/metadata/generated_config_test.go index a04fba5c0ce7..7d36ec62d603 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_config_test.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_config_test.go @@ -78,23 +78,30 @@ func TestMetricsBuilderConfig(t *testing.T) { K8sClusterName: ResourceAttributeConfig{Enabled: true}, K8sContainerName: ResourceAttributeConfig{Enabled: true}, K8sCronjobName: ResourceAttributeConfig{Enabled: true}, + K8sCronjobStartTime: ResourceAttributeConfig{Enabled: true}, K8sCronjobUID: ResourceAttributeConfig{Enabled: true}, K8sDaemonsetName: ResourceAttributeConfig{Enabled: true}, + K8sDaemonsetStartTime: ResourceAttributeConfig{Enabled: true}, K8sDaemonsetUID: ResourceAttributeConfig{Enabled: true}, K8sDeploymentName: ResourceAttributeConfig{Enabled: true}, + K8sDeploymentStartTime: ResourceAttributeConfig{Enabled: true}, K8sDeploymentUID: ResourceAttributeConfig{Enabled: true}, K8sHpaName: ResourceAttributeConfig{Enabled: true}, K8sHpaUID: ResourceAttributeConfig{Enabled: true}, K8sJobName: ResourceAttributeConfig{Enabled: true}, + K8sJobStartTime: ResourceAttributeConfig{Enabled: true}, K8sJobUID: ResourceAttributeConfig{Enabled: true}, K8sNamespaceName: ResourceAttributeConfig{Enabled: true}, + K8sNamespaceStartTime: ResourceAttributeConfig{Enabled: true}, K8sNamespaceUID: ResourceAttributeConfig{Enabled: true}, K8sNodeName: ResourceAttributeConfig{Enabled: true}, K8sNodeStartTime: ResourceAttributeConfig{Enabled: true}, K8sNodeUID: ResourceAttributeConfig{Enabled: true}, K8sPodName: ResourceAttributeConfig{Enabled: true}, + K8sPodStartTime: ResourceAttributeConfig{Enabled: true}, K8sPodUID: ResourceAttributeConfig{Enabled: true}, K8sReplicasetName: ResourceAttributeConfig{Enabled: true}, + K8sReplicasetStartTime: ResourceAttributeConfig{Enabled: true}, K8sReplicasetUID: ResourceAttributeConfig{Enabled: true}, K8sReplicationcontrollerName: ResourceAttributeConfig{Enabled: true}, K8sReplicationcontrollerUID: ResourceAttributeConfig{Enabled: true}, @@ -107,6 +114,7 @@ func TestMetricsBuilderConfig(t *testing.T) { K8sServiceUID: ResourceAttributeConfig{Enabled: true}, K8sServiceAccountName: ResourceAttributeConfig{Enabled: true}, K8sStatefulsetName: ResourceAttributeConfig{Enabled: true}, + K8sStatefulsetStartTime: ResourceAttributeConfig{Enabled: true}, K8sStatefulsetUID: ResourceAttributeConfig{Enabled: true}, OpencensusResourcetype: ResourceAttributeConfig{Enabled: true}, OpenshiftClusterquotaName: ResourceAttributeConfig{Enabled: true}, @@ -170,23 +178,30 @@ func TestMetricsBuilderConfig(t *testing.T) { K8sClusterName: ResourceAttributeConfig{Enabled: false}, K8sContainerName: ResourceAttributeConfig{Enabled: false}, K8sCronjobName: ResourceAttributeConfig{Enabled: false}, + K8sCronjobStartTime: ResourceAttributeConfig{Enabled: false}, K8sCronjobUID: ResourceAttributeConfig{Enabled: false}, K8sDaemonsetName: ResourceAttributeConfig{Enabled: false}, + K8sDaemonsetStartTime: ResourceAttributeConfig{Enabled: false}, K8sDaemonsetUID: ResourceAttributeConfig{Enabled: false}, K8sDeploymentName: ResourceAttributeConfig{Enabled: false}, + K8sDeploymentStartTime: ResourceAttributeConfig{Enabled: false}, K8sDeploymentUID: ResourceAttributeConfig{Enabled: false}, K8sHpaName: ResourceAttributeConfig{Enabled: false}, K8sHpaUID: ResourceAttributeConfig{Enabled: false}, K8sJobName: ResourceAttributeConfig{Enabled: false}, + K8sJobStartTime: ResourceAttributeConfig{Enabled: false}, K8sJobUID: ResourceAttributeConfig{Enabled: false}, K8sNamespaceName: ResourceAttributeConfig{Enabled: false}, + K8sNamespaceStartTime: ResourceAttributeConfig{Enabled: false}, K8sNamespaceUID: ResourceAttributeConfig{Enabled: false}, K8sNodeName: ResourceAttributeConfig{Enabled: false}, K8sNodeStartTime: ResourceAttributeConfig{Enabled: false}, K8sNodeUID: ResourceAttributeConfig{Enabled: false}, K8sPodName: ResourceAttributeConfig{Enabled: false}, + K8sPodStartTime: ResourceAttributeConfig{Enabled: false}, K8sPodUID: ResourceAttributeConfig{Enabled: false}, K8sReplicasetName: ResourceAttributeConfig{Enabled: false}, + K8sReplicasetStartTime: ResourceAttributeConfig{Enabled: false}, K8sReplicasetUID: ResourceAttributeConfig{Enabled: false}, K8sReplicationcontrollerName: ResourceAttributeConfig{Enabled: false}, K8sReplicationcontrollerUID: ResourceAttributeConfig{Enabled: false}, @@ -199,6 +214,7 @@ func TestMetricsBuilderConfig(t *testing.T) { K8sServiceUID: ResourceAttributeConfig{Enabled: false}, K8sServiceAccountName: ResourceAttributeConfig{Enabled: false}, K8sStatefulsetName: ResourceAttributeConfig{Enabled: false}, + K8sStatefulsetStartTime: ResourceAttributeConfig{Enabled: false}, K8sStatefulsetUID: ResourceAttributeConfig{Enabled: false}, OpencensusResourcetype: ResourceAttributeConfig{Enabled: false}, OpenshiftClusterquotaName: ResourceAttributeConfig{Enabled: false}, @@ -245,23 +261,30 @@ func TestResourceAttributesConfig(t *testing.T) { K8sClusterName: ResourceAttributeConfig{Enabled: true}, K8sContainerName: ResourceAttributeConfig{Enabled: true}, K8sCronjobName: ResourceAttributeConfig{Enabled: true}, + K8sCronjobStartTime: ResourceAttributeConfig{Enabled: true}, K8sCronjobUID: ResourceAttributeConfig{Enabled: true}, K8sDaemonsetName: ResourceAttributeConfig{Enabled: true}, + K8sDaemonsetStartTime: ResourceAttributeConfig{Enabled: true}, K8sDaemonsetUID: ResourceAttributeConfig{Enabled: true}, K8sDeploymentName: ResourceAttributeConfig{Enabled: true}, + K8sDeploymentStartTime: ResourceAttributeConfig{Enabled: true}, K8sDeploymentUID: ResourceAttributeConfig{Enabled: true}, K8sHpaName: ResourceAttributeConfig{Enabled: true}, K8sHpaUID: ResourceAttributeConfig{Enabled: true}, K8sJobName: ResourceAttributeConfig{Enabled: true}, + K8sJobStartTime: ResourceAttributeConfig{Enabled: true}, K8sJobUID: ResourceAttributeConfig{Enabled: true}, K8sNamespaceName: ResourceAttributeConfig{Enabled: true}, + K8sNamespaceStartTime: ResourceAttributeConfig{Enabled: true}, K8sNamespaceUID: ResourceAttributeConfig{Enabled: true}, K8sNodeName: ResourceAttributeConfig{Enabled: true}, K8sNodeStartTime: ResourceAttributeConfig{Enabled: true}, K8sNodeUID: ResourceAttributeConfig{Enabled: true}, K8sPodName: ResourceAttributeConfig{Enabled: true}, + K8sPodStartTime: ResourceAttributeConfig{Enabled: true}, K8sPodUID: ResourceAttributeConfig{Enabled: true}, K8sReplicasetName: ResourceAttributeConfig{Enabled: true}, + K8sReplicasetStartTime: ResourceAttributeConfig{Enabled: true}, K8sReplicasetUID: ResourceAttributeConfig{Enabled: true}, K8sReplicationcontrollerName: ResourceAttributeConfig{Enabled: true}, K8sReplicationcontrollerUID: ResourceAttributeConfig{Enabled: true}, @@ -274,6 +297,7 @@ func TestResourceAttributesConfig(t *testing.T) { K8sServiceUID: ResourceAttributeConfig{Enabled: true}, K8sServiceAccountName: ResourceAttributeConfig{Enabled: true}, K8sStatefulsetName: ResourceAttributeConfig{Enabled: true}, + K8sStatefulsetStartTime: ResourceAttributeConfig{Enabled: true}, K8sStatefulsetUID: ResourceAttributeConfig{Enabled: true}, OpencensusResourcetype: ResourceAttributeConfig{Enabled: true}, OpenshiftClusterquotaName: ResourceAttributeConfig{Enabled: true}, @@ -289,23 +313,30 @@ func TestResourceAttributesConfig(t *testing.T) { K8sClusterName: ResourceAttributeConfig{Enabled: false}, K8sContainerName: ResourceAttributeConfig{Enabled: false}, K8sCronjobName: ResourceAttributeConfig{Enabled: false}, + K8sCronjobStartTime: ResourceAttributeConfig{Enabled: false}, K8sCronjobUID: ResourceAttributeConfig{Enabled: false}, K8sDaemonsetName: ResourceAttributeConfig{Enabled: false}, + K8sDaemonsetStartTime: ResourceAttributeConfig{Enabled: false}, K8sDaemonsetUID: ResourceAttributeConfig{Enabled: false}, K8sDeploymentName: ResourceAttributeConfig{Enabled: false}, + K8sDeploymentStartTime: ResourceAttributeConfig{Enabled: false}, K8sDeploymentUID: ResourceAttributeConfig{Enabled: false}, K8sHpaName: ResourceAttributeConfig{Enabled: false}, K8sHpaUID: ResourceAttributeConfig{Enabled: false}, K8sJobName: ResourceAttributeConfig{Enabled: false}, + K8sJobStartTime: ResourceAttributeConfig{Enabled: false}, K8sJobUID: ResourceAttributeConfig{Enabled: false}, K8sNamespaceName: ResourceAttributeConfig{Enabled: false}, + K8sNamespaceStartTime: ResourceAttributeConfig{Enabled: false}, K8sNamespaceUID: ResourceAttributeConfig{Enabled: false}, K8sNodeName: ResourceAttributeConfig{Enabled: false}, K8sNodeStartTime: ResourceAttributeConfig{Enabled: false}, K8sNodeUID: ResourceAttributeConfig{Enabled: false}, K8sPodName: ResourceAttributeConfig{Enabled: false}, + K8sPodStartTime: ResourceAttributeConfig{Enabled: false}, K8sPodUID: ResourceAttributeConfig{Enabled: false}, K8sReplicasetName: ResourceAttributeConfig{Enabled: false}, + K8sReplicasetStartTime: ResourceAttributeConfig{Enabled: false}, K8sReplicasetUID: ResourceAttributeConfig{Enabled: false}, K8sReplicationcontrollerName: ResourceAttributeConfig{Enabled: false}, K8sReplicationcontrollerUID: ResourceAttributeConfig{Enabled: false}, @@ -318,6 +349,7 @@ func TestResourceAttributesConfig(t *testing.T) { K8sServiceUID: ResourceAttributeConfig{Enabled: false}, K8sServiceAccountName: ResourceAttributeConfig{Enabled: false}, K8sStatefulsetName: ResourceAttributeConfig{Enabled: false}, + K8sStatefulsetStartTime: ResourceAttributeConfig{Enabled: false}, K8sStatefulsetUID: ResourceAttributeConfig{Enabled: false}, OpencensusResourcetype: ResourceAttributeConfig{Enabled: false}, OpenshiftClusterquotaName: ResourceAttributeConfig{Enabled: false}, diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_metrics_test.go b/receiver/k8sclusterreceiver/internal/metadata/generated_metrics_test.go index cbbe1b375e92..336c8f90aeec 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_metrics_test.go @@ -49,6 +49,7 @@ func TestMetricsBuilder(t *testing.T) { mb := NewMetricsBuilder(loadMetricsBuilderConfig(t, test.name), settings, WithStartTime(start)) expectedWarnings := 0 + assert.Equal(t, expectedWarnings, observedLogs.Len()) defaultMetricsCount := 0 @@ -236,23 +237,30 @@ func TestMetricsBuilder(t *testing.T) { rb.SetK8sClusterName("k8s.cluster.name-val") rb.SetK8sContainerName("k8s.container.name-val") rb.SetK8sCronjobName("k8s.cronjob.name-val") + rb.SetK8sCronjobStartTime("k8s.cronjob.start_time-val") rb.SetK8sCronjobUID("k8s.cronjob.uid-val") rb.SetK8sDaemonsetName("k8s.daemonset.name-val") + rb.SetK8sDaemonsetStartTime("k8s.daemonset.start_time-val") rb.SetK8sDaemonsetUID("k8s.daemonset.uid-val") rb.SetK8sDeploymentName("k8s.deployment.name-val") + rb.SetK8sDeploymentStartTime("k8s.deployment.start_time-val") rb.SetK8sDeploymentUID("k8s.deployment.uid-val") rb.SetK8sHpaName("k8s.hpa.name-val") rb.SetK8sHpaUID("k8s.hpa.uid-val") rb.SetK8sJobName("k8s.job.name-val") + rb.SetK8sJobStartTime("k8s.job.start_time-val") rb.SetK8sJobUID("k8s.job.uid-val") rb.SetK8sNamespaceName("k8s.namespace.name-val") + rb.SetK8sNamespaceStartTime("k8s.namespace.start_time-val") rb.SetK8sNamespaceUID("k8s.namespace.uid-val") rb.SetK8sNodeName("k8s.node.name-val") rb.SetK8sNodeStartTime("k8s.node.start_time-val") rb.SetK8sNodeUID("k8s.node.uid-val") rb.SetK8sPodName("k8s.pod.name-val") + rb.SetK8sPodStartTime("k8s.pod.start_time-val") rb.SetK8sPodUID("k8s.pod.uid-val") rb.SetK8sReplicasetName("k8s.replicaset.name-val") + rb.SetK8sReplicasetStartTime("k8s.replicaset.start_time-val") rb.SetK8sReplicasetUID("k8s.replicaset.uid-val") rb.SetK8sReplicationcontrollerName("k8s.replicationcontroller.name-val") rb.SetK8sReplicationcontrollerUID("k8s.replicationcontroller.uid-val") @@ -265,6 +273,7 @@ func TestMetricsBuilder(t *testing.T) { rb.SetK8sServiceUID("k8s.service.uid-val") rb.SetK8sServiceAccountName("k8s.service_account.name-val") rb.SetK8sStatefulsetName("k8s.statefulset.name-val") + rb.SetK8sStatefulsetStartTime("k8s.statefulset.start_time-val") rb.SetK8sStatefulsetUID("k8s.statefulset.uid-val") rb.SetOpencensusResourcetype("opencensus.resourcetype-val") rb.SetOpenshiftClusterquotaName("openshift.clusterquota.name-val") diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_resource.go b/receiver/k8sclusterreceiver/internal/metadata/generated_resource.go index 61110fb7b2cb..f6d7aef62f9b 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_resource.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_resource.go @@ -63,6 +63,13 @@ func (rb *ResourceBuilder) SetK8sCronjobName(val string) { } } +// SetK8sCronjobStartTime sets provided value as "k8s.cronjob.start_time" attribute. +func (rb *ResourceBuilder) SetK8sCronjobStartTime(val string) { + if rb.config.K8sCronjobStartTime.Enabled { + rb.res.Attributes().PutStr("k8s.cronjob.start_time", val) + } +} + // SetK8sCronjobUID sets provided value as "k8s.cronjob.uid" attribute. func (rb *ResourceBuilder) SetK8sCronjobUID(val string) { if rb.config.K8sCronjobUID.Enabled { @@ -77,6 +84,13 @@ func (rb *ResourceBuilder) SetK8sDaemonsetName(val string) { } } +// SetK8sDaemonsetStartTime sets provided value as "k8s.daemonset.start_time" attribute. +func (rb *ResourceBuilder) SetK8sDaemonsetStartTime(val string) { + if rb.config.K8sDaemonsetStartTime.Enabled { + rb.res.Attributes().PutStr("k8s.daemonset.start_time", val) + } +} + // SetK8sDaemonsetUID sets provided value as "k8s.daemonset.uid" attribute. func (rb *ResourceBuilder) SetK8sDaemonsetUID(val string) { if rb.config.K8sDaemonsetUID.Enabled { @@ -91,6 +105,13 @@ func (rb *ResourceBuilder) SetK8sDeploymentName(val string) { } } +// SetK8sDeploymentStartTime sets provided value as "k8s.deployment.start_time" attribute. +func (rb *ResourceBuilder) SetK8sDeploymentStartTime(val string) { + if rb.config.K8sDeploymentStartTime.Enabled { + rb.res.Attributes().PutStr("k8s.deployment.start_time", val) + } +} + // SetK8sDeploymentUID sets provided value as "k8s.deployment.uid" attribute. func (rb *ResourceBuilder) SetK8sDeploymentUID(val string) { if rb.config.K8sDeploymentUID.Enabled { @@ -119,6 +140,13 @@ func (rb *ResourceBuilder) SetK8sJobName(val string) { } } +// SetK8sJobStartTime sets provided value as "k8s.job.start_time" attribute. +func (rb *ResourceBuilder) SetK8sJobStartTime(val string) { + if rb.config.K8sJobStartTime.Enabled { + rb.res.Attributes().PutStr("k8s.job.start_time", val) + } +} + // SetK8sJobUID sets provided value as "k8s.job.uid" attribute. func (rb *ResourceBuilder) SetK8sJobUID(val string) { if rb.config.K8sJobUID.Enabled { @@ -133,6 +161,13 @@ func (rb *ResourceBuilder) SetK8sNamespaceName(val string) { } } +// SetK8sNamespaceStartTime sets provided value as "k8s.namespace.start_time" attribute. +func (rb *ResourceBuilder) SetK8sNamespaceStartTime(val string) { + if rb.config.K8sNamespaceStartTime.Enabled { + rb.res.Attributes().PutStr("k8s.namespace.start_time", val) + } +} + // SetK8sNamespaceUID sets provided value as "k8s.namespace.uid" attribute. func (rb *ResourceBuilder) SetK8sNamespaceUID(val string) { if rb.config.K8sNamespaceUID.Enabled { @@ -168,6 +203,13 @@ func (rb *ResourceBuilder) SetK8sPodName(val string) { } } +// SetK8sPodStartTime sets provided value as "k8s.pod.start_time" attribute. +func (rb *ResourceBuilder) SetK8sPodStartTime(val string) { + if rb.config.K8sPodStartTime.Enabled { + rb.res.Attributes().PutStr("k8s.pod.start_time", val) + } +} + // SetK8sPodUID sets provided value as "k8s.pod.uid" attribute. func (rb *ResourceBuilder) SetK8sPodUID(val string) { if rb.config.K8sPodUID.Enabled { @@ -182,6 +224,13 @@ func (rb *ResourceBuilder) SetK8sReplicasetName(val string) { } } +// SetK8sReplicasetStartTime sets provided value as "k8s.replicaset.start_time" attribute. +func (rb *ResourceBuilder) SetK8sReplicasetStartTime(val string) { + if rb.config.K8sReplicasetStartTime.Enabled { + rb.res.Attributes().PutStr("k8s.replicaset.start_time", val) + } +} + // SetK8sReplicasetUID sets provided value as "k8s.replicaset.uid" attribute. func (rb *ResourceBuilder) SetK8sReplicasetUID(val string) { if rb.config.K8sReplicasetUID.Enabled { @@ -266,6 +315,13 @@ func (rb *ResourceBuilder) SetK8sStatefulsetName(val string) { } } +// SetK8sStatefulsetStartTime sets provided value as "k8s.statefulset.start_time" attribute. +func (rb *ResourceBuilder) SetK8sStatefulsetStartTime(val string) { + if rb.config.K8sStatefulsetStartTime.Enabled { + rb.res.Attributes().PutStr("k8s.statefulset.start_time", val) + } +} + // SetK8sStatefulsetUID sets provided value as "k8s.statefulset.uid" attribute. func (rb *ResourceBuilder) SetK8sStatefulsetUID(val string) { if rb.config.K8sStatefulsetUID.Enabled { diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_resource_test.go b/receiver/k8sclusterreceiver/internal/metadata/generated_resource_test.go index 3e4d1edfe5d8..ddf2aabefe14 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_resource_test.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_resource_test.go @@ -19,23 +19,30 @@ func TestResourceBuilder(t *testing.T) { rb.SetK8sClusterName("k8s.cluster.name-val") rb.SetK8sContainerName("k8s.container.name-val") rb.SetK8sCronjobName("k8s.cronjob.name-val") + rb.SetK8sCronjobStartTime("k8s.cronjob.start_time-val") rb.SetK8sCronjobUID("k8s.cronjob.uid-val") rb.SetK8sDaemonsetName("k8s.daemonset.name-val") + rb.SetK8sDaemonsetStartTime("k8s.daemonset.start_time-val") rb.SetK8sDaemonsetUID("k8s.daemonset.uid-val") rb.SetK8sDeploymentName("k8s.deployment.name-val") + rb.SetK8sDeploymentStartTime("k8s.deployment.start_time-val") rb.SetK8sDeploymentUID("k8s.deployment.uid-val") rb.SetK8sHpaName("k8s.hpa.name-val") rb.SetK8sHpaUID("k8s.hpa.uid-val") rb.SetK8sJobName("k8s.job.name-val") + rb.SetK8sJobStartTime("k8s.job.start_time-val") rb.SetK8sJobUID("k8s.job.uid-val") rb.SetK8sNamespaceName("k8s.namespace.name-val") + rb.SetK8sNamespaceStartTime("k8s.namespace.start_time-val") rb.SetK8sNamespaceUID("k8s.namespace.uid-val") rb.SetK8sNodeName("k8s.node.name-val") rb.SetK8sNodeStartTime("k8s.node.start_time-val") rb.SetK8sNodeUID("k8s.node.uid-val") rb.SetK8sPodName("k8s.pod.name-val") + rb.SetK8sPodStartTime("k8s.pod.start_time-val") rb.SetK8sPodUID("k8s.pod.uid-val") rb.SetK8sReplicasetName("k8s.replicaset.name-val") + rb.SetK8sReplicasetStartTime("k8s.replicaset.start_time-val") rb.SetK8sReplicasetUID("k8s.replicaset.uid-val") rb.SetK8sReplicationcontrollerName("k8s.replicationcontroller.name-val") rb.SetK8sReplicationcontrollerUID("k8s.replicationcontroller.uid-val") @@ -48,6 +55,7 @@ func TestResourceBuilder(t *testing.T) { rb.SetK8sServiceUID("k8s.service.uid-val") rb.SetK8sServiceAccountName("k8s.service_account.name-val") rb.SetK8sStatefulsetName("k8s.statefulset.name-val") + rb.SetK8sStatefulsetStartTime("k8s.statefulset.start_time-val") rb.SetK8sStatefulsetUID("k8s.statefulset.uid-val") rb.SetOpencensusResourcetype("opencensus.resourcetype-val") rb.SetOpenshiftClusterquotaName("openshift.clusterquota.name-val") @@ -58,9 +66,9 @@ func TestResourceBuilder(t *testing.T) { switch test { case "default": - assert.Equal(t, 39, res.Attributes().Len()) + assert.Equal(t, 47, res.Attributes().Len()) case "all_set": - assert.Equal(t, 39, res.Attributes().Len()) + assert.Equal(t, 47, res.Attributes().Len()) case "none_set": assert.Equal(t, 0, res.Attributes().Len()) return @@ -98,6 +106,11 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "k8s.cronjob.name-val", val.Str()) } + val, ok = res.Attributes().Get("k8s.cronjob.start_time") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "k8s.cronjob.start_time-val", val.Str()) + } val, ok = res.Attributes().Get("k8s.cronjob.uid") assert.True(t, ok) if ok { @@ -108,6 +121,11 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "k8s.daemonset.name-val", val.Str()) } + val, ok = res.Attributes().Get("k8s.daemonset.start_time") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "k8s.daemonset.start_time-val", val.Str()) + } val, ok = res.Attributes().Get("k8s.daemonset.uid") assert.True(t, ok) if ok { @@ -118,6 +136,11 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "k8s.deployment.name-val", val.Str()) } + val, ok = res.Attributes().Get("k8s.deployment.start_time") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "k8s.deployment.start_time-val", val.Str()) + } val, ok = res.Attributes().Get("k8s.deployment.uid") assert.True(t, ok) if ok { @@ -138,6 +161,11 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "k8s.job.name-val", val.Str()) } + val, ok = res.Attributes().Get("k8s.job.start_time") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "k8s.job.start_time-val", val.Str()) + } val, ok = res.Attributes().Get("k8s.job.uid") assert.True(t, ok) if ok { @@ -148,6 +176,11 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "k8s.namespace.name-val", val.Str()) } + val, ok = res.Attributes().Get("k8s.namespace.start_time") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "k8s.namespace.start_time-val", val.Str()) + } val, ok = res.Attributes().Get("k8s.namespace.uid") assert.True(t, ok) if ok { @@ -173,6 +206,11 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "k8s.pod.name-val", val.Str()) } + val, ok = res.Attributes().Get("k8s.pod.start_time") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "k8s.pod.start_time-val", val.Str()) + } val, ok = res.Attributes().Get("k8s.pod.uid") assert.True(t, ok) if ok { @@ -183,6 +221,11 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "k8s.replicaset.name-val", val.Str()) } + val, ok = res.Attributes().Get("k8s.replicaset.start_time") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "k8s.replicaset.start_time-val", val.Str()) + } val, ok = res.Attributes().Get("k8s.replicaset.uid") assert.True(t, ok) if ok { @@ -243,6 +286,11 @@ func TestResourceBuilder(t *testing.T) { if ok { assert.EqualValues(t, "k8s.statefulset.name-val", val.Str()) } + val, ok = res.Attributes().Get("k8s.statefulset.start_time") + assert.True(t, ok) + if ok { + assert.EqualValues(t, "k8s.statefulset.start_time-val", val.Str()) + } val, ok = res.Attributes().Get("k8s.statefulset.uid") assert.True(t, ok) if ok { diff --git a/receiver/k8sclusterreceiver/internal/metadata/generated_status.go b/receiver/k8sclusterreceiver/internal/metadata/generated_status.go index 1eaeb822b837..784c87d59c29 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/generated_status.go +++ b/receiver/k8sclusterreceiver/internal/metadata/generated_status.go @@ -4,6 +4,8 @@ package metadata import ( "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" ) const ( @@ -11,3 +13,11 @@ const ( MetricsStability = component.StabilityLevelBeta LogsStability = component.StabilityLevelDevelopment ) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/k8sclusterreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/k8sclusterreceiver") +} diff --git a/receiver/k8sclusterreceiver/internal/metadata/testdata/config.yaml b/receiver/k8sclusterreceiver/internal/metadata/testdata/config.yaml index 246f61df05d2..c1c1143f68ef 100644 --- a/receiver/k8sclusterreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/k8sclusterreceiver/internal/metadata/testdata/config.yaml @@ -102,14 +102,20 @@ all_set: enabled: true k8s.cronjob.name: enabled: true + k8s.cronjob.start_time: + enabled: true k8s.cronjob.uid: enabled: true k8s.daemonset.name: enabled: true + k8s.daemonset.start_time: + enabled: true k8s.daemonset.uid: enabled: true k8s.deployment.name: enabled: true + k8s.deployment.start_time: + enabled: true k8s.deployment.uid: enabled: true k8s.hpa.name: @@ -118,10 +124,14 @@ all_set: enabled: true k8s.job.name: enabled: true + k8s.job.start_time: + enabled: true k8s.job.uid: enabled: true k8s.namespace.name: enabled: true + k8s.namespace.start_time: + enabled: true k8s.namespace.uid: enabled: true k8s.node.name: @@ -132,10 +142,14 @@ all_set: enabled: true k8s.pod.name: enabled: true + k8s.pod.start_time: + enabled: true k8s.pod.uid: enabled: true k8s.replicaset.name: enabled: true + k8s.replicaset.start_time: + enabled: true k8s.replicaset.uid: enabled: true k8s.replicationcontroller.name: @@ -160,6 +174,8 @@ all_set: enabled: true k8s.statefulset.name: enabled: true + k8s.statefulset.start_time: + enabled: true k8s.statefulset.uid: enabled: true opencensus.resourcetype: @@ -271,14 +287,20 @@ none_set: enabled: false k8s.cronjob.name: enabled: false + k8s.cronjob.start_time: + enabled: false k8s.cronjob.uid: enabled: false k8s.daemonset.name: enabled: false + k8s.daemonset.start_time: + enabled: false k8s.daemonset.uid: enabled: false k8s.deployment.name: enabled: false + k8s.deployment.start_time: + enabled: false k8s.deployment.uid: enabled: false k8s.hpa.name: @@ -287,10 +309,14 @@ none_set: enabled: false k8s.job.name: enabled: false + k8s.job.start_time: + enabled: false k8s.job.uid: enabled: false k8s.namespace.name: enabled: false + k8s.namespace.start_time: + enabled: false k8s.namespace.uid: enabled: false k8s.node.name: @@ -301,10 +327,14 @@ none_set: enabled: false k8s.pod.name: enabled: false + k8s.pod.start_time: + enabled: false k8s.pod.uid: enabled: false k8s.replicaset.name: enabled: false + k8s.replicaset.start_time: + enabled: false k8s.replicaset.uid: enabled: false k8s.replicationcontroller.name: @@ -329,6 +359,8 @@ none_set: enabled: false k8s.statefulset.name: enabled: false + k8s.statefulset.start_time: + enabled: false k8s.statefulset.uid: enabled: false opencensus.resourcetype: diff --git a/receiver/k8sclusterreceiver/internal/pod/pods.go b/receiver/k8sclusterreceiver/internal/pod/pods.go index c07dacf97c13..65a25d578efb 100644 --- a/receiver/k8sclusterreceiver/internal/pod/pods.go +++ b/receiver/k8sclusterreceiver/internal/pod/pods.go @@ -5,11 +5,12 @@ package pod // import "github.com/open-telemetry/opentelemetry-collector-contrib import ( "context" - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig" - "k8s.io/apimachinery/pkg/labels" "strings" "time" + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig" + "k8s.io/apimachinery/pkg/labels" + "go.opentelemetry.io/collector/pdata/pcommon" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" "go.uber.org/zap" @@ -81,6 +82,7 @@ func RecordMetrics(logger *zap.Logger, mb *metadata.MetricsBuilder, pod *corev1. rb.SetK8sPodUID(string(pod.UID)) rb.SetOpencensusResourcetype("k8s") rb.SetK8sServiceName(getServiceNameForPod(pod)) + rb.SetK8sPodStartTime(pod.GetCreationTimestamp().String()) rb.SetK8sServiceAccountName(getServiceAccountNameForPod(pod)) rb.SetK8sClusterName("unknown") mb.EmitForResource(metadata.WithResource(rb.Emit())) diff --git a/receiver/k8sclusterreceiver/internal/replicaset/replicasets.go b/receiver/k8sclusterreceiver/internal/replicaset/replicasets.go index d3fde6ca6f3c..cb7f8a4640d7 100644 --- a/receiver/k8sclusterreceiver/internal/replicaset/replicasets.go +++ b/receiver/k8sclusterreceiver/internal/replicaset/replicasets.go @@ -36,6 +36,7 @@ func RecordMetrics(mb *metadata.MetricsBuilder, rs *appsv1.ReplicaSet, ts pcommo rb.SetK8sNamespaceName(rs.Namespace) rb.SetK8sReplicasetName(rs.Name) rb.SetK8sReplicasetUID(string(rs.UID)) + rb.SetK8sReplicasetStartTime(rs.GetCreationTimestamp().String()) rb.SetOpencensusResourcetype("k8s") mb.EmitForResource(metadata.WithResource(rb.Emit())) } diff --git a/receiver/k8sclusterreceiver/internal/statefulset/statefulsets.go b/receiver/k8sclusterreceiver/internal/statefulset/statefulsets.go index e1d4b29e1ce3..a2a7bd0af4c9 100644 --- a/receiver/k8sclusterreceiver/internal/statefulset/statefulsets.go +++ b/receiver/k8sclusterreceiver/internal/statefulset/statefulsets.go @@ -47,6 +47,7 @@ func RecordMetrics(mb *imetadata.MetricsBuilder, ss *appsv1.StatefulSet, ts pcom rb.SetK8sStatefulsetUID(string(ss.UID)) rb.SetK8sStatefulsetName(ss.Name) rb.SetK8sNamespaceName(ss.Namespace) + rb.SetK8sStatefulsetStartTime(ss.GetCreationTimestamp().String()) rb.SetOpencensusResourcetype("k8s") mb.EmitForResource(imetadata.WithResource(rb.Emit())) } diff --git a/receiver/k8sclusterreceiver/metadata.yaml b/receiver/k8sclusterreceiver/metadata.yaml index 6fa059c47afe..55d58cec09bb 100644 --- a/receiver/k8sclusterreceiver/metadata.yaml +++ b/receiver/k8sclusterreceiver/metadata.yaml @@ -209,6 +209,46 @@ resource_attributes: description: The OpenCensus resource type. type: string enabled: true + + k8s.daemonset.start_time: + description: "The start time of the Daemonset." + enabled: true + type: string + + k8s.deployment.start_time: + description: "The start time of the Deployment." + enabled: true + type: string + + k8s.job.start_time: + description: "The start time of the Job." + enabled: true + type: string + + k8s.cronjob.start_time: + description: "The start time of the Cronjob." + enabled: true + type: string + + k8s.replicaset.start_time: + description: "The start time of the Replicaset." + enabled: true + type: string + + k8s.statefulset.start_time: + description: "The start time of the Statefulset." + enabled: true + type: string + + k8s.namespace.start_time: + description: "The start time of the Namespace." + enabled: true + type: string + + k8s.pod.start_time: + description: "The start time of the Pod." + enabled: true + type: string attributes: k8s.namespace.name: