To set up log forwarding from GCP Cloud Logging to Apica Ascent, you must:
Create a user-managed service account
Create a Cloud Pub/Sub topic
Create a log sink and subscribe it to the Pub/Sub topic
Create a VM for Logstash
The examples in this document use the gcloud command-line interface. Google Cloud APIs must be enabled through the Services and APIs page in the console before they can be used with gcloud. To perform the steps in this tutorial, enable the following APIs:
Compute Engine
Pub/Sub
Identity and Access Management (IAM)
Cloud Logging
Create a service account
Activate and login to the Cloud Shell. Create a service account to attach to the VM
The commands use project namegcp-customer-1.Replace it with a valid project name from the target account.
gcloud iam service-accounts create logstash --display-name="Logstash to Apica Ascent"
Provide IAM permissions allowing the new service account to access Pub/Sub using the pubsub.subscriber role.
gcloud projects add-iam-policy-binding gcp-customer-1 \
--member serviceAccount:logstash@gcp-customer-1.iam.gserviceaccount.com \
--role roles/pubsub.subscriber
//Replace the customer name 'gcp-customer-1' with a valid one
Create a Pub/Sub topic and subscription
Create a Pub/Sub topic where Cloud Logging will send events to be picked up by Logstash using the following command.
gcloud pubsub topics create apica-ascent-topic
Next, create a subscription by running the following command.
Create a log sink to be used to export logs to the new Pub/Sub topic.
gcloud logging sinks create \
logstash-sink pubsub.googleapis.com/projects/gcp-customer-1/topics/apica-ascent-topic
//Response
Created [https://logging.googleapis.com/v2/projects/scalesec-dev/sinks/logstash-sink].
Please remember to grant `serviceAccount:p3520xx273005-05xx3@gcp-sa-logging.iam.gserviceaccount.com` Pub/Sub
Publisher role to the topic.
More information about sinks can be found at /logging/docs/export/
The second part of the output is a reminder to verify that the service account used by Cloud Logging has permission to publish events to the Pub/Sub topic.
You can now launch the Apica Ascent GCP PubSub App extension and pull logs directly from the created topic and subscription. Please refer to the documenation on how to do so.
Create the Logstash VM (Deprecated)
Create a VM to run logstash to pull logs from the Pub/Sub logging sink and send them to Apica Ascent:
Logstash comes with no default configuration. Create a new file /etc/logstash/conf.d/logstash.conf with the below contents, modifying values as needed:
Autopilot is a new mode of operation in Google Kubernetes Engine (GKE) that is designed to reduce the operational cost of managing clusters, optimize your clusters for production, and yield higher workload availability, use the below configuration on Logstash configuration to forward logs to Apica Ascent.
The mappings for k8s_node, k8s_pod, k8s_cluster can further be refined by mapping into the json logs from cloud logging. The above mapping is an example on how you can use flexible mappings to suite your needs.
You can obtain an ingest token from the Apica Ascent UI as described here. You can customize the namespace and cluster_id in the Logstash configuration based on your needs.
Your GCP Cloud Logging logs will now be forwarded to your Apica Ascent instance. See the Explore Section to view the logs.
Running logstash outside of GCE
If you are running logstash in a VM outside of GCE, you need to provide the service account token in the logstash configuration as well.