Entity Selectors โ Smartscape DQL
Hands-on2 exercises
Entity Selectors โ Smartscape DQL
Gen2 entity selectors were a mini-language for finding entities. Gen3 replaces them with DQL queries against Smartscape.
Migration Examples
GEN2 Entity Selector GEN3 DQL
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
type(HOST) smartscapeNodes "HOST"
type(HOST),tag("env:prod") smartscapeNodes "HOST"
| filter matchesValue(dt.tags, "env:prod")
type(SERVICE),entityName("login") smartscapeNodes "SERVICE"
| filter name == "login"
type(HOST), smartscapeNodes "HOST"
fromRelationships.isInstanceOf( | traverse "runs_on", "SERVICE",
type(SERVICE),entityName("web")) direction: backward
| filter name == "web"
๐ Try it
Convert this Gen2 entity selector to Gen3 DQL: type(HOST),tag("env:production")
extension.yamlYAML
Loading...
Common Entity Queries
// List all hosts with OS and cloud provider
smartscapeNodes "HOST"
| fieldsAdd os.type, cloud.provider, host.logical.cpu.cores
| fields name, os.type, cloud.provider, host.logical.cpu.cores
// Find services on a specific host
smartscapeNodes "HOST"
| filter name == "my-host"
| traverse "runs_on", "SERVICE", direction: backward
| fields name, id
// List K8s pods in a namespace
smartscapeNodes "K8S_POD"
| filter k8s.namespace.name == "production"
| fields k8s.cluster.name, k8s.pod.name, k8s.workload.name
// Find AWS EC2 instances
smartscapeNodes "AWS_EC2_INSTANCE"
| fieldsAdd aws.region, aws.account.id
| fields name, aws.region, aws.account.id
Relationship Traversal Cheat Sheet
From โ To Traverse Command
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
HOST โ services running on it traverse "runs_on", "SERVICE", direction: backward
SERVICE โ host it runs on traverse "runs_on", "HOST"
HOST โ processes traverse "runs_on", "PROCESS", direction: backward
K8S_POD โ containers traverse "is_part_of", "CONTAINER", direction: backward
LB โ target groups traverse "balanced_by", direction: backward
EC2 โ security groups traverse "uses", "AWS_EC2_SECURITYGROUP"
RDS โ KMS key traverse "uses", "AWS_KMS_KEY"