Google Compute Engine

Google Compute Engine

Ship Google Compute Engine logs and metrics from Google Cloud Pub/Sub to Logit.io

Follow the steps below to send your observability data to Logit.io

Logs

Install Integration

Please click on the Install Integration button to configure your stack for this source.

Export Logs to Google Pub/Sub

Ensure that you have Cloud Compute configured in GCP (opens in a new tab).

Now we can filter the logs as needed, by clicking on the service name and choosing Show matching entries as shown below.

Filter the logs that we want to export

Read more about how to configure and export logs using the Google Operations Console (opens in a new tab)

Create A Sink

To export the logs choose Create sink as shown below.

Select sink service You will be then be prompted for:

  • Sink details (enter a name)
  • Sink destination (choose Cloud Pub/Sub topic creating a new topic if needed)
  • Choose logs to include in sink (this will have a filter applied already if you filtered the logs above)

Choose Create sink to continue.

Fill in edit sink form

Create Google Pub/Sub

Locate your newly created Pub/Sub topic (opens in a new tab) and choose Create subscription.

Find topic in Topics menu

Enter a suitable Subscription ID and leave the delivery type as pull.

We don't need to change anything further at this stage, scroll to the bottom and choose CREATE to create the Subscription.

Create Service Account

Now in service accounts (opens in a new tab), choose the project you're working with.

Then select CREATE SERVICE ACCOUNT, this account will be used to retrieve logs from the Pub/Sub and send them to Logit.io.

Service accounts screenshot

Name the service account and in step 2 add the role Pub/Sub Subscriber as shown below, then choose DONE.

View new service account

Now choose Manage keys as shown below.

Add key using dropdown

Then choose ADD KEY > Create new key, choosing the recommended JSON format. This will download the JSON key to your machine ready to use in the next step.

Add key using dropdown

Configuring Logstash

To start pulling logs and metrics from the Google Cloud Platform to your Stack you need to configure a Google Cloud Platform Input on your Logit.io Stack.

Go to Dashboard

Logit.io will verify your input before it is applied, we will contact you to confirm when this has been completed.

Launch Logit.io to view your logs

Data should now have been sent to your Stack.

View My Data

If you don't see take a look at How to diagnose no data in Stack below for how to diagnose common issues.

Metrics

Configure Telegraf to ship Google Compute Engine metrics to your Logit.io stacks via Logstash.

Install Integration

Please click on the Install Integration button to configure your stack for this source.

Set Credentials in GCP

@intro

  • Begin by heading over to the 'Project Selector' (opens in a new tab) and select the specific project from which you wish to send metrics.

    • Progress to the 'Service Account Details' screen. Here, assign a distinct name to your service account and opt for 'Create and Continue'.
    • In the 'Grant This Service Account Access to Project' screen, ensure the following roles: 'Compute Viewer', 'Monitoring Viewer', and 'Cloud Asset Viewer'.
    • Upon completion of the above, click 'Done'.
    • Now find and select your project in the 'Service Accounts for Project' list.
    • Move to the 'KEYS' section.
    • Navigate through Keys > Add Key > Create New Key, and specify 'JSON' as the key type.
    • Lastly, click on 'Create', and make sure to save your new key.

    Now add the environment variable for the key

    On the machine run:

    export GOOGLE_APPLICATION_CREDENTIALS=<your-gcp-key>

Install Telegraf

This integration allows you to configure a Telegraf agent to send your metrics, in multiple formats, to Logit.io.

Choose the installation method for your operating system:

When you paste the command below into Powershell it will download the Telegraf zip file. Once that is complete, press Enter again and the zip file will be extracted into C:\Program Files\InfluxData\telegraf\telegraf-1.31.2.

wget https://dl.influxdata.com/telegraf/releases/telegraf-1.31.2_windows_amd64.zip -UseBasicParsing -OutFile telegraf-1.31.2_windows_amd64.zip 
Expand-Archive .\telegraf-1.31.2_windows_amd64.zip -DestinationPath 'C:\Program Files\InfluxData\telegraf'

Configure the Telegraf input plugin

First you need to set up the input plug-in to enable Telegraf to scrape the GCP data from your hosts. This can be accomplished by incorporating the following code into your configuration file:

# Gather timeseries from Google Cloud Platform v3 monitoring API
[[inputs.stackdriver]]
  ## GCP Project
  project = "<your-project-name>"
 
  ## Include timeseries that start with the given metric type.
  metric_type_prefix_include = [
	"@metric_type",
  ]
 
  ## Most metrics are updated no more than once per minute; it is recommended
  ## to override the agent level interval with a value of 1m or greater.
  interval = "1m"

Read more about how to configure data scraping and configuration options for Stackdriver (opens in a new tab)

Configure the output plugin

Once you have generated the configuration file, you need to set up the output plug-in to allow Telegraf to transmit your data to Logit.io in Prometheus format. This can be accomplished by incorporating the following code into your configuration file:

[[outputs.http]]
  url = "https://@metricsUsername:@metricsPassword@@metrics_id-vm.logit.io:@vmAgentPort/api/v1/write"
  data_format = "prometheusremotewrite"
 
  [outputs.http.headers]
    Content-Type = "application/x-protobuf"
    Content-Encoding = "snappy"

Start Telegraf

From the location where Telegraf was installed (C:\Program Files\InfluxData\telegraf\telegraf-1.31.2) run the program providing the chosen configuration file as a parameter:

.\telegraf.exe --config telegraf-demo.conf

Once Telegraf is running you should see output similar to the following, which confirms the inputs, output and basic configuration the application has been started with: Powershell Telegraf information

View your metrics

Data should now have been sent to your Stack.

View My Data

If you don't see metrics take a look at How to diagnose no data in Stack below for how to diagnose common issues.

How to diagnose no data in Stack

If you don't see data appearing in your stack after following this integration, take a look at the troubleshooting guide for steps to diagnose and resolve the problem or contact our support team and we'll be happy to assist.

Cloud Compute Logging Overview

Cloud Compute Engine is an Infrastructure-as-a-service (IaaS) offering from Google Cloud Platform (GCP). This IaaS platform enables users to launch virtual machines on demand through Google's data centers and extensive global network.

Cloud Compute is a comparable platform to Microsoft Azure & Amazon EC2 and is often used as it is relatively inexpensive when compared to the two previously cited service providers. Some of the drawbacks of using GCP can include limited access to virtual machines based upon billing reliability of the organisation's account as if monthly spends are exceeded instances may be unavailable for use.

Compute Engine creates activity, usage, billing & audit logs that allow you track a variety of events affecting your deployment. For example; activity logs record the occurrence of API calls and system events as log messages. It is recommended that you prioritise activity logs over audit messages to follow through log analysis best practises.

With the amount of log messages and formats being generated by a single Infrastructure service it can be hard to know where to look first when it comes to debugging your applications and services running on virtual machines.

You can use Google Cloud Compute logs & metrics to visualise the performance of your services in Hosted Kibana (opens in a new tab) for intelligent reporting & by using our log analysis platform (opens in a new tab) you can correlate the performance of your Compute Engines with the rest of your applications (even those based outside of Google services).

Our Cloud Compute log file analyser can be used to centralise your data, alert on preconfigured rules & monitor the health of all your virtual machine (VM) deployments.

If you need any assistance with analysing your Google Cloud Compute logs we're here to help. Feel free to reach out by getting in contact with us via live chat & we'll be happy to help you start analysing your Cloud Compute data.