auth0 / auth0-cli

Build, manage and test your Auth0 integrations from the command line
https://auth0.github.io/auth0-cli/
MIT License
243 stars 52 forks source link

Add capability to export logs as type csv not just json. #954

Closed DannyPat44 closed 8 months ago

DannyPat44 commented 8 months ago

Checklist

Describe the problem you'd like to have solved

I was investigating some issues in our tenant and wanted to export some logs to a .csv file so we can count specific issues and share them with our customer success and support teams. Specifically, you can load the .csv to Excel, which is a friendly tool for non-developers.

Describe the ideal solution

I was able to do it, but I had to do some jq manipulation, which was a bit painful. It would be nice to have a similar flag as --json for csv or have the formatting to the log table be more straightforward to parse to .csv.

Alternatives and current workarounds

I was able to use this to build a csv file from the json output. But it took more effort than I would have liked. auth0 logs list --filter "type: f AND date:[2023-12-25 TO 2024-01-02]" --json | jq -r '["type", "date", "description", "connection", "client_name", "user_agent"], (.[] | [.type, .date, .description, .connection, .client_name, .user_agent]) | @csv ' >> ~/Downloads/ben-logs.csv

I tried using tr and sed but found that both would not properly break the file apart with the current output formating. auth0 logs list --filter "type: f AND date:[2023-12-25 TO 2024-01-02]" | tr "\\t" "," >> ~/Downloads/amh-logs.csv

Additional context

I love the new CLI tool. Overall, it is a great addition to help developers troubleshoot.

m3talsmith commented 8 months ago

@DannyPat44 I'm working on a CSV export for another command and looking at generalizing the format. I'll keep logs in mind as I think it's a good fit too. Update you as it comes together.

m3talsmith commented 8 months ago

@DannyPat44 #955 brings the --csv flag to logs and all the rest of our table result-based commands. This should be merged today into the main branch and make it into the next release.

An example of using it in your case would be:

auth0 logs list --filter "type: f AND date:[2023-12-25 TO 2024-01-02]" --csv > ~/Downloads/ben-logs.csv
DannyPat44 commented 8 months ago

Wow, that was so quick! Thank you.