Cisco ACI Troubleshooting: Moquery & Query Filter Examples

Cisco ACI moquery examples


cisco aci moquery examples
The APIC NX-OS CLI is limited and so is the GUI. Sure you can build scripts with acicobra or use a REST API tool like Postman, but when your already on the CLI and need data, moquery is your friend.

Cisco ACI Troubleshooting on the CLI with moquery is perfect to use alone, with tools like grep, or roll into a bash one-liner. While troubleshooting with curl or icurl is also effective, each tool has their place.

Overview

Get Help

moquery -h
or
man moquery

Query all tenants

moquery -c fvTenant -o table

Query specific tenant

moquery -d uni/tn-TenantTest123
or
moquery -c fvTenant -f 'fv.Tenant.name=="TenantTest123"'
or
moquery -c fvTenant -x 'query-target-filter=eq(fvTenant.name,"TenantTest123")'

Query specific tenant and all children

moquery -d uni/tn-TenantTest123 -x 'rsp-subtree=children'

Query specific tenant and specific child

moquery -d uni/tn-TenantTest123 -x "rsp-subtree=children rsp-subtree-class=fvBD"

Query specific tenant and full subtree then filtered subtree

(less)
moquery -c fvTenant -f 'fv.Tenant.name=="TenantTest123"' -x 'query-target=subtree'

Query specific tenant and filter then full unfiltered subtree

(more)
moquery -c fvTenant -f 'fv.Tenant.name=="TenantTest123"' -x 'rsp-subtree=full'

Query tenants that contain wildcard match

moquery -c fvTenant -f 'fv.Tenant.name*"Test"'

Query EPGs with pctags between 10900 and 10905

moquery -c fvAEPg -f 'fv.AEPg.pcTag~"(10900,10905)"'

Query ports less than rate

moquery -c eqptIngrPkts5min -f 'eqpt.IngrPkts5min.unicastRate<"1000"' | egrep '^dn|^unicastRate'

Query linkes from node

moquery -c fabricLink -f 'fabric.Link.n1=="123"'

Query changes on date by user

moquery -c aaaModLR -f 'aaa.ModLR.created>"2018-01-01" and aaa.ModLR.user=="admin"'

Query changes between dates

moquery -c aaaModLR -f 'aaa.ModLR.created>"2015-05-07" and aaa.ModLR.created<"2015-05-10"'

Query AEP based on interface policy

moquery -c "infraAccPortGrp" | egrep "^dn" | awk '{print "moquery -d "$3" -x query-target=children \| egrep tDn"}'

Query policy-group

moquery -d "uni/infra/funcprof/accportgrp-POLGRPNAME" -x query-target=children

Query active faults

moquery -c faultInst | egrep -e "^descr" | sort | uniq -c

Query faults by description

moquery -c caultInst -f fault.Inst.descr==":Failed to form relation"

Common Filter Conditional Operators
REST API Operator Moquery Operator Description
eq == Equal to
ne != Not equal to
lt < Less than
gt > Greater than
le <= Less than or equal to
ge >= Greater than or equal to
bw ~ Between
not Logical inverse
and and Logical AND
or or Logical OR
wcard * Wildcard

Common Query Filters
Type Syntax Description
query-target {self | children | subtree} Define the scope of a query
target-subtree-class class name Respond-only elements including the specified class
query-target-filter filter expressions Respond-only elements matching conditions
rsp-subtree {no | children | full} Specifies child object level included in the response
rsp-subtree-class class name Respond only specified classes
rsp-subtree-filter filter expressions Respond only classes matching conditions
rsp-subtree-include {faults | health :stats :…} Request additional objects
order-by Not Implemented Sort the response based on the property values

See also:
Cisco ACI ELAM Packet Capture
Cisco ACI Automation with cURL
Cisco ACI Python Cobra Examples
Cisco ACI Troubleshooting with icURL