Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubelet raw metrics API proposal #15862

Merged
merged 1 commit into from Oct 29, 2015

Conversation

timstclair
Copy link

Forked from discussion on #15691
Addresses #12483

cc/ @vishh @jimmidyson @dchen1107 @bgrant0607

- `start` - start time to return metrics from; type json encoded `time.Time`
- `end` - end time to return metrics to; type json encoded `time.Time`
- `count` - maximum number of stats to return in each ContainerMetrics instance;
type int
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @lavalamp says, this is "poor-man's paging" -- Is there a better way to structure this parameter to support proper paging in the future (e.g. should this be max total stats, as opposed to max per-container stats?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can get rid of this parameter. What we ideally need is a way to downsample the data returned, to reduce the load on the higher layers and the network.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have this as a step between results. We could calculate a reasonable step depending on size of window between start & end.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimmidyson what do you mean by a step? Time step? In that case, we would need to validate that the raw metrics step evenly divides it.

@vishh is step & downsample the same thing? In either case, would we aggregate samples, or just drop samples not requested?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes a time step. IMO metrics should be reported at regular intervals for ease of use & understanding.

I would drop samples not requested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.
An usual query is something like "give me stats every 30 seconds for the
last five minutes".
I can express the duration with start and end. Adding step or rate
will help us express the downsampling rate.

On Mon, Oct 19, 2015 at 3:30 PM, Tim St. Clair notifications@github.com
wrote:

In docs/proposals/kubelet-raw-metrics-api.md
#15862 (comment)
:

+- /pods - All pod metrics across all namespaces; type []metrics.Pod
+- /namespaces/{namespace}/pods - All pod metrics within namespace; type

  • []metrics.Pod
    +- /namespaces/{namespace}/pods/{pod} - metrics for specific pod; type
  • metrics.Pod
    +- Unsupported paths return status not found (404)
    • /namespaces/
    • /namespaces/{namespace}

+Additionally, all endpoints (except root discovery endpoint) support the
+following optional query parameters:
+
+- start - start time to return metrics from; type json encoded time.Time
+- end - end time to return metrics to; type json encoded time.Time
+- count - maximum number of stats to return in each ContainerMetrics instance;

  • type int

@jimmidyson https://github.com/jimmidyson what do you mean by a step?
Time step? In that case, we would need to validate that the raw metrics
step evenly divides it.

@vishh https://github.com/vishh is step & downsample the same thing? In
either case, would we aggregate samples, or just drop samples not requested?


Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/15862/files#r42434514.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK so can we change count? I prefer step or interval to rate as that normally refers to rate of change when talking about metrics.

IMO this should be optional & a reasonable step value should be calculated from the requested window size.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I went with step. However, I disagree that the default should be variable based on the window size. I think it will be better to have a default (predictable) default size. For instance, if I make a request and get back stats ever 10 seconds, and then increase my window size by 30 seconds, I'd expect to get 3 more stats back, not get the same number spaced 11 seconds apart.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added count back as there is a heapster use case for it.

cc/ @mwielgus

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use case? What is the behaviour if available metrics are greater than requested count? Trim from beginning or end of window?

@k8s-github-robot
Copy link

Labelling this PR as size/L

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 19, 2015
@vishh
Copy link
Contributor

vishh commented Oct 19, 2015

Thanks for the proposal @timstclair! Much appreciated!

@k8s-bot
Copy link

k8s-bot commented Oct 19, 2015

GCE e2e test build/test passed for commit 05794bcf947ab20f2de6f12d75f61c43667d9b79.

@timstclair
Copy link
Author

FYI, added a few notes about implementation.

@k8s-bot
Copy link

k8s-bot commented Oct 19, 2015

GCE e2e test build/test passed for commit 6c8d1c3ff400b7cb6ad9b169de5bba42acea9c50.

// ContainerMetrics is a k8s wrapper around cAdvisor metrics
type ContainerMetrics struct {
ObjectMeta, TypeMeta
Info cadvisorv2.ContainerInfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer all type information to be in Kubernetes & provide a converter from cadvisor API to Kubernetes API, even if that is a 1-1 field mapping. More independent of implementation & can be versioned separately.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cadvisor APIs are also versioned right. What do we get by adding one more layer of versioning here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth noting that the API is currently completely self contained. I don't have a strong opinion here, but I bet someone else does :)

I think the important pieces are that everything is documented together in the same place. If the cadvisor API has separate documentation, I think that's a pretty strong argument for cloning the API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO cadvisor is an implementation detail. Great that the cadvisor API is versioned, but I think the metrics API needs to be fully self-contained & versioned independently. Also using the cadvisor API directly would leak cadvisor details through to the unversioned representations as per the Kubernetes API conventions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sold. We'll mirror the cadvisor v2 APIs in the versioned metrics API, and also add ObjectMeta & TypeMeta to each object.

@timstclair timstclair force-pushed the metrics-proposal branch 2 times, most recently from d716bf7 to a8edd1f Compare October 20, 2015 17:42
@k8s-bot
Copy link

k8s-bot commented Oct 20, 2015

GCE e2e build/test failed for commit d716bf7d0c167e4db1a72088d9061215e9d8e25b.

@k8s-bot
Copy link

k8s-bot commented Oct 20, 2015

GCE e2e test build/test passed for commit a8edd1f22285c08fae7af0c1308507296546f336.

@timstclair
Copy link
Author

Ok, merged this proposal into the existing DerivedMetrics proposal. I updated that proposal to be consistent with everything proposed here. Comment away!

@k8s-bot
Copy link

k8s-bot commented Oct 21, 2015

GCE e2e build/test failed for commit 064f35657c6cf02f32831bbe67193a88653518a7.

@jimmidyson
Copy link
Member

👍 Nice work @timstclair!

@timstclair
Copy link
Author

@mwielgus - What were the heapster requirements we discussed yesterday? I remember:

  • pod labels
  • pod status

Was there anything else?

@mwielgus
Copy link
Contributor

@timstclair
Pod status and container CPU/mem request/limit.

cc: @piosz

@dchen1107 dchen1107 assigned dchen1107 and unassigned brendandburns Oct 22, 2015
- `/nodes/localhost` - When served by kubelet, the only node provided is
`localhost`; type metrics.Node
- `/nodes/{node}` - metrics for a specific node
- `/derivedNodes` - host metrics; type `[]metrics.DerivedNode`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we document here the difference between /nodes and /derivedNodes? Same for /pods?

From the document, i cannot see any difference.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

- `end` - end time to return metrics to; type json encoded `time.Time`
- `step` - the time step between each stats sample; type int (seconds), default
10s, must be a multiple of 10s
- `count` - maximum number of stats to return in each ContainerMetrics instance;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? @piosz @mwielgus

@k8s-bot
Copy link

k8s-bot commented Oct 23, 2015

GCE e2e test build/test passed for commit 3f367bb7fda13da6b93256b712494b3991a8fde0.

@k8s-bot
Copy link

k8s-bot commented Oct 23, 2015

GCE e2e build/test failed for commit e085448688919be57369e7b6c49681da3682c359.

@k8s-bot
Copy link

k8s-bot commented Oct 23, 2015

GCE e2e test build/test passed for commit fa3feac0ff04c2705ee1803a555b1e0d35852618.

- `/rawNodes/localhost` - The only node provided is `localhost`; type
metrics.Node
- `/derivedNodes` - host metrics; type `[]metrics.DerivedNode`
- `/nodes/{node}` - derived metrics for a specific node
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derivedNodes

@dchen1107
Copy link
Member

LGTM

@dchen1107 dchen1107 added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 27, 2015
@dchen1107 dchen1107 closed this Oct 27, 2015
@dchen1107 dchen1107 reopened this Oct 27, 2015
@k8s-bot
Copy link

k8s-bot commented Oct 27, 2015

GCE e2e build/test failed for commit fa3feac0ff04c2705ee1803a555b1e0d35852618.

@timstclair
Copy link
Author

@k8s-bot test this

@k8s-bot
Copy link

k8s-bot commented Oct 27, 2015

GCE e2e test build/test passed for commit fa3feac0ff04c2705ee1803a555b1e0d35852618.

@timstclair
Copy link
Author

squashed

@k8s-github-robot
Copy link

PR changed after LGTM, removing LGTM.

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 27, 2015
@timstclair timstclair added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 27, 2015
@k8s-bot
Copy link

k8s-bot commented Oct 27, 2015

GCE e2e test build/test passed for commit accb08c.

@wojtek-t
Copy link
Member

@k8s-bot unit test this please

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Oct 29, 2015
@k8s-github-robot k8s-github-robot merged commit 139e158 into kubernetes:master Oct 29, 2015
}
type RawPod struct {
TypeMeta
ObjectMeta // Should include pod name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timstclair: I just remembered that network usage is at the pod level and volumes disk usage is also at the pod level. So in addition to container metrics, we will have pod level metrics too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we move those stats out of ContainerStats and into RawPod, add additional NetworkStats into the RawPod, or add a new Network stats type?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Its either that or we can pre-define an infrastructure container and
associate all pod level stats to that container. Even in that case, volume
fs usage cannot belong to any containers.

On Thu, Oct 29, 2015 at 2:29 PM, Tim St. Clair notifications@github.com
wrote:

In docs/proposals/compute-resource-metrics-api.md
#15862 (comment)
:

+## Schema
+
+Types are colocated with other API groups in /pkg/apis/metrics, and follow api
+groups conventions there.
+
+```go
+// Raw metrics are only available through the kubelet API.
+type RawNode struct {

  • TypeMeta
  • ObjectMeta // Should include node name
  • Machine ContainerMetrics
  • SystemContainers []ContainerMetrics
    +}
    +type RawPod struct {
  • TypeMeta
  • ObjectMeta // Should include pod name

Would we move those stats out of ContainerStats
https://github.com/timstclair/cadvisor/blob/master/info/v2/container.go#L105
and into RawPod, add additional NetworkStats into the RawPod, or add a new
Network stats type?


Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/15862/files#r43446885.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/design Categorizes issue or PR as related to design. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet