api_server_metrics.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. Copyright 2015 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package metrics
  14. type ApiServerMetrics Metrics
  15. func (m *ApiServerMetrics) Equal(o ApiServerMetrics) bool {
  16. return (*Metrics)(m).Equal(Metrics(o))
  17. }
  18. func NewApiServerMetrics() ApiServerMetrics {
  19. result := NewMetrics()
  20. return ApiServerMetrics(result)
  21. }
  22. func parseApiServerMetrics(data string) (ApiServerMetrics, error) {
  23. result := NewApiServerMetrics()
  24. if err := parseMetrics(data, (*Metrics)(&result)); err != nil {
  25. return ApiServerMetrics{}, err
  26. }
  27. return result, nil
  28. }
  29. func (g *MetricsGrabber) getMetricsFromApiServer() (string, error) {
  30. rawOutput, err := g.client.Get().RequestURI("/metrics").Do().Raw()
  31. if err != nil {
  32. return "", err
  33. }
  34. return string(rawOutput), nil
  35. }