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

feat(centraldashboard): Displaying metrics from Prometheus #7116

Merged

Conversation

axel7083
Copy link
Contributor

@axel7083 axel7083 commented May 2, 2023

Through the MetricsService1, the central dashboard support showing cluster metrics from the google api. The aim of this PR is to add support for Prometheus.

Changes

Backend

  • Adding /api/metrics endpoint for resourceChartsLink and resourceChartsLinkText field.
  • Adding PrometheusMetricsService class implementing MetricsService
  • Adding prometheus-query package

MetricsService interface

  • Adding getChartsLink(): MetricsInfo to MetricsService. It will be used to send client the info about the metrics (resourceChartsLink and resourceChartsLinkText).

env

This PR add two environment variable

  • PROMETHEUS_URL: url for prometheus query
  • METRICS_DASHBOARD: if defined, will add a button under graphs to go to the url defined

Prometheus query

The query used for each function specified by the MetricsService interface.

  • getNodeCpuUtilization: sum(rate(node_cpu_seconds_total[5m])) by (instance)
  • getPodCpuUtilization: sum(rate(container_cpu_usage_seconds_total[5m]))
  • getPodMemoryUsage: sum(container_memory_usage_bytes)

Frontend

  • Adding iron-ajax to /api/metrics.
  • Adding metrics properties to main-page and dashboard-view.
  • Making footer of ressource-chart.js hidden if resourceChartsLink is undefined.

Issue(s)

The current version does not support authentication with Prometheus. Considering it is private and use Istio in kubeflow.

Footnotes

  1. metrics_service.ts

Adding /api/metrics endpoint for `resourceChartsLink` and `resourceChartsLinkText` field.

Adding PrometheusMetricsService class implementing MetricsService

Adding `prometheus-query` package

## MetricsService

Adding `getChartsLink(): MetricsInfo` to MetricsService. It will be used to send client the info about the metrics (resourceChartsLink and resourceChartsLinkText).

## env

- PROMETHEUS_URL: url for prometheus query
- METRICS_DASHBOARD: if defined, will add a button under graphs to go to the url defined

## Prometheus query

- getNodeCpuUtilization: `sum(rate(node_cpu_seconds_total[5m])) by (instance)`
- getPodCpuUtilization: `sum(rate(container_cpu_usage_seconds_total[5m]))`
- getPodMemoryUsage: `sum(container_memory_usage_bytes)`

# frontend

Adding iron-ajax to `/api/metrics`.
Adding `metrics` properties to main-page and dashboard-view.
Making footer of `ressource-chart.js` hidden if resourceChartsLink is undefined.
@google-oss-prow google-oss-prow bot added size/L and removed size/XXL labels May 2, 2023
@axel7083 axel7083 changed the title centraldashboard: Displaying metrics from Prometheus feat(centraldashboard): Displaying metrics from Prometheus Jun 8, 2023
@kimwnasptd
Copy link
Member

Looks great @axel7083!

/lgtm
/approve

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kimwnasptd

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 14e242d into kubeflow:master Jun 13, 2023
2 checks passed
tzstoyanov pushed a commit to tzstoyanov/kubeflow that referenced this pull request Jun 14, 2023
…7116)

* # backend

Adding /api/metrics endpoint for `resourceChartsLink` and `resourceChartsLinkText` field.

Adding PrometheusMetricsService class implementing MetricsService

Adding `prometheus-query` package

## MetricsService

Adding `getChartsLink(): MetricsInfo` to MetricsService. It will be used to send client the info about the metrics (resourceChartsLink and resourceChartsLinkText).

## env

- PROMETHEUS_URL: url for prometheus query
- METRICS_DASHBOARD: if defined, will add a button under graphs to go to the url defined

## Prometheus query

- getNodeCpuUtilization: `sum(rate(node_cpu_seconds_total[5m])) by (instance)`
- getPodCpuUtilization: `sum(rate(container_cpu_usage_seconds_total[5m]))`
- getPodMemoryUsage: `sum(container_memory_usage_bytes)`

# frontend

Adding iron-ajax to `/api/metrics`.
Adding `metrics` properties to main-page and dashboard-view.
Making footer of `ressource-chart.js` hidden if resourceChartsLink is undefined.

* Fixing package-lock.json

* Adding Unit Tests and Improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants