-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Create prometheus client #11
Conversation
A sample output of the load watcher looks like the following: > curl -H "Content-Type: application/json" http://127.0.0.1:2020/watcher|jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1900 100 1900 0 0 1855k 0 --:--:-- --:--:-- --:--:-- 1855k
{
"timestamp": 1612427148,
"window": {
"duration": "15m",
"start": 1612426248,
"end": 1612427148
},
"source": "Prometheus",
"data": {
"NodeMetricsMap": {
"10.95.102.97": {
"metrics": [
{
"name": "instance:node_cpu:ratio",
"type": "CPU",
"operator": "avg_over_time",
"rollup": "15m",
"value": 0.19731935228375208
},
{
"name": "instance:node_memory_utilisation:ratio",
"type": "Memory",
"operator": "avg_over_time",
"rollup": "15m",
"value": 0.08354249717493203
},
{
"name": "instance:node_cpu:ratio",
"type": "CPU",
"operator": "stddev_over_time",
"rollup": "15m",
"value": 0.00048452241606516646
},
{
"name": "instance:node_memory_utilisation:ratio",
"type": "Memory",
"operator": "stddev_over_time",
"rollup": "15m",
"value": 0.00013245370097128003
}
],
"tags": {},
"metadata": {
"dataCenter": ""
}
},
"10.95.102.99": {
"metrics": [
{
"name": "instance:node_cpu:ratio",
"type": "CPU",
"operator": "avg_over_time",
"rollup": "15m",
"value": 0.2048283625730656
},
{
"name": "instance:node_memory_utilisation:ratio",
"type": "Memory",
"operator": "avg_over_time",
"rollup": "15m",
"value": 0.09212922586804047
},
{
"name": "instance:node_cpu:ratio",
"type": "CPU",
"operator": "stddev_over_time",
"rollup": "15m",
"value": 0.0005520914622929221
},
{
"name": "instance:node_memory_utilisation:ratio",
"type": "Memory",
"operator": "stddev_over_time",
"rollup": "15m",
"value": 0.0001700369598327637
}
],
"tags": {},
"metadata": {
"dataCenter": ""
}
},
"10.95.102.90": {
"metrics": [
{
"name": "instance:node_cpu:ratio",
"type": "CPU",
"operator": "avg_over_time",
"rollup": "15m",
"value": 0.05814883040935881
},
{
"name": "instance:node_memory_utilisation:ratio",
"type": "Memory",
"operator": "avg_over_time",
"rollup": "15m",
"value": 0.10718011619404219
},
{
"name": "instance:node_cpu:ratio",
"type": "CPU",
"operator": "stddev_over_time",
"rollup": "15m",
"value": 0.00025611915450171206
},
{
"name": "instance:node_memory_utilisation:ratio",
"type": "Memory",
"operator": "stddev_over_time",
"rollup": "15m",
"value": 3.1065560195209836e-05
}
],
"tags": {},
"metadata": {
"dataCenter": ""
}
}
}
}
} |
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.
Please review the comments. Also, my name in the commit message is redundant 😄 - Something like "Add Prometheus client" is fine :)
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.
Thanks for making the changes @wangchen615. LGTM.
This PR is to solve #10 and close #10 .
There are the following major changes:
prometheus.go
was added underpkg/metricsprovider
withFetchAllHostsMetrics
method implemented.pkg/watcher/watcher.go
was revised to support different types of clients to fill in the datasource field.FetchHostMetrics
was commented as Prometheus client does not need to fetch host metric one by one.README.md
is updated to include a guide on configuring environment variables.