Skip to content

Commit

Permalink
feat: K8s containers for cAdvisor & kubeletstats telemetry (#1526)
Browse files Browse the repository at this point in the history
* feat: K8s containers for cAdvisor & kubeletstats telemetry

* test: Sample telemetry for k8s containers via ksm, kubeletstats, cadvisor

---------

Co-authored-by: Javi Imbernón <[email protected]>
  • Loading branch information
brettj-newrelic and javimb authored Mar 12, 2024
1 parent c83c4c6 commit 3aadc5c
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 0 deletions.
64 changes: 64 additions & 0 deletions entity-types/infra-container/definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,70 @@ synthesis:
# value added for test entities only
- attribute: newrelicOnly
value: "true"
# cAdvisor data via opentelemetry prometheusReceiver
- compositeIdentifier:
separator: ":"
attributes:
- k8s.cluster.name
- namespace
- pod
- container
encodeIdentifierInGUID: true
name: container
conditions:
# cadvisor container prefix
- attribute: metricName
prefix: container_
# identifier attributes
- attribute: container
present: true
- attribute: pod
present: true
- attribute: namespace
present: true
- attribute: k8s.cluster.name
present: true
# open telemetry
- attribute: newrelic.source
value: 'api.metrics.otlp'
# if service.name is present, handle as one
- attribute: service.name
present: false
# value added for test entities only
- attribute: newrelicOnly
value: "true"
# kubeletstatsreceiver data via opentelemetry
- compositeIdentifier:
separator: ":"
attributes:
- k8s.cluster.name
- k8s.namespace.name
- k8s.pod.name
- k8s.container.name
encodeIdentifierInGUID: true
name: k8s.container.name
conditions:
# cadvisor container prefix
- attribute: metricName
prefix: container.
# identifier attributes
- attribute: k8s.container.name
present: true
- attribute: k8s.pod.name
present: true
- attribute: k8s.namespace.name
present: true
- attribute: k8s.cluster.name
present: true
# open telemetry
- attribute: newrelic.source
value: 'api.metrics.otlp'
# if service.name is present, handle as one
- attribute: service.name
present: false
# value added for test entities only
- attribute: newrelicOnly
value: "true"
tags:
newrelic.integrationName:
newrelic.integrationVersion:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"k8s.cluster.name": "farm",
"namespace": "orchards",
"pod": "tree-afge",
"container": "peach-332",
"newrelic.source": "api.metrics.otlp",
"newrelicOnly": "true",
"metricName": "container_start_time_seconds",
"container_cpu_usage_seconds_total": {"type":"gauge","count":1,"sum":1.70794305E9,"min":1.70794305E9,"max":1.70794305E9,"latest":1.70794305E9}
},
{
"k8s.cluster.name": "universe",
"namespace": "solar-system",
"pod": "earth",
"container": "verdant-forest",
"newrelic.source": "api.metrics.otlp",
"newrelicOnly": "true",
"metricName": "container_cpu_usage_seconds_total",
"container_cpu_usage_seconds_total": {"type":"cumulativeCount","count":0.0,"cumulative":1123.000001},
"description": "Cumulative cpu time consumed in seconds",
"otel.library.name": "otelcol/prometheusreceiver",
"otel.library.version": "0.91.0",
"instrumentation.provider": "opentelemetry",
"cpu": "total",
"end_timestamp": 1710174211131,
"http.scheme": "https",
"id": "/system.slice/kubelet.service",
"image": "gke.gcr.io/foo@sha256:111122223333aaaabbbbbcccccddddd",
"k8s.node.name": "verdant-forests-123",
"net.host.name": "verdant-forests-123",
"service.instance.id": "verdant-forests-123",
"name": "5bcc88d422b8b50b"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"k8s.cluster.name": "farm",
"namespace": "orchards",
"pod": "tree-afge",
"container": "peach-332",
"newrelic.source": "api.metrics.otlp",
"newrelicOnly": "true",
"metricName": "kube_pod_container_status_ready",
"kube_pod_container_status_ready": {"type":"gauge","count":1,"sum":1.0,"min":1.0,"max":1.0,"latest":1.0}
},
{
"k8s.cluster.name": "universe",
"namespace": "solar-system",
"pod": "earth",
"container": "verdant-forest",
"newrelic.source": "api.metrics.otlp",
"newrelicOnly": "true",
"metricName": "kube_pod_container_info",
"kube_pod_container_info": {"type":"gauge","count":1,"sum":1.0,"min":1.0,"max":1.0,"latest":1.0},
"description": "[STABLE] Information about a container in a pod.",
"otel.library.name": "otelcol/prometheusreceiver",
"otel.library.version": "0.91.0",
"instrumentation.provider": "opentelemetry",
"image":"sha256:1f337e7e6242ffe8cb590da7fa41ed409b8f759bcb075767b74d3861c9d25cc0",
"image_id":"gke.gcr.io/foo@sha256:3aaf29f6967aafd47e50007eedc9c2ac78a202a213f43af92e0b9ccfebc63636",
"image_spec":"gke.gcr.io/foo@sha256:3aaf29f6967aafd47e50007eedc9c2ac78a202a213f43af92e0b9ccfebc63636",
"net.host.port": "8080",
"net.host.name": "11.11.1.11",
"service.instance.id": "11.11.1.11:8080",
"http.scheme": "http",
"container_id": "containerd://b413084f553d6c30d4f96e7ceeef60d858ec9dbce93d93d945afd15398fb5f0d"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"k8s.cluster.name": "farm",
"k8s.namespace.name": "orchards",
"k8s.pod.name": "tree-afge",
"k8s.container.name": "peach-332",
"newrelic.source": "api.metrics.otlp",
"newrelicOnly": "true",
"metricName": "container.cpu.utilization",
"container.cpu.utilization": {"type":"gauge","count":1,"sum":9.04E-6,"min":9.04E-6,"max":9.04E-6,"latest":9.04E-6}
},
{
"k8s.cluster.name": "universe",
"k8s.namespace.name": "solar-system",
"k8s.pod.name": "earth",
"k8s.container.name": "verdant-forest",
"newrelic.source": "api.metrics.otlp",
"newrelicOnly": "true",
"metricName": "container.memory.usage",
"container.memory.usage": {"type":"gauge","count":1,"sum":3.0121984E7,"min":3.0121984E7,"max":3.0121984E7,"latest":3.0121984E7},
"k8s.pod.uid": "1a91119-1d15-416c-1bb1-11a1821f381b",
"k8s.pod.start_time": "2023-02-05T05:23:54Z",
"k8s.node.name": "verdant-forests-123",
"description": "Container memory usage",
"otel.library.name": "otelcol/kubeletstatsreceiver",
"otel.library.version": "0.91.0",
"instrumentation.provider": "opentelemetry",
"unit": "By"
}
]

0 comments on commit 3aadc5c

Please sign in to comment.