-
Notifications
You must be signed in to change notification settings - Fork 8
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
DEV VX-142: Node metrics handler #59
Conversation
@@ -0,0 +1,41 @@ | |||
package entity | |||
|
|||
type NICNetworkTrafficMetrics struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the json structure tag
src/server/handler_prometheus.go
Outdated
@@ -17,15 +19,12 @@ func queryMetrics(ctx *web.Context) { | |||
|
|||
query := query.New(req.Request.URL.Query()) | |||
|
|||
query_str := "" | |||
expression := "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about using var expression string
?
src/server/handler_node_metrics.go
Outdated
func listNodeMetricsHandler(ctx *web.Context) { | ||
sp, req, resp := ctx.ServiceProvider, ctx.Request, ctx.Response | ||
|
||
result, err := queryFromPrometheus(sp, "sum by (node)(kube_node_info)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should handle error. rignt?
src/server/handler_node_metrics.go
Outdated
node.Info.Labels = map[string]string{} | ||
node.NICs = map[string]entity.NICMetrics{} | ||
|
||
results, _ := queryFromPrometheus(sp, `{__name__=~"kube_node_info|kube_node_created|node_network_interface|kube_node_labels|kube_node_status_allocatable_cpu_cores|kube_node_status_allocatable_memory_bytes|kube_node_status_capacity_cpu_cores|kube_node_status_capacity_memory_bytes|",node=~"`+id+`"}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should handle error. rignt?
src/server/handler_node_metrics.go
Outdated
} | ||
} | ||
|
||
results, _ = queryFromPrometheus(sp, `sum by(__name__, resource) ({__name__=~"kube_pod_container_resource_limits|kube_pod_container_resource_requests",node=~"`+id+`"})`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should handle error. rignt?
src/server/handler_node_metrics.go
Outdated
} | ||
} | ||
|
||
results, _ = queryFromPrometheus(sp, `{__name__=~"node_network_interface|node_network_receive_bytes_total|node_network_transmit_bytes_total|node_network_receive_packets_total|node_network_transmit_packets_total",node=~"`+id+`"}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should handle error. rignt?
src/server/handler_prometheus.go
Outdated
|
||
testTime := time.Now() | ||
result, err := api.Query(context.Background(), query_str, testTime) | ||
result, err := queryFromPrometheus(sp, expression) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should handle error. rignt?
Codecov Report
@@ Coverage Diff @@
## develop #59 +/- ##
============================================
- Coverage 80.84% 68.06% -12.78%
============================================
Files 23 29 +6
Lines 637 927 +290
============================================
+ Hits 515 631 +116
- Misses 88 255 +167
- Partials 34 41 +7
Continue to review full report at Codecov.
|
1962d80
to
d79c18b
Compare
f7c6748
to
3673e84
Compare
DEV VX-142: Node metrics handler Former-commit-id: b9ce90d2974a0455d64b7c21a6aaf21287f5040f [formerly 95fc862] Former-commit-id: a881820fb01395748899590dde8f60eb5c50a654
DEV VX-142: Node metrics handler
No description provided.