Skip to content

gcp get-log-metric

Get log metric

Description

Get log metric for gcp logs

Synopsis

gcp get-log-metric
    [--site <site>]
    [<name>]

Arguments

site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default: input.site      Attributes: optional

name - (string)

     Metric name to fetch metric
     Example: "CassandraMetric"
     Default: _None_      Attributes: optional

Examples

Input:

x=! gcp get-log-metric
Output:
{
  "metric": [
    {
      "name": "testMetric1",
      "filter": "severity=\"INFO\"",
      "metricDescriptor": {
        "name": "projects/macro-context-293714/metricDescriptors/logging.googleapis.com/user/testMetric1",
        "type": "logging.googleapis.com/user/testMetric1",
        "metricKind": "DELTA",
        "valueType": "INT64",
        "unit": "1"
      },
      "createTime": "2022-10-12T10:48:23.869119110Z",
      "updateTime": "2022-10-12T10:48:23.869119110Z"
    },
    {
      "name": "testMetric2",
      "description": "testDesc2",
      "filter": "severity=\"INFO\"",
      "metricDescriptor": {
        "name": "projects/macro-context-293714/metricDescriptors/logging.googleapis.com/user/testMetric2",
        "type": "logging.googleapis.com/user/testMetric2",
        "metricKind": "DELTA",
        "valueType": "INT64",
        "unit": "1",
        "description": "testDesc2"
      },
      "createTime": "2022-10-12T13:33:38.884929622Z",
      "updateTime": "2022-10-12T14:00:28.715224167Z"
    },
    {
      "name": "testMetric3",
      "description": "testDesc2",
      "filter": "severity=\"INFO\"",
      "metricDescriptor": {
        "name": "projects/macro-context-293714/metricDescriptors/logging.googleapis.com/user/testMetric3",
        "type": "logging.googleapis.com/user/testMetric3",
        "metricKind": "DELTA",
        "valueType": "INT64",
        "unit": "1",
        "description": "testDesc2"
      },
      "createTime": "2022-10-14T08:33:18.198693597Z",
      "updateTime": "2022-10-14T08:35:44.706415294Z"
    }
  ]
}
Input:
! gcp get-log-metric
Output:
NAME            DESCRIPTION     FILTER                                                  TYPE                                    
testMetric1     testDesc2       severity="INFO"                                         logging.googleapis.com/user/testMetric1
testMetric2     testDesc2       severity="INFO"                                         logging.googleapis.com/user/testMetric2
testMetric3     testDesc        severity="INFO"                                         logging.googleapis.com/user/testMetric3
testMetric4     testDesc        protoPayload.status >= 400 AND sample(insertId, 0.1)    logging.googleapis.com/user/testMetric4
testMetric5     -               protoPayload.status >= 400 AND sample(insertId, 0.1)    logging.googleapis.com/user/testMetric5
Input:
! gcp get-log-metric "testMetric1"
Output:
NAME            DESCRIPTION     FILTER                                                  TYPE                                    
testMetric1     testDesc2       severity="INFO"                                         logging.googleapis.com/user/testMetric1
Input:
! gcp create-bucket "prabhsimran-bucket-3"
Output:
Bucket prabhsimran-bucket-3 is created
Input:
x=! gcp get-buckets
Output:
{
  "buckets": [
    {
      "name": "prabhsimran-bucket-1",
      "created": "2022-10-28T06:35:42.135Z",
      "labels": {
        "owner": "prabhsimran",
        "use": "testing"
      },
      "location": "US",
      "etag": "CAE="
    },
    {
      "name": "prabhsimran-bucket-2",
      "created": "2022-10-28T06:36:14.403Z",
      "location": "US",
      "etag": "CAE="
    }
  ]
}
Input:
! gcp get-buckets
Output:
NAME                    CREATED                         LOCATION        ETAG 
prabhsimran-bucket-1    2022-10-28T06:35:42.135Z        US              CAE=
Input:
! gcp delete-bucket "prabhsimran-bucket-3"
Output:
Bucket prabhsimran-bucket-3 is deleted
Input:
! gcp create-object "testobject-2" --bucket "prabhsimran-bucket-2" --body "test-body"
Output:
Object testobject-2 is created
Input:
! gcp get-object "testobject-2" --bucket "prabhsimran-bucket-2"
Output:
test-body
Input:
x=! gcp list-objects --bucket "prabhsimran-bucket-1"
Output:
{
  "objects": [
    {
      "name": "testobject-1",
      "created": "2022-10-28T06:56:02.183Z",
      "updated": "2022-10-28T06:56:02.183Z",
      "deleted": "0001-01-01T00:00:00Z",
      "etag": "CLTs54GsgvsCEAE=",
      "bucket": "prabhsimran-bucket-1",
      "size": "9",
      "contentType": "text/plain; charset=utf-8"
    }
  ]
}
Input:
! gcp list-objects --bucket "prabhsimran-bucket-1"
Output:
NAME            BUCKET                  SIZE    CREATED                         UPDATED                         DELETED              
testobject-1    prabhsimran-bucket-1    9       2022-10-28T06:56:02.183Z        2022-10-28T06:56:02.183Z        0001-01-01T00:00:00Z
Input:
x=! gcp get-instances --zone "us-central1-a"
Output:
{
  "instances": [
    {
      "name": "test-instance-1",
      "created": "2022-10-28T00:26:21.770-07:00",
      "status": "RUNNING",
      "zone": "https://www.googleapis.com/compute/v1/projects/prabhsimran-project/zones/us-central1-a",
      "machineType": "https://www.googleapis.com/compute/v1/projects/prabhsimran-project/zones/us-central1-a/machineTypes/f1-micro"
    }
  ]
}
Input:
! gcp get-instances --zone "us-central1-a"
Output:
NAME            CREATED                         STATUS          ZONE                                                                                    MACHINE TYPE                                                                                                 
test-instance-1 2022-10-28T00:26:21.770-07:00   TERMINATED      https://www.googleapis.com/compute/v1/projects/prabhsimran-project/zones/us-central1-a  https://www.googleapis.com/compute/v1/projects/prabhsimran-project/zones/us-central1-a/machineTypes/f1-micro
Input:
! gcp stop-instance "test-instance-1" --zone "us-central1-a"
Output:
Instance test-instance-1 is stopped
Input:
! gcp start-instance "test-instance-1" --zone "us-central1-a"
Output:
Instance test-instance-1 is started
Input:
! gcp delete-instance "test-instance-1" --zone "us-central1-a"
Output:
Instance test-instance-1 is deleted

Access Control

To use this command, you need access to the following:

Field Value
Action "read"
Service Type "gcp"
Service Instance
Namespace
Object Type "metric"
Object ID name

Please see Access Control for details.