- Enable Cloud Resource Manager API;
- Verify Cloud Monitoring API is enabled.
- Create a service account with Project role set to “Viewer”. Alternatively, you can create a role with the minimum permissions required for data collection.
- Create the JSON key credentials;
- Optionally, link this service account to other GCP projects from which you want to collect data.
- Optionally, you can install the Ops agent on each GCE instance to collect memory data. See https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent for details.
Video: Google Cloud Platform Prerequisites for Collecting Data
Video: Google Cloud Platform Prerequisites for Collecting Data
Verify GCP Data Collection APIs are Enabled
You need to verify that the following APIs are enabled for your project:- Cloud Resource Manager API—Needs to be enabled, if not listed.
- Cloud Monitoring API—is enabled by default when the project is created.
- Login to the GCP console and select your project.
- From the GCP console main menu, navigate to APIs & services > Dashboard.
- From the APIs & services Dashboard, ensure that the following APIs are enabled and listed in the Enabled APIs and services list:
- Cloud Resource Manager API
- Cloud Monitoring API (previously named, Stackdriver Monitoring API)
Figure: APIs & Services Dashboard
Figure: APIs & Services Dashboard

- If the Cloud Resource Manager API is not listed, click on ENABLE APIS AND SERVICES at the top of the dashboard. Search for the Cloud Resource Manager API and click Enable:
Figure: Enabling Cloud Resource Manager API
Figure: Enabling Cloud Resource Manager API

Creating a GCP Service Account
To connect Densify to your GCP project, you will need a GCP service account and corresponding credentials in JSON format. You need to repeat this process for each of your GCP projects and save the credential JSON files in an encrypted .ZIP file. You will then import this file to create a connection to collect data from your GCP projects. Use the following instructions to create and configure the GCP service account:- Login to the GCP console and select your project.
- From the main menu, select IAM & Admin > Service accounts.
Figure: Creating Service Account
Figure: Creating Service Account

- From the Service Accounts page, click Create Service Account.
- In the Create service account pane:
- Specify Service account name. As a best practice, use the display name to keep track of what the account will be used for and what permissions are assigned. (e.g. Densify_Connection_Viewer)
- Provide a description of the service. This step is optional, but may help you link this account to other projects later on.
- Click Create and Continue to create the service account.
Figure: Creating Service Account
Figure: Creating Service Account

- In the Role field scroll down the list and select “Project” and then set the role for the whole project to “Viewer”.
Figure: Assigning a Role to the Service Account
Figure: Assigning a Role to the Service Account

- You do not need to add users to the this account so click DONE.
Creating Credentials for the Service Account
You now need to create the key for the service account. Densify uses this key to verify its identity- In the GCP console, from the main menu, select IAM & Admin > Service accounts.
- You should see the account that you just created. In the Key ID column you can see that no keys have been created.
- Click the options in the Actions column. Select Manage keys from the dropdown menu.
- Select Add Key and then Create new key.
- The key is generated and downloaded to your computer. Retain the generated keys for creating the Densify cloud connection.
Do not check these service account keys into your source code or leave them in the download directory.
Creating a Role with Minimum Permissions for Data Collection
Densify recommends using the viewer role, as indicated above, to simplify setup and maintenance of data collection. The viewer role provides read-only access to your GCP services and resources and supports the requirements of Densify data collection and analysis. As the Densify data collection continues to evolve and expand, you do not need to update this permission policy to include newly added services and features. Alternatively, you create a custom role and grant the minimum required permissions to the service account to be used Densify for data collection. You must have theiam.roles.create permission, to create the custom role. The custom role must be created at the Organization level.
This custom role must be updated periodically as Densify’s standard data collection requirements are updated to support additional services and features.
|
|
- Login to the GCP console and navigate to Roles in the main menu.
- Select your organization from the Organization drop-down.
- From the Roles page, click Create Role.
- Enter a Title, Description for the role.
- Click Add Permissions. See the above list and select all 15 permission for your custom role.
- Click Add to grant the selected permissions to your custom role.
- Click CREATE to create the role. You will now see your new role in the list on the Roles page.
Figure: Creating Custom Role
Figure: Creating Custom Role

- When you create the service account, select this custom role as follows:
Figure: Selecting Custom Role
Figure: Selecting Custom Role

Using a Single GCP Service Account to Access Multiple Projects
In order to simplify data collection you can grant a single GCP service account access to other projects. This can be done by adding the service account ID from one project to another, through the account’s IAM & admin dashboard. You would then use this master service account to create your Densify cloud connection.- Login to the GCP console and select the project that contains the service account that will become the master account.
- From the GCP console main menu, select IAM & admin > Service accounts.
- Select the Service account ID to be used as the master account, from the list of service accounts. Copy the Service account ID onto the clipboard, as you cannot search from the Add Members function (in the steps below).
- Select the project to which you want to add the service account.
- From the IAM & admin menu, select IAM.
- Click the ADD in the toolbar.
Figure: IAM & admin Dialog Box
Figure: IAM & admin Dialog Box

- The Add Members dialog box opens. Paste the Service Account ID into the New Members field,
- Select the account’s role in the project. Select the Project > Viewer role for the newly added member.
Figure: Add Member Dialog Box
Figure: Add Member Dialog Box

- Click Add to complete and save the change. You can now use the private key previously generated from the service account to access the selected project.
- You can repeat these steps for your other projects.