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

DEV VX-142: Node metrics handler #59

Merged
merged 11 commits into from
Jul 5, 2018
Merged

DEV VX-142: Node metrics handler #59

merged 11 commits into from
Jul 5, 2018

Conversation

WakeupTsai
Copy link
Contributor

No description provided.

@WakeupTsai WakeupTsai requested review from John-Lin and hwchiu July 4, 2018 05:36
@@ -0,0 +1,41 @@
package entity

type NICNetworkTrafficMetrics struct {
Copy link
Contributor

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

@@ -17,15 +19,12 @@ func queryMetrics(ctx *web.Context) {

query := query.New(req.Request.URL.Query())

query_str := ""
expression := ""
Copy link
Contributor

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?

func listNodeMetricsHandler(ctx *web.Context) {
sp, req, resp := ctx.ServiceProvider, ctx.Request, ctx.Response

result, err := queryFromPrometheus(sp, "sum by (node)(kube_node_info)")
Copy link
Contributor

Choose a reason for hiding this comment

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

should handle error. rignt?

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+`"}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

should handle error. rignt?

}
}

results, _ = queryFromPrometheus(sp, `sum by(__name__, resource) ({__name__=~"kube_pod_container_resource_limits|kube_pod_container_resource_requests",node=~"`+id+`"})`)
Copy link
Contributor

Choose a reason for hiding this comment

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

should handle error. rignt?

}
}

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+`"}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

should handle error. rignt?


testTime := time.Now()
result, err := api.Query(context.Background(), query_str, testTime)
result, err := queryFromPrometheus(sp, expression)
Copy link
Contributor

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-io
Copy link

codecov-io commented Jul 4, 2018

Codecov Report

Merging #59 into develop will decrease coverage by 12.77%.
The diff coverage is 10.58%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
src/server/handler_node_metrics.go 0% <0%> (ø)
src/server/route.go 64.44% <100%> (+1.65%) ⬆️
src/server/handler_prometheus.go 82.14% <76.19%> (-17.86%) ⬇️
src/storageprovider/storage.go 100% <0%> (ø)
src/storageprovider/nfs.go 0% <0%> (ø)
src/server/handler_storage.go 83.67% <0%> (ø)
src/kubernetes/deployment.go 100% <0%> (ø)
src/storageprovider/fake.go 100% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 043ed08...abb0a8f. Read the comment docs.

@John-Lin John-Lin merged commit 95fc862 into develop Jul 5, 2018
@John-Lin John-Lin deleted the phstsai/VX-142 branch July 5, 2018 10:39
John-Lin added a commit that referenced this pull request Jul 25, 2018
DEV VX-142: Node metrics handler

Former-commit-id: b9ce90d2974a0455d64b7c21a6aaf21287f5040f [formerly 95fc862]
Former-commit-id: a881820fb01395748899590dde8f60eb5c50a654
John-Lin added a commit that referenced this pull request Jul 25, 2018
DEV VX-142: Node metrics handler

Former-commit-id: b9ce90d2974a0455d64b7c21a6aaf21287f5040f [formerly b9ce90d2974a0455d64b7c21a6aaf21287f5040f [formerly 95fc862]]
Former-commit-id: a881820fb01395748899590dde8f60eb5c50a654
Former-commit-id: 0f2c1f3
John-Lin added a commit that referenced this pull request Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants