More Stackdriver – creating log-based metrics

Log-based metrics allow a logging agent to record certain number of logs of certain types of messages (such as error logs) over certain period of time. There are system-defined log-based metrics and user-defined log-based metrics. To create one, perform following steps:

  1. Go to Stackdriver logging | logs and click on the CREATE METRIC button.
  1. Name your metric. We will name them my-metric and describe its use. Provide labels as required. Here, we will give it as resource.type=“audited_resource”.
  2. Click on Create to create the metric.
  3. You can edit or delete the metric once it is created by clicking on the three dots at the right end of the metric name.
  4. Optionally, you can also create an alert for the metric from the same popup.
  5. Clicking on it will guide you to Stackdriver UI. Here, you can mention the condition of the alert. We have asked for log entries above 4 for 5 minutes in past 1 hour.
  1. Click on Save Condition to save the rule. Optionally, you can also define documentation for it by clicking on +Add Documentation.
  2. Finally, save the policy.

Thus, this is how we create alerting policies for Stackdriver logs in GCP. Now, we will discuss the monitoring aspects of Stackdriver in GCP.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.84.242