infinityworks / prometheus-rancher-exporter

Exposes Rancher metrics to Prometheus
MIT License
99 stars 47 forks source link

Add support for Host agent state. #18

Closed johnrengelman closed 7 years ago

johnrengelman commented 7 years ago

The agent state is what is set when a host connects/disconnects from the Rancher server.

Currently if a host is in the "reconnecting" state per the Rancher UI, this is not exposed via the metrics.

Rucknar commented 7 years ago

Interesting, thanks for the PR. Could you explain a little more?

Is the host 'State' field not covering a host in a reconnecting state? I ask because it's one of the possible states exposed by the API. Not sure how the Rancher API knows what state the agent is in, if it's not connected, apologies if i'm being slow here.

Also, is this for V1 or V2 of the API? I'm 70% sure i tested this with v2-beta, could be wrong though.

johnrengelman commented 7 years ago

This is v1. When a Host is "reconnecting" if you look at the API, the host.state field is active but host.agentState is reconnecting. You can test this by stopping the rancher-agent container on the host machine.

johnrengelman commented 7 years ago

Also, I don't believe reconnecting is a valid state for host.state here are the common state - https://github.com/rancher/cattle/blob/master/code/iaas/model/src/main/java/io/cattle/platform/core/constants/CommonStatesConstants.java

and host specific - https://github.com/rancher/cattle/blob/master/code/iaas/model/src/main/java/io/cattle/platform/core/constants/HostConstants.java#L31

johnrengelman commented 7 years ago

You also don't have reconnecting as a state for hostState - https://github.com/infinityworksltd/prometheus-rancher-exporter/blob/master/rancher_exporter.go#L33

Rucknar commented 7 years ago

Can't argue with the code! Okay, let me test this, should get time tomorrow and merge if all looks good.

Rucknar commented 7 years ago

LGTM, merging.

Rucknar commented 7 years ago

v0.22.52 just built fine on the Hub and is available for use, updated release notes. Thanks @johnrengelman