Skip to content
Snippets Groups Projects
Verified Commit 7204690d authored by Varac's avatar Varac
Browse files

Test if prometheus can reach all targets

Closes #217
parent 2d1eb5a1
No related branches found
No related tags found
No related merge requests found
......@@ -3,3 +3,4 @@
markers =
certs: Run tests related to TLS certificates
testinfra: Run testinfra tests (test OS/package versions etc)
prometheus: Test prometheus
import json
import pytest
import requests
@pytest.mark.prometheus
def test_prometheus_alerts(host):
print("Starting prometheus test...")
#cmd = host.run("hostname")
#print("Hostname: " + cmd.stdout)
url = 'http://127.0.0.1:30090/api/v1/alerts'
alert_json = json.loads(host.check_output('curl ' + url))
print(type(alert_json))
status = alert_json["status"]
alerts = alert_json["data"]["alerts"]
# Filter out the ever firing "Dead mans switch"
real_alerts = [alert for alert in alerts
if alert["labels"]["severity"] != "none"]
count = len(real_alerts)
print(json.dumps(real_alerts))
assert status == "success", "Failure queriying the prometheus api at" + url
assert count == 0, "There are prometheus alerts firing !"
if __name__ == "__main__":
test_prometheus_alerts('')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment