gcp metrics - ghdrako/doc_snipets GitHub Wiki

resource.type="k8s_container"
resource.labels.project_id="tst-biz-acp-gcp-pr"
resource.labels.location="europe-north1-a"
resource.labels.cluster_name="c1-tst-biz-acp-gcp-pr"
resource.labels.namespace_name="acp"
labels.k8s-pod/job-name:"acp-ms-cdc-replication-boot-" severity>=WARNING
jsonPayload.message=~ "Deactivate replication"
locals {
    resource_type_condition = "resource.type=k8s_container"        
    resource_labels_condition = format("resource.labels.project_id=%s AND resource.labels.cluster_name=%s AND resource.labels.namespace_name=%s",
                                 var.project, 
                                 var.cluster_name, 
                                 var.ns)
}


module "acp-ms-cdc-replication-boot-monitoring-module" {
    source = "[email protected]:multicloud/iac/pkobp/gcp/modules/cloud-stackdriver-logging/google-logging-metrics.git?ref=v1.0.0"
    name = "acp-ms-cdc-replication-boot-_deactivation_error_count-tf"
    filter =  format("%s AND %s AND %s AND %s",
                     local.resource_type_condition,
                     "labels.k8s-pod/job-name:acp-ms-cdc-replication-boot-",
                     "severity >= WARNING",
                     "jsonPayload.message=~ \"Deactivate replication\"")
    description = "acp-ms-cdc-replication-boot - log deactivation errors metrics."
    metric_kind = "DELTA"
    value_type  = "INT64"
}