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

chore: address some gaps in k8s monitoring #6653

Merged
merged 2 commits into from
Dec 19, 2024
Merged

chore: address some gaps in k8s monitoring #6653

merged 2 commits into from
Dec 19, 2024

Conversation

srikanthccv
Copy link
Member

@srikanthccv srikanthccv commented Dec 17, 2024

Summary

Part of #5373

  1. Certain metrics like pod phase encode the state of the pod in value. This makes them non-aggregatable. Ideally, they should encode the state in labels. To address this, I added a special filters __value, which can be used to filter out metrics with value in the query. So if you want to count the number of pods in running state, you can __value=2. The same applies to node conditions. All the changes related to MetricValueFilter are doing this.

  2. Change of SpaceAggregationSum to SpaceAggregationAvg. This is because it not meaningful to sum up the utilization percentage values. Example, if you have 2 pods with 1 cpu request and they are using 2 cpu each, then the utilization as a percentage is 200% for both. If you sum up the utilization, you get 400%, which is not correct (because the total cpu request is 2 and the total cpu usage is 4, which is 200% utilization).

  3. Fix the map key for cpu_request and memory_request

  4. Add pod phase and node condition metrics to the default metrics list.


Important

Enhances Kubernetes monitoring by adding value-based metric filtering, adjusting aggregation methods, and including new metrics for pod phases and node conditions.

  • Behavior:
    • Introduces __value filter in query_builder.go to filter metrics by value, applicable in nodes_query.go, pods_query.go, and workload_query.go.
    • Changes SpaceAggregationSum to SpaceAggregationAvg in pods_query.go, workload_query.go, and query_builder.go to correctly calculate utilization percentages.
    • Adds pod phase and node condition metrics to default metrics in namespaces.go, nodes.go, and pods.go.
  • Models:
    • Adds NodeCountByCondition and PodCountByPhase to infra.go for enhanced metric tracking.
  • Misc:
    • Fixes map key for cpu_request and memory_request in workload_query.go.
    • Adds AddMetricValueFilter function in query_builder.go to support new filtering logic.

This description was created by Ellipsis for c795f58. It will automatically update as commits are pushed.

@github-actions github-actions bot added the chore label Dec 17, 2024
@srikanthccv srikanthccv changed the base branch from develop to main December 19, 2024 10:32
@srikanthccv srikanthccv marked this pull request as ready for review December 19, 2024 10:33
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to c795f58 in 1 minute and 45 seconds

More details
  • Looked at 782 lines of code in 16 files
  • Skipped 0 files when reviewing.
  • Skipped posting 11 drafted comments based on config settings.
1. pkg/query-service/app/metrics/query_builder.go:12
  • Draft comment:
    The AddMetricValueFilter function has repetitive code for different numeric types. Consider using a type switch with a single case for all numeric types to reduce redundancy.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR introduces a new filter __value to handle non-aggregatable metrics by encoding state in labels. This is a good approach to make metrics aggregatable. However, the implementation of AddMetricValueFilter function in pkg/query-service/app/metrics/query_builder.go can be optimized. The function currently has repetitive code for different numeric types, which can be simplified.
2. pkg/query-service/app/inframetrics/pods_query.go:54
  • Draft comment:
    The SpaceAggregation for utilization metrics should be SpaceAggregationAvg instead of SpaceAggregationSum. This change is necessary to correctly aggregate percentage values. Please ensure this change is applied consistently across all relevant queries.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
3. pkg/query-service/app/metrics/v3/query_builder.go:336
  • Draft comment:
    The AddMetricValueFilter function has repetitive code for different numeric types. Consider using a type switch with a single case for all numeric types to reduce redundancy.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR introduces a new filter __value to handle non-aggregatable metrics by encoding state in labels. This is a good approach to make metrics aggregatable. However, the implementation of AddMetricValueFilter function in pkg/query-service/app/metrics/query_builder.go can be optimized. The function currently has repetitive code for different numeric types, which can be simplified.
4. pkg/query-service/app/metrics/v4/query_builder.go:21
  • Draft comment:
    The AddMetricValueFilter function has repetitive code for different numeric types. Consider using a type switch with a single case for all numeric types to reduce redundancy.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR introduces a new filter __value to handle non-aggregatable metrics by encoding state in labels. This is a good approach to make metrics aggregatable. However, the implementation of AddMetricValueFilter function in pkg/query-service/app/metrics/query_builder.go can be optimized. The function currently has repetitive code for different numeric types, which can be simplified.
5. pkg/query-service/app/inframetrics/namespaces.go:311
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in multiple places in the code.
  • Reason this comment was not posted:
    Comment was on unchanged code.
6. pkg/query-service/app/inframetrics/nodes.go:329
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in multiple places in the code.
  • Reason this comment was not posted:
    Marked as duplicate.
7. pkg/query-service/app/inframetrics/pods.go:371
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in multiple places in the code.
  • Reason this comment was not posted:
    Marked as duplicate.
8. pkg/query-service/app/inframetrics/pods_query.go:203
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in multiple places in the code.
  • Reason this comment was not posted:
    Marked as duplicate.
9. pkg/query-service/app/metrics/query_builder.go:12
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in multiple places in the code.
  • Reason this comment was not posted:
    Marked as duplicate.
10. pkg/query-service/app/metrics/v3/query_builder.go:339
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in multiple places in the code.
  • Reason this comment was not posted:
    Marked as duplicate.
11. pkg/query-service/app/metrics/v4/cumulative/table.go:23
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components. This is applicable in multiple places in the code.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_09H8UZX5ndxmPLIu


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@srikanthccv srikanthccv merged commit 77420b9 into main Dec 19, 2024
18 of 19 checks passed
@srikanthccv srikanthccv deleted the gaps-infra branch December 19, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants