influxdata / influxdata/telegraf
Include resource requests and limits in `kubernetes` plugin output for containers
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 17.8k
- Forks
- 5.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 161
Description
## 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 `join`s 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the kubernetes input plugin's pod-container collection and compare it with kube_inventory's resource fields; the issue says the needed data is already in the same pod API response. Confirm how the kubernetes_pod_container measurement is emitted, then verify that resource usage, requests, and limits can be queried together with matching tags and timestamps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- devops, observability-sre
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100