consulconsul-kv

hashicorp consul is not publishing all the metrics


consul isn't publishing all the metrics defined in their document, from https://www.consul.io/docs/agent/telemetry.html#transaction-timing, it shows only raft metrics but not txn kvs, has anyone observed this problem?

Command to enable prometheus style metrics:

consul agent -dev -hcl 'telemetry{prometheus_retention_time="24h" disable_hostname=true}'

watch metrics:

watch -n 1 -d "curl -s localhost:8500/v1/agent/metrics?format=prometheus|grep -v ^# | grep -E 'kvs|txn|raft'"

Solution

  • Metrics will be exported only if they are available, i.e. if there are no transactions or KV store operations, then you will not see these metrics in the output.

    I have managed to see kvs metrics in the example you have provided. While running Consul agent via command in the question, in browser open http://127.0.0.1:8500/ and click on Key/Value option in the top list (you should end up here http://127.0.0.1:8500/ui/dc1/kv). Click on Create to add new Key/Value pair. After clicking Save you should see something like this in the terminal running watch command:

    consul_fsm_kvs{op="set",quantile="0.5"} 0.3572689890861511
    consul_fsm_kvs{op="set",quantile="0.9"} 0.3572689890861511
    consul_fsm_kvs{op="set",quantile="0.99"} 0.3572689890861511
    consul_fsm_kvs_sum{op="set"} 0.3572689890861511
    consul_fsm_kvs_count{op="set"} 1
    consul_kvs_apply{quantile="0.5"} 2.6777150630950928
    consul_kvs_apply{quantile="0.9"} 2.6777150630950928
    consul_kvs_apply{quantile="0.99"} 2.6777150630950928
    consul_kvs_apply_sum 2.6777150630950928
    consul_kvs_apply_count 1
    

    If there are no more transactions some of these values will be set to NaN value, depends on Prometheus metrics type.

    Similarly, to see txn, you need to create Consul Transaction

    Hope that helps you set up monitoring.