Query Equinix Metal
Query Equinix Metal infrastructure with cnquery
Mondoo's equinix provider lets you use cnquery to query and inventory your Equinix Metal infrastructure. You can explore organizations, projects, devices, SSH keys, and more.
Requirements
To analyze your Equinix Metal environment with cnquery, you must have:
- cnquery installed on your workstation
- An Equinix Metal account
- An Equinix Metal API token
Configure access to Equinix Metal
To create an API token:
- Log in to the Equinix Metal console.
- Navigate to your user settings.
- Generate an API token.
Connect to Equinix Metal
To query resources within an organization:
cnquery shell equinix org ORG_ID --token YOUR_API_TOKENTo query resources within a specific project:
cnquery shell equinix project PROJECT_ID --token YOUR_API_TOKENYou can also set the PACKET_AUTH_TOKEN environment variable instead of passing the --token flag:
export PACKET_AUTH_TOKEN=your_token_here
cnquery shell equinix org ORG_IDExample queries
Organizations
Retrieve organization information:
cnquery> equinix.metal.organization
equinix.metal.organization: {
name: "My Organization"
...
}Projects
List all projects:
cnquery> equinix.metal.projects
equinix.metal.projects: [
0: equinix.metal.project name="Production"
1: equinix.metal.project name="Development"
...
]Retrieve project details:
cnquery> equinix.metal.projects { name id createdAt updatedAt }
equinix.metal.projects: [
0: {
name: "Production"
id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
createdAt: 2024-01-15 10:30:00 +0000 UTC
updatedAt: 2025-03-20 14:00:00 +0000 UTC
}
1: {
name: "Development"
id: "b2c3d4e5-f6a7-8901-bcde-f12345678901"
createdAt: 2024-06-01 09:00:00 +0000 UTC
updatedAt: 2025-04-10 11:30:00 +0000 UTC
}
]List devices within a project:
cnquery> equinix.metal.projects[0].devices { hostname state }
equinix.metal.projects[0].devices: [
0: {
hostname: "server-1"
state: "active"
}
1: {
hostname: "server-2"
state: "active"
}
]Devices
List all devices:
cnquery> equinix.metal.devices
equinix.metal.devices: [
0: equinix.metal.device hostname="server-1"
...
]Retrieve details about devices:
cnquery> equinix.metal.devices { hostname state billingCycle os }
equinix.metal.devices: [
0: {
hostname: "server-1"
state: "active"
billingCycle: "hourly"
os: "ubuntu_22_04"
}
...
]Check whether any devices are spot instances:
cnquery> equinix.metal.devices { hostname spotInstance locked }
equinix.metal.devices: [
0: {
hostname: "server-1"
spotInstance: 0
locked: 0
}
...
]SSH keys
List SSH keys:
cnquery> equinix.metal.sshKeys
equinix.metal.sshKeys: [
0: equinix.metal.sshKey label="my-key"
...
]Users
List users in the organization:
cnquery> equinix.metal.users
equinix.metal.users: [
0: equinix.metal.user name="Alice Smith"
1: equinix.metal.user name="Bob Jones"
...
]Learn more
-
To learn more about how the MQL query language works, read Write Effective MQL.
-
For a list of all the Equinix resources and fields you can query, read the Equinix Resource Pack Reference.