Consul Querying Nodes - Consul

What is Consul Querying Nodes?

In this section, we will study how to query nodes with the resulting functions −

  • Using dig
  • Using the Monitor command
  • Using the Watch command
  • By Registering External Services

Let us appreciate each of these functions in detail.

Using Dig

Consul takes note on for DNS queries in the consul. The way it controls which nodes are obtainable to deliver a service is using checks that can be either −

  • A Script that is executed and it returns a nagios compliant code.
  • An HTTP check that returns an HTTP response code.
  • A TCP check that is checking if a port is open.

The overall command for trying out dig is −

Currently, let us try out a example dig command –

The output would be as shown in the resulting screenshot.


Using the Monitor Command

It is used to link and show the logs of a running Consul agent. This command will display the recent logs. It also lets you to log the agent at a comparatively high log level. It contains of many log levels, which you can track, such as – Trace, Debug, Info, Warn and Err.
Let us try out the resulting command −

The output would be as shown in the resulting screenshot.


You can also set the monitor command by means of the sub-commands such as -log-level and -rpc-address. By default, the address of the RPC is For more info, click here.

Using the Watch Command

This command offers us with a mechanism to watch for deviations in the list of nodes, service members, key value, etc. It also appeals a procedure with the newest values of the view. If no procedure is specified, the current values are treated to STDOUT, which can be a beneficial way to inspect data in Consul. The Consul Watch Command help has a selection of different choices as shown in the resulting screenshot –


Let us try out a demo with -type = service as shown in the following command.


For more data on this topic, you can click here.

By Registering External Services

Once recorded, the DNS interface will be able to return the suitable ‘A Records’ or CNAME Records for the service. Let us register an exterior service, such as Amazon as shown in the resulting code block and the screenshot as well.


The above command states a service named as shop. This Node is called as amazon with its URL obtainable at on Port 80. Let us check the output on consul to make sure we have properly installed this service. For this, please open the browser window at localhost:8500.


To remove the service, we can simply use the following command.


Let us check the UI for it as shown in the resulting screenshot.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Consul Topics