mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
fix docker health checker metrics missing from prometheus
This commit is contained in:
parent
84675b5c0f
commit
751594860a
3 changed files with 4 additions and 3 deletions
|
@ -97,7 +97,7 @@ func (r *HTTPRoute) Start(providerSubtask *task.Task) E.Error {
|
||||||
client, err := docker.ConnectClient(r.Idlewatcher.DockerHost)
|
client, err := docker.ConnectClient(r.Idlewatcher.DockerHost)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fallback := monitor.NewHTTPHealthChecker(r.rp.TargetURL, r.Raw.HealthCheck)
|
fallback := monitor.NewHTTPHealthChecker(r.rp.TargetURL, r.Raw.HealthCheck)
|
||||||
r.HealthMon = monitor.NewDockerHealthMonitor(client, r.Idlewatcher.ContainerID, r.Raw.HealthCheck, fallback)
|
r.HealthMon = monitor.NewDockerHealthMonitor(client, r.Idlewatcher.ContainerID, r.TargetName(), r.Raw.HealthCheck, fallback)
|
||||||
r.task.OnCancel("close docker client", client.Close)
|
r.task.OnCancel("close docker client", client.Close)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ func (r *StreamRoute) Start(providerSubtask *task.Task) E.Error {
|
||||||
client, err := docker.ConnectClient(r.Idlewatcher.DockerHost)
|
client, err := docker.ConnectClient(r.Idlewatcher.DockerHost)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fallback := monitor.NewRawHealthChecker(r.TargetURL(), r.Raw.HealthCheck)
|
fallback := monitor.NewRawHealthChecker(r.TargetURL(), r.Raw.HealthCheck)
|
||||||
r.HealthMon = monitor.NewDockerHealthMonitor(client, r.Idlewatcher.ContainerID, r.Raw.HealthCheck, fallback)
|
r.HealthMon = monitor.NewDockerHealthMonitor(client, r.Idlewatcher.ContainerID, r.TargetName(), r.Raw.HealthCheck, fallback)
|
||||||
r.task.OnCancel("close docker client", client.Close)
|
r.task.OnCancel("close docker client", client.Close)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,13 @@ type DockerHealthMonitor struct {
|
||||||
fallback health.HealthChecker
|
fallback health.HealthChecker
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDockerHealthMonitor(client *docker.SharedClient, containerID string, config *health.HealthCheckConfig, fallback health.HealthChecker) *DockerHealthMonitor {
|
func NewDockerHealthMonitor(client *docker.SharedClient, containerID, alias string, config *health.HealthCheckConfig, fallback health.HealthChecker) *DockerHealthMonitor {
|
||||||
mon := new(DockerHealthMonitor)
|
mon := new(DockerHealthMonitor)
|
||||||
mon.client = client
|
mon.client = client
|
||||||
mon.containerID = containerID
|
mon.containerID = containerID
|
||||||
mon.monitor = newMonitor(fallback.URL(), config, mon.CheckHealth)
|
mon.monitor = newMonitor(fallback.URL(), config, mon.CheckHealth)
|
||||||
mon.fallback = fallback
|
mon.fallback = fallback
|
||||||
|
mon.service = alias
|
||||||
return mon
|
return mon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue