Billing in GCD: finding the sku ID in the vm instance - google-cloud-platform

I have checked the billing in GCD and i just find as reference service ID and a sku ID. I can't even click on the sku ID. Is there a more "direct" way to get to the product i used, if it's still running? I know there is a billing api for this, but this does not direct me to the actual product.
If there is no link in the billing report, where can i see the skuID in my for example VM instance?

You can try to use labels to break down your billing charges per resources (per VM instance for example). Have a look at the documentation Creating and managing labels:
A label is a key-value pair that helps you organize your Google Cloud
instances. You can attach a label to each resource, then filter the
resources based on their labels. Information about labels is forwarded
to the billing system, so you can break down your billing charges by
label.
You can create labels by using Resource Manager API, Cloud Console or gcloud command. For GCE resources you should follow the documentation Labeling resources, for example:
$ gcloud compute instances create example-instance --image-family=rhel-8 --image-project=rhel-cloud --zone=us-central1-a --labels=k0=value1,k1=value2
$ gcloud compute instances add-labels example-instance --labels=k0=value1,k1=value2
$ gcloud compute instances update example-instance --zone=us-central1-a --update-labels=k0=value1,k1=value2 --remove-labels=k3
$ gcloud compute instances remove-labels example-instance --labels=k0,k1
In addition, have a look at the documentation View your billing reports and cost trends and Export Cloud Billing data to BigQuery.

Related

Want to get list of Cloud SQL instance in multiple projects in current organisation

I am a fresher to GCP and i would like know how do we get all details related to list of Cloud SQL instances ( Including MYSQL, POSTGRESSSQL, SQLSERVER) from multiple projects in my current organisation.
The purpose of this is to design a dashboard to see various metrics like number of instances running, number of databases running etc. Please note that the default metrics in monitoring does not have these features
Please let me know in detail on how to get on this requirement
You can use the Asset Inventory product. With GCLOUD cli, you can do that like this
gcloud asset search-all-resources --scope=organizations/<YourOrgID> \
--asset-types='sqladmin.googleapis.com/Instance'
If you want to create dashboard, I recommend you to export assets to BigQuery

GCP Billing report does not contain resource id

I generated a billing report(export to csv) for GCP but not able to map billing entry to the resource as there is no resource id present. How am I supposed to know the cost for the individual resource
AWS gives to option to explicitly include the resource id.
Any Help is appreciated
You can use labels to do it. Have a look at the documentation Creating and managing labels:
A label is a key-value pair that helps you organize your Google Cloud
instances. You can attach a label to each resource, then filter the
resources based on their labels. Information about labels is forwarded
to the billing system, so you can break down your billing charges by
label.
You can create labels by using Resource Manager API, Cloud Console or gcloud command (here an example for GCE VM instances).
Services currently supporting labels:
BigQuery
Cloud Bigtable
Dataflow
Dataproc
Cloud Deployment Manager
Cloud Functions
Cloud Healthcare API
Cloud Key Management Service
Pub/Sub
Cloud Spanner
Cloud SQL
Cloud Storage
Compute Engine
Google Kubernetes Engine
Cloud Run (fully managed)
Networking
Resource Manager (projects only)
App Engine (both Flexible and Standard environments)
More information about using labels you can find at the documentation View your billing reports and cost trends, View and download the cost details of your invoice or statement and Export Cloud Billing data to BigQuery
Thank your Response.
I did try it with labels, but in CSV report there is a column for Project Labels only. I exported the same report in Big query and i was able to see columns for tree types of labels project labels, system labels, and labels. The labels which I was setting in VMs I could see them in the third column.
Not sure what are project labels

How to get Grafana CloudWatch Cross-account / Cross-Region Metrics

I have 4 AWS accounts (DTAP) and I want to be able to create one dashboard in Grafana with the cost per service (for all accounts).
So far I can easily create one dashboard in Dev with the costs for all services (using this dashboard: https://grafana.com/grafana/dashboards/139)
I also enabled cross account cross region in AWS (https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Cross-Account-Cross-Region.html) which works nice (in AWS CloudWatch).
Now the problem which I am having is that I can't specify an account selector in this Grafana dashboad 139, or modify the query in such way that I can get metric from different account than Dev:
REMOVE_EMPTY(SEARCH('Namespace="AWS/Billing" MetricName="EstimatedCharges"', 'Average', 3600))
Does anyone has any idea how to get this or which fields are the ones for account select in AWS? I need a programatic way of running "View data for" from the picture below and graph it in Grafana:
Also, I want to avoid creating multiple data sources for each account (due to other limitations)

How do I know what service account is tied to which server?

I see notifications about actions being performed by 123456-compute#service-account but how do I know what servers performed these actions? When I search 123456 in GCE I don't see any servers come up
You can use gcloud tool to list service accounts assigned to compute instances:
gcloud --format='table(name,serviceAccounts.email)' compute instances list
The output would be something like that:
NAME EMAIL
instance-1 [u'123456-compute#developer.gserviceaccount.com']
instance-2 [u'234567-compute#developer.gserviceaccount.com']
It can be that all instances run with the same service account. For example compute engine instances created using GCP console or gcloud tool have default compute engine service account assigned.
In this case service account wouldn't help in identifying which server performed an action.

Service Account does not exists on GCP

While trying for the first time to use Google Kubernetes Cloud solution, and according to the tutorial... I am trying to create new cluster.
But after pressing Create i receive
The request contains invalid arguments: "EXTERNAL: service account
"****#developer.gserviceaccount.com" does not exist.". Error code: "7"
in a red circle near the Kubernetes cluster name.
After some investigations it's looks like the default service account which google generated for my account.
I've looked over the create cluster options, but there isn't any option to change the service account.
Do I need to change Google Compute Engine default service account? how i can do it?
How I can overcome this issue?
Thank you
Default Compute Engine Service Account is essential for functions related to Compute Engine and is being generated automatically. Kubernetes Engine utilizes Compute Engine VM Instances as Nodes used for the cluster. GKE uses the Compute Engine Service Account to authorize the creation of these nodes.
In order to regenerate default service there are two options:
Regenerate by Disabling and Re-enabling the Google Compute Engine API. In the "API's & Services" dashboard. If for some reason performing this option encountering errors when disabling the API, then try option 2.
run command gcloud services enable compute.googleapis.com in Cloud SDK or Cloud Shell which is in the header of the page.
Looks like you either do not have any default service account or have more than one.
Simply go to the "Service Accounts" section "IAM & Admin" and select the app engine default service account, and provide this as an argument while creating cluster from gcloud or gshell as below:
gcloud container clusters create my-cluster --zone=us-west1-b --machine-type=n1-standard-1 --disk-size=100 --service-account=abc#appspot.gserviceaccount.com
To initialize GKE, go to the GCP Console. Wait for the "Kubernetes Engine is getting ready. This may take a minute or more" message to disappear.
Please open the page and wait for a while