steampipe plugin install nomad

Table: nomad_job - Query Nomad Jobs using SQL

Nomad is a simple and flexible workload orchestrator to deploy and manage containers and non-containerized applications across on-prem and clouds at scale. Nomad Jobs are the primary configuration that users interact with when using Nomad. These jobs are specified in files which are then passed to Nomad to schedule onto the cluster.

Table Usage Guide

The nomad_job table provides insights into the jobs scheduled within HashiCorp Nomad. As a DevOps engineer, explore job-specific details through this table, including job configurations, statuses, and other metadata. Utilize it to manage and monitor your workloads, understand job dependencies, and optimize resource allocation.

Examples

Basic info

Explore which jobs are currently active by determining their status and type. This can help in understanding the workload distribution across different regions, and track any changes over time.

select
id,
name,
namespace,
status,
type,
region,
modify_index,
submit_time
from
nomad_job;
select
id,
name,
namespace,
status,
type,
region,
modify_index,
submit_time
from
nomad_job;

List unstable jobs

Discover the segments that contain unstable jobs across various regions and namespaces, helping you identify areas that may require troubleshooting or further investigation.

select
id,
name,
namespace,
status,
type,
region
from
nomad_job
where
not stable;
select
id,
name,
namespace,
status,
type,
region
from
nomad_job
where
stable = 0;

List multi-region jobs

Discover the segments that have jobs spanning multiple regions, enabling you to manage and monitor tasks across different geographical areas more effectively.

select
id,
name,
namespace,
status,
region,
multiregion
from
nomad_job
where
multiregion is not null;
select
id,
name,
namespace,
status,
region,
multiregion
from
nomad_job
where
multiregion is not null;

List pending jobs

Discover the segments that consist of jobs awaiting execution, enabling you to manage and prioritize your workflow more effectively. This can be particularly useful in scenarios where resource allocation and task scheduling are critical.

select
id,
name,
namespace,
status,
region,
multiregion
from
nomad_job
where
status = 'pending';
select
id,
name,
namespace,
status,
region,
multiregion
from
nomad_job
where
status = 'pending';

List jobs with autorevert enabled

Explore which jobs have the 'autorevert' feature enabled. This can be particularly useful for understanding and managing job configurations in a Nomad cluster.

select
id,
name,
namespace,
status,
update
->> 'AutoRevert' as auto_revert
from
nomad_job
where
update
->> 'AutoRevert' = 'true';
select
id,
name,
namespace,
status,
json_extract(
update
,
'$.AutoRevert'
) as auto_revert
from
nomad_job
where
json_extract(
update
,
'$.AutoRevert'
) = 'true';

Show the CSI plugin configuration of the jobs

Analyze the configuration of job-specific CSI plugins to understand their types and health timeout settings. This can help in monitoring and managing the performance and health of these plugins.

select
id as job_id,
name as job_name,
t -> 'CSIPluginConfig' ->> 'ID' as csi_plugin_id,
t -> 'CSIPluginConfig' ->> 'Type' as csi_plugin_type,
t -> 'CSIPluginConfig' ->> 'HealthTimeout' as csi_plugin_timeout
from
nomad_job,
jsonb_array_elements(task_groups) as tg,
jsonb_array_elements(tg -> 'Tasks') as t;
select
nomad_job.id as job_id,
nomad_job.name as job_name,
json_extract(t.value, '$.CSIPluginConfig.ID') as csi_plugin_id,
json_extract(t.value, '$.CSIPluginConfig.Type') as csi_plugin_type,
json_extract(t.value, '$.CSIPluginConfig.HealthTimeout') as csi_plugin_timeout
from
nomad_job,
json_each(nomad_job.task_groups) as tg,
json_each(json_extract(tg.value, '$.Tasks')) as t;

Schema for nomad_job

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
affinitiesjsonbThe list of affinities for the job.
all_at_oncebooleanWhether all tasks should be run in parallel or not.
constraintsjsonbThe list of constraints for the job.
consul_namespacetextThe Consul namespace used by the job.
consul_tokentextConsul token used by the job.
create_indexbigint=Create index of the job.
datacentersjsonbThe list of datacenters where the job can be run.
dispatch_idempotency_tokentextThe dispatch idempotency token used by the job.
dispatchedbooleanIndicates whether the job has been dispatched.
idtext=Generated UUID for the job.
job_modify_indexbigintJob modify index of the job.
metajsonbMetadata associated with the job.
migratejsonbThe migration strategy for the job.
modify_indexbigintModify index of the job.
multiregionjsonbThe multi-region settings for the job.
nametext=The name of the job.
namespacetext=The namespace associated with the job.
parameterized_jobjsonbThe parameterized job configuration for the job.
parent_idtextThe parent ID of the job.
payloadjsonbThe payload of the job.
periodicjsonbThe periodic configuration for the job.
prioritybigintThe priority of the job.
regiontextThe region where the Nomad job is running.
reschedulejsonbThe rescheduling policy for the job.
spreadsjsonbThe list of spread configurations for the job.
stablebooleanIndicates whether the job is stable.
statustextThe status of the job.
status_descriptiontextThe description of the status of the job.
stopbooleanIndicates whether the job should be stopped.
submit_timetimestamp with time zoneThe time when the job was submitted.
task_groupsjsonbThe list of task groups for the job.
titletextThe title of the job.
typetextThe type of job.
updatejsonbThe update strategy for the job.
vault_namespacetextThe vault namespace used by the job.
vault_tokentextVault token used by the job.
versionbigintThe version of the job.

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)" -- nomad

You can pass the configuration to the command with the --config argument:

steampipe_export_nomad --config '<your_config>' nomad_job