Skip to content

Commit

Permalink
GCP costs - removed bq messages (#846)
Browse files Browse the repository at this point in the history
* Fixed file name

* Fixed file name

* Revert "Fixed file name"

This reverts commit dc9c1fb.

* Fixed file name

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Fixed typo
  • Loading branch information
jdesouza authored Nov 30, 2023
1 parent 93cf743 commit 33d166e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions plugins/cloud-costs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.1.3
* Fix cloud costs content

## 0.1.2
* Fix cloud costs file name

Expand Down
6 changes: 4 additions & 2 deletions plugins/cloud-costs/cloud-costs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ if [[ "$provider" == "gcp" ]]; then
gcloud auth activate-service-account --key-file=/.config/gcp-key.json --project=$projectname

sql="SELECT main.* FROM \`$table\` AS main LEFT JOIN UNNEST(labels) as labels WHERE labels.key = '$tagkey' AND labels.value = '$tagvalue' and usage_start_time >= '$initial_date_time' AND usage_start_time < '$final_date_time' order by usage_start_time desc"
bq --format=prettyjson query --max_rows=1000000 --nouse_legacy_sql "$sql" > /output/cloudcosts-tmp.json
bq --quiet --format=prettyjson query --max_rows=10000000 --nouse_legacy_sql "$sql" > /output/cloudcosts-tmp.json
echo "Google bigquey finished......"

mv /output/cloudcosts-tmp.json /output/cloudcosts.json
awk '$0 == "[" {p=1} p' < /output/cloudcosts-tmp.json > /output/cloudcosts-tmp-clean.json

mv /output/cloudcosts-tmp-clean.json /output/cloudcosts.json
echo "Saved GCP costs file in /output/cloudcosts.json"

exit 0
fi
2 changes: 1 addition & 1 deletion plugins/cloud-costs/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.2
0.1.3

0 comments on commit 33d166e

Please sign in to comment.