Sign inSign up

clarenceb/consul_exporter

By clarenceb

Updated almost 11 years ago

Exporter for Consul metrics wit service entry counts (total and healthy)

Image
0

1.0K

clarenceb/consul_exporter repository overview

Consul Exporter

Export Consul service health to Prometheus.

To run it:

make
./consul_exporter [flags]

Exported Metrics

MetricMeaningLabels
consul_upWas the last query of Consul successful
consul_raft_peersHow many peers (servers) are in the Raft cluster
consul_serf_lan_membersHow many members are in the cluster
consul_catalog_servicesHow many services are in the cluster
consul_catalog_service_node_healthyIs this service healthy on this nodeservice, node
consul_health_node_statusStatus of health checks associated with a nodecheck, node
consul_health_service_statusStatus of health checks associated with a servicecheck, node, service
consul_catalog_kvThe values for selected keys in Consul's key/value catalog. Keys with non-numeric values are omittedkey
Flags
./consul_exporter --help
  • consul.server: Address (host and port) of the Consul instance we should connect to. This could be a local agent (localhost:8500, for instance), or the address of a Consul server.
  • consul.health-summary: Collects information about each registered service and exports consul_catalog_service_node_healthy. This requires n+1 Consul API queries to gather all information about each service. Health check information are available via consul_health_service_status as well, but only for services which have a health check configured. Defaults to true.
  • web.listen-address: Address to listen on for web interface and telemetry.
  • web.telemetry-path: Path under which to expose metrics.
  • log.level: Logging level. info by default.
Key/Value Checks

This exporter supports grabbing key/value pairs from Consul's KV store and exposing them to Prometheus. This can be useful, for instance, if you use Consul KV to store your intended cluster size, and want to graph that value against the actual value found via monitoring.

  • kv.prefix: Prefix under which to look for KV pairs.
  • kv.filter: Only store keys that match this regex pattern.

A prefix must be supplied to activate this feature. Pass / if you want to search the entire keyspace.

Useful Queries

Are my services healthy?

min(consul_catalog_service_node_healthy) by (service)

Values of 1 mean that all nodes for the service are passing. Values of 0 mean at least one node for the service is not passing.

What service nodes are failing?

sum by (node, service)(consul_catalog_service_node_healthy == 0)

Using Docker

You can deploy this exporter using the prom/consul-exporter Docker image.

For example:

docker pull prom/consul-exporter

docker run -d -p 9107:9107 prom/consul-exporter -consul.server=172.17.42.1:8500

Keep in mind that your container needs to be able to communicate with the Consul server or agent. Use an IP accessible from the container or set the --dns and --dns-search options of the docker run command:

docker run -d -p 9107:9107 --dns=172.17.42.1 --dns-search=service.consul \
        prom/consul-exporter -consul.server=consul:8500

Tag summary

Content type

Image

Digest

sha256:3bd2c168d

Size

8.8 MB

Last updated

about 11 years ago

docker pull clarenceb/consul_exporter