-
Notifications
You must be signed in to change notification settings - Fork 260
Prometheus metrics #590
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
Merged
huntergregory
merged 56 commits into
Azure:master
from
huntergregory:prometheus-metrics
Jul 14, 2020
Merged
Prometheus metrics #590
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
ae95acc
prometheus additions to testmain (commented out right now)
7505699
home of the npm prometheus metrics and tools for updating them, testi…
e57526e
add/remove policy metrics
c9e3529
add/remove iptables rule metric measurements
aa8fc12
add/remove ipset metric measurements
44e500b
testing for gauges. want to soon remove the boolean for including pro…
ccd3762
run http server that exposes prometheus from main
8ed5dd8
cleaner test additions with less code
ef5f168
removed incorrect instance of AddSet in the TestDeleteSet test
8decd79
added prometheus annotations to pod templates
73ee92c
merged prometheus changes with pull from master
1d9e319
deleted unused file
19c3e93
much more organized initialization of metrics now. now includes map f…
75d5772
add ability to get summary count value. now getting gauge values and …
3a081b1
condenses prometheus testing code base by condensing all prometheus e…
d41fe10
added testing for summary counts, condensed prometheus error handling…
9fb3bfb
update based on variable spelling change in metrics package
67675df
Added comments for functions and moved http handler code to the http …
605567a
fixed problem of registering same metric name for different metrics, …
b0d1f94
made prometheus testing folder with interactive testing file. moved o…
680cc88
moved testing around again
c2cbc61
fixed spelling mistake
59c56a7
counting mistake in unit test
00a1950
handler variable ws in wrong file. Changed stdout printing to logging
6bb6bb0
fixed parameter errors and counting error in a test
142c8f5
moved utilities for testing prometheus metrics to npm/util. Updated S…
94a7930
updated uses of StartHTTP to have the extra parameter
7edc4cd
updated GetValue and GetCountValue uses to use the prometheus feature…
8f0ece1
removed unnecessary comments, removed print statement, and added quan…
36b574e
fixed problem of double registering metrics
185efca
wait longer for http server to start
85949ba
moved tool in test-util.go to promutil/util.go
9c074df
fixed timer to be in milliseconds and updated metric descriptions to …
f3bf2b6
removed unnecessary comments
0fbf146
http server always started in a go routine now. Added comment justify…
f17d70e
debugging http connection refused in pipeline
7c337fe
fixed syntax error
46be509
removed debugging wrapper around http service
0a51a18
sleep so that the testing metrics endpoint can be pinged
e032f9b
redesigned GetValue and GetCountValue so that they don't use http calls
f7c17ba
removed random but helpful testing file - will write about quick test…
4797697
milliseconds were being truncated. now they have decimals
a4623bd
merged in shufang's pr'
7a5eb6e
use direct Prometheus metric commands instead of wrapping them
2f456fe
removed code used when testing was done through http server. Moved re…
29f3e90
added createGaugeVec, updated comments, made all help strings constants
56963ad
added metric that counts number of entries in each ipset. still need …
df2be75
fixed creation of GaugeVecs, and use explicit labeling instead of ord…
9b3a26d
updated GetVecValue method signature
1dea15f
added set to metrics on creation and wrote unit tests for CreateSet, …
b402178
use custom registry to limit content that Container Insights scrapes.…
6e28082
wrote TODO item comments for Restore and Destroy (currently these fun…
1f614ab
NPM won't crash if a Prometheus metric fails to register now (unlikel…
e04ede1
initialize metrics in unit tests
122a838
Merge branch 'master' of https://github.com/Azure/azure-container-net…
43e1161
renamed util.go to test-util.go
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package metrics | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "time" | ||
|
|
||
| "github.com/Azure/azure-container-networking/log" | ||
| "github.com/prometheus/client_golang/prometheus/promhttp" | ||
| ) | ||
|
|
||
| const ( | ||
| // HTTPPort is the port used by the HTTP server (includes a preceding colon) | ||
| HTTPPort = ":8000" | ||
|
|
||
| //MetricsPath is the path for the Prometheus metrics endpoint (includes preceding slash) | ||
| MetricsPath = "/metrics" | ||
| ) | ||
|
|
||
| var started = false | ||
| var handler http.Handler | ||
huntergregory marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // StartHTTP starts a HTTP server in a Go routine with endpoint on port 8000. Metrics are exposed on the endpoint /metrics. | ||
| // By being exposed, the metrics can be scraped by a Prometheus Server or Container Insights. | ||
| // The function will pause for delayAmountAfterStart seconds after starting the HTTP server for the first time. | ||
huntergregory marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| func StartHTTP(delayAmountAfterStart int) { | ||
| if started { | ||
| return | ||
| } | ||
| started = true | ||
|
|
||
| http.Handle(MetricsPath, getHandler()) | ||
| log.Logf("Starting Prometheus HTTP Server") | ||
| go http.ListenAndServe(HTTPPort, nil) | ||
| time.Sleep(time.Second * time.Duration(delayAmountAfterStart)) | ||
| } | ||
|
|
||
| // getHandler returns the HTTP handler for the metrics endpoint | ||
| func getHandler() http.Handler { | ||
| if handler == nil { | ||
| handler = promhttp.HandlerFor(registry, promhttp.HandlerOpts{}) | ||
| } | ||
| return handler | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.