-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add prometheus metrics * add docs * metrics snippet * bump version * fix typo * remove redundant flag * add doc string, add to defaults test * add prometheus unit tests * update docs * add ability to bind to different interface * fix flake8 * fix readme * 0.3.0 * fix readme * fix readme
- Loading branch information
Showing
15 changed files
with
180 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ dependencies: | |
- pip: | ||
- docker | ||
- schedule | ||
- prometheus_client | ||
- pytest | ||
- pytest-cov | ||
- pytest-mock | ||
|
This file contains 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ dependencies: | |
- pip: | ||
- docker | ||
- schedule | ||
- prometheus_client |
This file contains 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 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 |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
RUNONCE = False | ||
CLEANUP = False | ||
KEEPTAG = False | ||
METRICS_ADDR = '127.0.0.1' | ||
METRICS_PORT = 8000 |
This file contains 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 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,17 @@ | ||
from prometheus_client import Counter, Gauge | ||
|
||
updated_containers_counter = Counter( | ||
'containers_updated', 'Count of containers updated', ['container']) | ||
|
||
monitored_containers_gauge = Gauge( | ||
'containers_being_monitored', 'Count of containers being monitored', []) | ||
|
||
|
||
def container_updates(label): | ||
"""Increment container update count based on label""" | ||
updated_containers_counter.labels(container=label).inc() | ||
|
||
|
||
def monitored_containers(num): | ||
"""Set number of containers being monitoring with a gauge""" | ||
monitored_containers_gauge.set(num) |
This file contains 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 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
docker | ||
schedule | ||
prometheus_client | ||
pytest | ||
pytest-cov | ||
pytest-mock | ||
|
This file contains 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
docker | ||
schedule | ||
schedule | ||
prometheus_client |
This file contains 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 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,17 @@ | ||
import pytest | ||
from prometheus_client import REGISTRY | ||
import ouroboros.metrics as metrics | ||
|
||
|
||
def test_container_updates(): | ||
test_label = 'test' | ||
metrics.container_updates(label=test_label) | ||
increment = REGISTRY.get_sample_value('containers_updated_total', labels={'container': test_label}) | ||
assert increment == 1.0 | ||
|
||
|
||
def test_monitored_containers(): | ||
test_count = 5.0 | ||
metrics.monitored_containers(num=test_count) | ||
num_monitored = REGISTRY.get_sample_value('containers_being_monitored') | ||
assert num_monitored == test_count |
This file contains 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 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 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