diff --git a/Cargo.lock b/Cargo.lock index 1b97949..e0c8eb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -691,6 +691,27 @@ dependencies = [ "typenum", ] +[[package]] +name = "csv" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde_core", +] + +[[package]] +name = "csv-core" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782" +dependencies = [ + "memchr", +] + [[package]] name = "deadpool" version = "0.12.3" @@ -1227,12 +1248,6 @@ dependencies = [ "foldhash", ] -[[package]] -name = "hashbrown" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" - [[package]] name = "hashlink" version = "0.10.0" @@ -1541,7 +1556,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.15.5", ] [[package]] @@ -1657,15 +1672,16 @@ dependencies = [ [[package]] name = "jmespath_extensions" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95ee2950a69b6aea207537220d40a00a7ddb5a259faefdc32cd01d7402d8e41" +checksum = "bb97d4fa7894bdc291623de3ee35a22988c6e897a7b08cda4b8dc870a0d52354" dependencies = [ "aho-corasick", "base64 0.22.1", "chrono", "chrono-tz", "crc32fast", + "csv", "geoutils", "hex", "hmac", diff --git a/crates/redisctl/Cargo.toml b/crates/redisctl/Cargo.toml index 74d9b70..05ae92e 100644 --- a/crates/redisctl/Cargo.toml +++ b/crates/redisctl/Cargo.toml @@ -51,7 +51,7 @@ thiserror = { workspace = true } serde_yaml = { workspace = true } comfy-table = { workspace = true } jmespath = { workspace = true } -jmespath_extensions = { version = "0.6", features = ["full"] } +jmespath_extensions = { version = "0.7", features = ["full"] } config = { workspace = true } # Keyring for Files.com API key storage (separate from profile credentials) diff --git a/docs/src/common-features/jmespath-queries.md b/docs/src/common-features/jmespath-queries.md index 2a1e69a..43389b6 100644 --- a/docs/src/common-features/jmespath-queries.md +++ b/docs/src/common-features/jmespath-queries.md @@ -330,7 +330,7 @@ redisctl enterprise database get 1 -q 'json_diff(current_config, desired_config) | Object | `keys`, `values`, `pick`, `omit`, `deep_merge` | | Math | `round`, `floor`, `ceil`, `sum`, `avg`, `max`, `min`, `stddev` | | Type | `type_of`, `is_array`, `is_string`, `to_boolean` | -| Utility | `if`, `coalesce`, `default`, `now` | +| Utility | `if`, `coalesce`, `default`, `now`, `env` | | DateTime | `format_date`, `time_ago`, `relative_time`, `is_weekend` | | Duration | `format_duration`, `parse_duration` | | Network | `is_private_ip`, `cidr_contains`, `ip_to_int` | @@ -342,6 +342,7 @@ redisctl enterprise database get 1 -q 'json_diff(current_config, desired_config) | Semver | `semver_compare`, `semver_satisfies`, `semver_parse` | | Fuzzy | `levenshtein`, `soundex`, `jaro_winkler` | | JSON Patch | `json_diff`, `json_patch`, `json_merge_patch` | +| Format | `to_csv`, `to_tsv`, `to_csv_table`, `pretty`, `html_escape` | For the complete list, see the [jmespath-extensions documentation](https://docs.rs/jmespath_extensions). diff --git a/docs/src/enterprise/monitoring/usage-report.md b/docs/src/enterprise/monitoring/usage-report.md index 484d3e7..7c5a548 100644 --- a/docs/src/enterprise/monitoring/usage-report.md +++ b/docs/src/enterprise/monitoring/usage-report.md @@ -172,14 +172,10 @@ mkdir -p "$REPORT_DIR" # Export full report redisctl enterprise usage-report export -o "$REPORT_DIR/usage-$DATE.json" -# Create summary CSV -redisctl enterprise usage-report get -q '{ - date: report_date, - databases: usage.total_databases, - shards: usage.total_shards, - memory_gb: usage.total_memory_gb, - nodes: usage.total_nodes -}' | jq -r '[.date, .databases, .shards, .memory_gb, .nodes] | @csv' >> "$REPORT_DIR/usage-summary.csv" +# Create summary CSV using JMESPath to_csv() +redisctl enterprise usage-report get -q ' + to_csv([report_date, usage.total_databases, usage.total_shards, usage.total_memory_gb, usage.total_nodes]) +' --raw >> "$REPORT_DIR/usage-summary.csv" # Email report echo "Redis Enterprise Usage Report for $MONTH" | \ @@ -240,9 +236,10 @@ Tabular format for spreadsheet analysis: # Export to CSV redisctl enterprise usage-report export -o report.csv -f csv -# Export specific data as CSV -redisctl enterprise usage-report get -q 'databases' | \ - jq -r '["name","memory_mb","shards"], (.[] | [.name, .memory_mb, .shard_count]) | @csv' > databases.csv +# Export specific data as CSV using JMESPath to_csv_table() +redisctl enterprise usage-report get -q ' + to_csv_table(databases, [`"name"`, `"memory_mb"`, `"shard_count"`]) +' --raw > databases.csv # Import to Google Sheets redisctl enterprise usage-report export -o /tmp/usage.csv -f csv