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_timefrom nomad_job;
select id, name, namespace, status, type, region, modify_index, submit_timefrom 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, regionfrom nomad_jobwhere not stable;
select id, name, namespace, status, type, regionfrom nomad_jobwhere 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, multiregionfrom nomad_jobwhere multiregion is not null;
select id, name, namespace, status, region, multiregionfrom nomad_jobwhere 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, multiregionfrom nomad_jobwhere status = 'pending';
select id, name, namespace, status, region, multiregionfrom nomad_jobwhere 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_revertfrom nomad_jobwhereupdate ->> 'AutoRevert' = 'true';
select id, name, namespace, status, json_extract( update, '$.AutoRevert' ) as auto_revertfrom nomad_jobwhere 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_timeoutfrom 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_timeoutfrom nomad_job, json_each(nomad_job.task_groups) as tg, json_each(json_extract(tg.value, '$.Tasks')) as t;
Schema for nomad_job
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form, e.g. connection_name. | |
affinities | jsonb | The list of affinities for the job. | |
all_at_once | boolean | Whether all tasks should be run in parallel or not. | |
constraints | jsonb | The list of constraints for the job. | |
consul_namespace | text | The Consul namespace used by the job. | |
consul_token | text | Consul token used by the job. | |
create_index | bigint | = | Create index of the job. |
datacenters | jsonb | The list of datacenters where the job can be run. | |
dispatch_idempotency_token | text | The dispatch idempotency token used by the job. | |
dispatched | boolean | Indicates whether the job has been dispatched. | |
id | text | = | Generated UUID for the job. |
job_modify_index | bigint | Job modify index of the job. | |
meta | jsonb | Metadata associated with the job. | |
migrate | jsonb | The migration strategy for the job. | |
modify_index | bigint | Modify index of the job. | |
multiregion | jsonb | The multi-region settings for the job. | |
name | text | = | The name of the job. |
namespace | text | = | The namespace associated with the job. |
parameterized_job | jsonb | The parameterized job configuration for the job. | |
parent_id | text | The parent ID of the job. | |
payload | jsonb | The payload of the job. | |
periodic | jsonb | The periodic configuration for the job. | |
priority | bigint | The priority of the job. | |
region | text | The region where the Nomad job is running. | |
reschedule | jsonb | The rescheduling policy for the job. | |
spreads | jsonb | The list of spread configurations for the job. | |
stable | boolean | Indicates whether the job is stable. | |
status | text | The status of the job. | |
status_description | text | The description of the status of the job. | |
stop | boolean | Indicates whether the job should be stopped. | |
submit_time | timestamp with time zone | The time when the job was submitted. | |
task_groups | jsonb | The list of task groups for the job. | |
title | text | The title of the job. | |
type | text | The type of job. | |
update | jsonb | The update strategy for the job. | |
vault_namespace | text | The vault namespace used by the job. | |
vault_token | text | Vault token used by the job. | |
version | bigint | The 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