influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.63k stars 5.58k forks source link

Include resource requests and limits in `kubernetes` plugin output for containers #8565

Open philomory opened 3 years ago

philomory commented 3 years ago

Feature Request

I'd like the kubernetes input plugin to include the resource limits and requests as fields in the kubernetes_pod_container measurement.

Proposal:

The kubernetes input should include resource limits and requests in the kubernetes_pod_container measurement. Currently, the only way to get this information is to also run the kube_inventory input plugin, however, this is sub-optimal for a few reasons:

  1. The kube_inventory plugin doesn't apply the same pod-specific tags that the kubernetes plugin does (see #8546)
  2. Running the kube_inventory plugin means making a bunch of extra API requests, even if the only additional information you're looking for is the resource limits.
  3. The kubernetes plugin is already fetching all of the necessary information as part of the same API request with which it gets the pod labels, names, etc. It just doesn't include the information in the emitted metrics.

Current behavior:

Resource usage comes from the kubernetes plugin, and resource requests/limits come from the kube_inventory plugin.

Desired behavior:

I can get resource usage and resource requests from a single plugin.

Use case:

If I want to compare container resource usage against resource limits and requests, I have to use two different input plugins. These two plugins tag their emitted metrics differently, and so they can't be combined with pivot, instead requiring otherwise-unecessary joins in InfluxDB when querying.

Leaving aside the question of whether it's necessary to have two different plugins for different subsets of Kubernetes metrics (I could go either way on that), I think resource limits and requests should be part of the same measurement as resource usage; it's very likely you'll want to work on these two fields at the same time, so it's useful to have them in the same plugin so they get the same tags, the same timestamps, etc.

powersj commented 2 years ago

next steps: look to make the above changes so users do not need to run both plugins

sspaink commented 2 years ago

Related issue: https://github.com/influxdata/telegraf/issues/9451