# MrLooquer GCP

## Steps and requirements

Steps to configure and integrate your GCP account with MrLooquer:

1. [Create a Exportation Logs](#create-a-exportation-logs)
2. [Create Service account](#create-service-account-for-the-function)
3. [Get api key of MrLooquer Rating](#get-api-key-of-mrlooquer-rating)
4. [Create function](#create-function)

You need to have a MrLooquer account <https://auth.mrlooquer.com/&#x20>;

### Create a Exportation logs

Go to Logging section in Google cloud console.

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA2NmFb-1t9_CxI1vH%2Fimage.png?alt=media\&token=f7efd6b4-47d1-44e3-8521-437ac931e20f)

In the Filter field, click in the down arrow and click on "convert to advanced filter".

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA2sFQsPXW37be_XFc%2Fimage.png?alt=media\&token=4a01f847-c640-4b6d-919f-44edab81515c)

In the input add the next query:

```
resource.type="gce_instance"
jsonPayload.event_subtype:"compute.instances.insert"
jsonPayload.event_type:"GCE_OPERATION_DONE"
```

And click on "Submit Filter".

Now, click on "Create Export" button.

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-LfAB28x_gUoTpekjpnu%2F-LfAB3ViZOSjafUP5UbS%2Fimage.png?alt=media\&token=610139d6-391f-4c15-9eea-c10faa937454)

In the form:

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA46S4m1nNAM_MwDMq%2Fimage.png?alt=media\&token=81e0edda-7135-4d86-9f8f-27df09dfbba2)

Complete the "Sink name" field with a text of you want. The "Sink Service" select "Cloud Pub/Sub" and in the "Sink Destination" field select "Create new Cloud Pub/Sub topic".

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA4I-GolCyM9qgKDYS%2Fimage.png?alt=media\&token=dabcd183-49d0-483f-99c3-b5b4af972ec0)

In the modal, complete the name field and click on "Create"

And select the topic just created in the "Sink Destination" field.

To complete the creation process, click on "Create Sink" button.

### Create Service account for the function

Go to IAM & admin > Service accounts

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA51DqP925dLwO4ed_%2Fimage.png?alt=media\&token=7d1aa13c-092a-4723-8dfc-ba72ec723f42)

Click on "Create Service Account" button, in the top of the page:

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-LfGuY1lKDDODymeocgJ%2F-LfGu_CUpFQQ7C0oYTfA%2Fimage.png?alt=media\&token=502c9c9a-53a6-42d6-9357-84e6fc86303f)

In the first step, complete the fields and click on "Create" button

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA5k6sENFzl9suVWwg%2Fimage.png?alt=media\&token=f669be27-a679-44cb-b8ec-38b26e00ac33)

In the second step, add 2 roles:

Compute Engine > Compute Viewer

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA6ZuPCN3hZqidj1wp%2Fimage.png?alt=media\&token=aac732ca-6ddd-4b65-a5d1-0e4bc08d57ad)

And Compute Engine > Compute Network Viewer

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA6dmoFInz4xH69i-U%2Fimage.png?alt=media\&token=a3e2707d-236d-42d8-bc74-af5ec9ed9b6f)

At the end, the form should be:

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA6i1VZGU9ay5AklTZ%2Fimage.png?alt=media\&token=6a00be60-2f35-4ae6-bfa2-05f00516d4d5)

Click on "Continue" button, and in the next step, click on "Done".

### Get api key of MrLooquer Rating

Login on [MrLooquer Rating](https://auth.mrlooquer.com/) and go to "Settings" menu. Set a name and copy the token.

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Ld38o643bWDjT8-8hLk%2F-Ld3ENjbbdP9_06g2TMx%2Fimage.png?alt=media\&token=07cc94ba-6923-467a-9a3f-0777bb19afd7)

### Create function

Go to "Cloud functions"

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA7ITEQUHuDuj_p93o%2Fimage.png?alt=media\&token=30e9a972-7255-4773-887e-8e175be18ea0)

Click on "Create function" button.

Fill the fields with the following information:

* Name: Name that you want
* Memory allocated: 128 MB
* Trigger: Cloud Pub/Sub
* Topic: The topic that you created in the first step
* Source Code: ZIP uploaded
* Runtime: Node.js 10 (Beta)
* Zip File: You can download the zip of the following url: <https://github.com/mrlooquer/mrlooquer-rating-gcp/releases/download/v1.0.0/code-function.zip>
* Stage bucket: You can choose an existing bucket or create a new bucket.&#x20;
* Function to execute: handler

In the advanced options:

* Region: Region that you want
* Timeout: 60
* Service account: The account that you created in the second step.
* And add one environment variable:
  * API\_TOKEN: The token that you created in the third step.

The form should be:

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-Lf9hnpo65Jy_KiffTNE%2F-LfA9CIBDKjrfHP0Qtc1%2Fimage.png?alt=media\&token=72bc7495-595c-477b-9b72-f40b00497516)

![](https://447679008-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LcwMVGj4THx62yRWx0s%2F-LfACXq6IRjOFfFsLDr_%2F-LfAC_1Xdr1vqj-lJroZ%2Fimage.png?alt=media\&token=6fdc3f9d-48ba-4ffa-b0c9-64b20b044e09)

Click on "Create" and you are done!
