Exporting detection rules and its exceptions

how to export all detection rules along with its query into csv format from elasticsearch portal?
how to export exceptions under each detection rule into csv format from elasticsearch portal?