I have a Python based microservice where Cloud Api Python SDK is used to create and record custom metrics, code is shown below.
from google.api import label_pb2 as ga_label
from google.api import metric_pb2 as ga_metric
from google.cloud import monitoring_v3
client = monitoring_v3.MetricServiceClient()
project_name = f"projects/{project_id}"
descriptor = ga_metric.MetricDescriptor()
descriptor.type = "custom.googleapis.com/my_metric" + str(uuid.uuid4())
descriptor.metric_kind = ga_metric.MetricDescriptor.MetricKind.GAUGE
descriptor.value_type = ga_metric.MetricDescriptor.ValueType.DOUBLE
descriptor.description = "Custom Metric recording specific code level events."
Example logs are shown below. Sensitive data has been redacted.
Can I ask how to create a log-based metric to count the number of log entries that match a given filter?
Current Google cloud documentation is complex and doesn't clearly answer my application requirements. I've gone through this article published by Google but not being able to get the correct metrics created.