Is there a way to programmatically (via REST api) access the usage of service within a public bluemix account?
Does Public Bluemix exposes API to access the usage history of bluemix account
Updated answer:
You can use the following Bluemix CLI command to retrieve the monthly usage and costs of your account:
bluemix bss account-usage [-d YYYY-MM] [--json]
Prerequisites: Endpoint, Login
Command options:
-d MONTH_DATE (optional)
Display data for month and date specifying by using the YYYY-MM format. If not specified, usage of the current month is shown.
--json (optional)
Display the usage result in JSON format.
Here's an example that show an account usage and cost report in 2016-06:
bluemix bss account-usage -d 2016-06
If you run the command with "export BLUEMIX_TRACE=true”, you can see the API endpoints that are being used.
There are other commands and more information available at the following URL:
https://console.ng.bluemix.net/docs/cli/reference/bluemix_cli/index.html#bluemix_bss_account_usage
Related
We're switching over our scripts from using gsutil to the reportedly faster gcloud storage. However we access a significant amount of public data, for example from gs://gcp-public-data--broad-references.
We do NOT want to pay to download this public data. However it appears that gcloud storage is automatically setting the X-Goog-User-Project header for public transfers while gsutil does not.
Is my understanding of the various documentation correct that glcoud storage is instructing GCS to bill us and not the public bucket for transfers?
Run gcloud version
On my machine this outputs Google Cloud SDK 407.0.0 and gsutil 5.15
Run gcloud init
Log in
Select a google project
Run gcloud config list
Verify the project you selected before has been configured
Run gsutil -d ls gs://gcp-public-data--broad-references
Verify that the request Headers: do NOT contain X-Goog-User-Project
Run gcloud --log-http storage ls gs://gcp-public-data--broad-references
Verify that under == headers start == your default project has been included as the X-Goog-User-Project
According to all the documentation I've been able to find one should not set that header by default.
Via https://cloud.google.com/storage/docs/requester-pays:
Important: Buckets that have Requester Pays disabled still accept requests that include a billing project, and charges are applied to the billing project supplied in the request. Consider any billing implications prior to including a billing project in all of your requests.
Via https://cloud.google.com/storage/docs/xml-api/reference-headers#xgooguserproject:
The project specified in the header is billed for charges associated with the request. This header is used, for example, when making requests to buckets that have Requester Pays enabled.
Bonus:
Run gsutil ls gs://gnomad-public-requester-pays
You should receive an error BadRequestException: 400 Bucket is a requester pays bucket but no user project provided.
Run gcloud storage ls gs://gnomad-public-requester-pays
The bucket contents should be listed
The latter above doesn't seem correct to me as I never intentionally told gcloud storage which project to bill for the request.
Heard back from a support member after this was reposted to the Google Cloud Community Forums.
ErnestoC said:
The default behavior of the Cloud CLI gcloud is to use the current project for all quota and billing operations. This is why you automatically see your project ID passed in X-Goog-User-Project. This behavior can be overridden though by adding the global --billing-project flag to any command.
If you set this flag to an empty string, no project is passed in the request. I tested this with gcloud storage and confirmed that requester pays buckets return the expected error message (“400: Bucket is a requester pays bucket but no user project provided.”). Non-requester pays buckets allow operations as well.
The account settings page (Manage > Account > Account Settings) lists an account ID and an account name under the "Account" heading. The account ID is easy enough to retrieve using the API, but I've not found a way to get the account name. Is this possible to get using the API?
I've been looking at the IBM Cloud API Docs and at the Softlayer API docs but haven't been able to find something which returns the account name.
The ibmcloud CLI returns the info, but I'd rather not have to use the CLI since this will be used from within a Python app.
You can always use IBMCLOUD_TRACE=true on the CLI to find out what the ibmcloud command is doing. What you see as "account name" is the ID resolved by going to the user management API.
Is there a way to get IBM Cloud Compose for RabbitMQ logs using web interface or cli?
There is Syslog-NG for RabbitMQ and it has other cloud logging services namely papertrail and Loggly providing the webinterface along with two IBM Cloud Compose API calls for logs
Get list of available logfiles
GET /2016-07/deployments/:id/logfiles
Get details of a logfile including download link
GET /2016-07/deployments/:id/logfiles/:logfile_id
To make use of the API, you will need a handful of digital assets; a token for your account to access the IBM Cloud API and a foundation endpoint for your queries. Check this link for details on how to get the token, endpoint and example cURL calls
We are using Bluemix Cloud Foundry applications and need to capture billing information for reporting purposes. Is anyone aware of how you can export the billing usage from Bluemix into a .csv or any other format?
Thanks.
I haven't it used that much, but you could use the bluemix / bx command with the billing option to retrieve usage and billing information per account or org. You can export it as JSON file.
The following would retrieve the usage for the org "user1#example.com" for the month of April 2017 in JSON format:
bx billing org-usage user1#example.com -d 2017-04 --json
Is it possible to retrieve the app/service usage information ( the fee/the money) via api?
I noticed that my current cf command 's version is 2.40.0
API endpoint: https://api.ng.bluemix.net (API version: 2.40.0)
I checked the api list and cannot find any useful information about my request.
Billing information for Bluemix services and application usage is not available through an API; it is only available through the Bluemix console. However, feel free to submit the request on the IBM Bluemix Ideas site for future consideration. Bluemix Project Management reviews the ideas regularly.
Using CF CLI you could use:
cf curl /v2/organizations/ORG_GUID/summary
to retrieve the org guid you can use
cf org <orgName> --guid
This provides you information about the number of services and applications, and the memory usage.