Type safety
This commit is contained in:
parent
762ef62098
commit
1999536b50
|
@ -12,7 +12,9 @@ from http.server import HTTPServer
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import docker # type: ignore[import]
|
import docker # type: ignore[import]
|
||||||
|
import docker.errors # type: ignore[import]
|
||||||
import numpy
|
import numpy
|
||||||
|
from docker.models.containers import Container # type: ignore[import]
|
||||||
from prometheus_client import CollectorRegistry # type: ignore[import]
|
from prometheus_client import CollectorRegistry # type: ignore[import]
|
||||||
from prometheus_client import Gauge, MetricsHandler, generate_latest
|
from prometheus_client import Gauge, MetricsHandler, generate_latest
|
||||||
|
|
||||||
|
@ -108,7 +110,8 @@ class HTTPHandler(MetricsHandler): # type: ignore[misc]
|
||||||
registry=registry,
|
registry=registry,
|
||||||
)
|
)
|
||||||
|
|
||||||
for container in self.docker_client.containers.list(all=True):
|
container: Container
|
||||||
|
for container in self.docker_client.containers.list(all=True): # type: ignore
|
||||||
try:
|
try:
|
||||||
data = self.docker_api.inspect_container(container.id)
|
data = self.docker_api.inspect_container(container.id)
|
||||||
except docker.errors.NotFound:
|
except docker.errors.NotFound:
|
||||||
|
@ -121,7 +124,7 @@ class HTTPHandler(MetricsHandler): # type: ignore[misc]
|
||||||
alert_threshold = int(
|
alert_threshold = int(
|
||||||
data["Config"]["Labels"].get("io.prometheus.alert.downtime", 3600)
|
data["Config"]["Labels"].get("io.prometheus.alert.downtime", 3600)
|
||||||
)
|
)
|
||||||
starttime: numpy.longlong = numpy.datetime64(started_at, "s").astype("long")
|
starttime = numpy.datetime64(started_at, "s").astype("long")
|
||||||
|
|
||||||
status_gauge.labels(
|
status_gauge.labels(
|
||||||
container.id,
|
container.id,
|
||||||
|
|
Loading…
Reference in a new issue