Table: consul_key - Query Consul Key-Value Store using SQL
Consul is a service networking solution to automate network configurations, discover services, and enable secure connectivity across any cloud or runtime. The key-value store feature in Consul is a flexible and dynamic configuration store that can be used for a wide variety of purposes, including storing configuration for service discovery and orchestration, leader election, distributed semaphore, and more. It is an integral part of Consul and is installed with the Consul agent.
Table Usage Guide
The consul_key
table provides insights into the keys and their corresponding values stored in the Consul Key-Value Store. As a DevOps engineer, explore key-specific details through this table, including the key name, its corresponding value, and associated metadata. Utilize it to uncover information about keys, such as their current values, flags, and the sessions they are associated with.
Examples
Basic info
Explore which sessions are associated with a specific key in your system. This can help you understand and manage the distribution and assignment of resources within your network.
select key, session, create_index, lock_index, namespace, partitionfrom consul_key;
select key, session, create_index, lock_index, namespace, partitionfrom consul_key;
List keys present in default namespace
Explore the keys present within the default namespace to understand their session contexts, creation indices, lock indices, and partitions. This can be beneficial in assessing the elements within the default namespace and understanding their configuration.
select key, session, create_index, lock_index, namespace, partitionfrom consul_keywhere namespace = 'default';
select key, session, create_index, lock_index, namespace, partitionfrom consul_keywhere namespace = 'default';
Show key value details
Explore which key-value pairs are being used in your Consul sessions. This can help you understand the configuration and data distribution within your system, allowing for more efficient management and troubleshooting.
select key, session, namespace, jsonb_pretty(value) as valuefrom consul_key;
select key, session, namespace, valuefrom consul_key;
Schema for consul_key
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form, e.g. connection_name. | |
create_index | bigint | = | CreateIndex holds the index corresponding the creation of this KVPair. This is a read-only field. |
flags | bigint | Flags are any user-defined flags on the key. It is up to the implementer to check these values, since Consul does not treat them specially. | |
key | text | = | Key is the name of the key. It is also part of the URL path when accessed via the API. |
lock_index | bigint | LockIndex holds the index corresponding to a lock on this key, if any. This is a read-only field. | |
modify_index | bigint | ModifyIndex is used for the Check-And-Set operations and can also be fed back into the WaitIndex of the QueryOptions in order to perform blocking queries. | |
namespace | text | = | Namespace is the namespace the KVPair is associated with. |
partition | text | Partition is the partition the KVPair is associated with. | |
session | text | Session is a string representing the ID of the session. Any other interactions with this key over the same session must specify the same session ID. | |
title | text | The title of the key. | |
value | jsonb | Value is the value for the key. This can be any value, but it will be base64 encoded upon transport. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- consul
You can pass the configuration to the command with the --config
argument:
steampipe_export_consul --config '<your_config>' consul_key