HCM

Happy Coding Monkey

jq Usage

2023-07-02


csv output format

aws rds --profile=prod describe-db-instances > desc_rds_instance.json
cat desc_db_instance.json |jq -r '.DBInstances[]' | jq -r '[.DBInstanceIdentifier, .Engine, .DBInstanceClass, .MultiAZ,  .StorageType, .AllocatedStorage,  .EngineVersion,  .BackupRetentionPeriod, .ReadReplicaSourceDBInstanceIdentifier,  .DBClusterIdentifier, .InstanceCreateTime]|@csv'

aws rds --profile=prod describe-db-clusters > db_clusters.json
cat db_clusters.json | jq -r  '.DBClusters[] | select( .Engine == "aurora-mysql" ) | [.Engine, .Endpoint, .ReaderEndpoint] | @csv'


aws --profile=prod elasticache describe-cache-clusters > desc_redis.json
cat desc_redis.json | jq '.CacheClusters[]' | jq -r '[.CacheClusterId, .Engine, .EngineVersion, .NumCacheNodes, .PreferredAvailabilityZone, .ReplicationGroupId, .CacheNodeType]|@csv'

trim field

jq ".DtsJobList[] | del(.DbObject, .Reserved, .PrecheckStatus)" ali_dts_jobs.json