From 864e65167917e6b6f5a57d496dce6c39248d4a95 Mon Sep 17 00:00:00 2001 From: Alex Resnick Date: Sat, 4 Dec 2021 15:45:27 +0000 Subject: [PATCH 1/2] Add GCP Custom Metricset --- packages/gcp/_dev/build/docs/metrics.md | 11 + .../metrics/agent/stream/stream.yml.hbs | 20 ++ .../gcp/data_stream/metrics/fields/agent.yml | 198 ++++++++++++++++++ .../metrics/fields/base-fields.yml | 20 ++ .../gcp/data_stream/metrics/fields/ecs.yml | 24 +++ packages/gcp/data_stream/metrics/manifest.yml | 40 ++++ .../gcp/data_stream/metrics/sample_event.json | 45 ++++ 7 files changed, 358 insertions(+) create mode 100644 packages/gcp/_dev/build/docs/metrics.md create mode 100644 packages/gcp/data_stream/metrics/agent/stream/stream.yml.hbs create mode 100644 packages/gcp/data_stream/metrics/fields/agent.yml create mode 100644 packages/gcp/data_stream/metrics/fields/base-fields.yml create mode 100644 packages/gcp/data_stream/metrics/fields/ecs.yml create mode 100644 packages/gcp/data_stream/metrics/manifest.yml create mode 100644 packages/gcp/data_stream/metrics/sample_event.json diff --git a/packages/gcp/_dev/build/docs/metrics.md b/packages/gcp/_dev/build/docs/metrics.md new file mode 100644 index 00000000000..1d279cfdaf6 --- /dev/null +++ b/packages/gcp/_dev/build/docs/metrics.md @@ -0,0 +1,11 @@ +# Custom Metrics + +Create custom metrics queries for additional data besides the compute, storage, gke, loadbalancing... as shown [here](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-metricset-gcp-metrics.html). + +## Metrics + +This is the `metrics` dataset. + +{{event "metrics"}} + +{{fields "metrics"}} \ No newline at end of file diff --git a/packages/gcp/data_stream/metrics/agent/stream/stream.yml.hbs b/packages/gcp/data_stream/metrics/agent/stream/stream.yml.hbs new file mode 100644 index 00000000000..877f28b7c42 --- /dev/null +++ b/packages/gcp/data_stream/metrics/agent/stream/stream.yml.hbs @@ -0,0 +1,20 @@ +metricsets: ["metrics"] +period: {{period}} +project_id: {{project_id}} +{{#if credentials_file}} +credentials_file: {{credentials_file}} +{{/if}} +{{#if credentials_json}} +credentials_json: {{credentials_json}} +{{/if}} +{{#if region}} +region: {{region}} +{{/if}} +{{#if zone}} +zone: {{zone}} +{{#/if}} +exclude_labels: {{exclude_labels}} +{{#if metrics}} +metrics: + {{metrics}} +{{#/if}} diff --git a/packages/gcp/data_stream/metrics/fields/agent.yml b/packages/gcp/data_stream/metrics/fields/agent.yml new file mode 100644 index 00000000000..da4e652c53b --- /dev/null +++ b/packages/gcp/data_stream/metrics/fields/agent.yml @@ -0,0 +1,198 @@ +- name: cloud + title: Cloud + group: 2 + description: Fields related to the cloud or infrastructure the events are coming from. + footnote: 'Examples: If Metricbeat is running on an EC2 host and fetches data from its host, the cloud info contains the data about this machine. If Metricbeat runs on a remote machine outside the cloud and fetches data from a service running in the cloud, the field contains cloud data from the machine the service is running on.' + type: group + fields: + - name: account.id + level: extended + type: keyword + ignore_above: 1024 + description: 'The cloud account or organization id used to identify different entities in a multi-tenant environment. + + Examples: AWS account id, Google Cloud ORG Id, or other unique identifier.' + example: 666777888999 + - name: availability_zone + level: extended + type: keyword + ignore_above: 1024 + description: Availability zone in which this host is running. + example: us-east-1c + - name: instance.id + level: extended + type: keyword + ignore_above: 1024 + description: Instance ID of the host machine. + example: i-1234567890abcdef0 + - name: instance.name + level: extended + type: keyword + ignore_above: 1024 + description: Instance name of the host machine. + - name: machine.type + level: extended + type: keyword + ignore_above: 1024 + description: Machine type of the host machine. + example: t2.medium + - name: provider + level: extended + type: keyword + ignore_above: 1024 + description: Name of the cloud provider. Example values are aws, azure, gcp, or digitalocean. + example: aws + - name: region + level: extended + type: keyword + ignore_above: 1024 + description: Region in which this host is running. + example: us-east-1 + - name: project.id + type: keyword + description: Name of the project in Google Cloud. + - name: image.id + type: keyword + description: Image ID for the cloud instance. +- name: container + title: Container + group: 2 + description: 'Container fields are used for meta information about the specific container that is the source of information. + + These fields help correlate data based containers from any runtime.' + type: group + fields: + - name: id + level: core + type: keyword + ignore_above: 1024 + description: Unique container id. + - name: image.name + level: extended + type: keyword + ignore_above: 1024 + description: Name of the image the container was built on. + - name: labels + level: extended + type: object + object_type: keyword + description: Image labels. + - name: name + level: extended + type: keyword + ignore_above: 1024 + description: Container name. +- name: host + title: Host + group: 2 + description: 'A host is defined as a general computing instance. + + ECS host.* fields should be populated with details about the host on which the event happened, or from which the measurement was taken. Host types include hardware, virtual machines, Docker containers, and Kubernetes nodes.' + type: group + fields: + - name: architecture + level: core + type: keyword + ignore_above: 1024 + description: Operating system architecture. + example: x86_64 + - name: domain + level: extended + type: keyword + ignore_above: 1024 + description: 'Name of the domain of which the host is a member. + + For example, on Windows this could be the host''s Active Directory domain or NetBIOS domain name. For Linux this could be the domain of the host''s LDAP provider.' + example: CONTOSO + default_field: false + - name: hostname + level: core + type: keyword + ignore_above: 1024 + description: 'Hostname of the host. + + It normally contains what the `hostname` command returns on the host machine.' + - name: id + level: core + type: keyword + ignore_above: 1024 + description: 'Unique host id. + + As hostname is not always unique, use values that are meaningful in your environment. + + Example: The current usage of `beat.name`.' + - name: ip + level: core + type: ip + description: Host ip addresses. + - name: mac + level: core + type: keyword + ignore_above: 1024 + description: Host mac addresses. + - name: name + level: core + type: keyword + ignore_above: 1024 + description: 'Name of the host. + + It can contain what `hostname` returns on Unix systems, the fully qualified domain name, or a name specified by the user. The sender decides which value to use.' + - name: os.family + level: extended + type: keyword + ignore_above: 1024 + description: OS family (such as redhat, debian, freebsd, windows). + example: debian + - name: os.kernel + level: extended + type: keyword + ignore_above: 1024 + description: Operating system kernel version as a raw string. + example: 4.4.0-112-generic + - name: os.name + level: extended + type: keyword + ignore_above: 1024 + multi_fields: + - name: text + type: text + norms: false + default_field: false + description: Operating system name, without the version. + example: Mac OS X + - name: os.platform + level: extended + type: keyword + ignore_above: 1024 + description: Operating system platform (such centos, ubuntu, windows). + example: darwin + - name: os.version + level: extended + type: keyword + ignore_above: 1024 + description: Operating system version as a raw string. + example: 10.14.1 + - name: type + level: core + type: keyword + ignore_above: 1024 + description: 'Type of host. + + For Cloud providers this can be the machine type like `t2.medium`. If vm, this could be the container, for example, or other information meaningful in your environment.' + - name: containerized + type: boolean + description: > + If the host is a container. + + - name: os.build + type: keyword + example: "18D109" + description: > + OS build information. + + - name: os.codename + type: keyword + example: "stretch" + description: > + OS codename, if any. + diff --git a/packages/gcp/data_stream/metrics/fields/base-fields.yml b/packages/gcp/data_stream/metrics/fields/base-fields.yml new file mode 100644 index 00000000000..a98b338bf92 --- /dev/null +++ b/packages/gcp/data_stream/metrics/fields/base-fields.yml @@ -0,0 +1,20 @@ +- name: data_stream.type + type: constant_keyword + description: Data stream type. +- name: data_stream.dataset + type: constant_keyword + description: Data stream dataset. +- name: data_stream.namespace + type: constant_keyword + description: Data stream namespace. +- name: '@timestamp' + type: date + description: Event timestamp. +- name: event.module + type: constant_keyword + description: Event module + value: gcp +- name: event.dataset + type: constant_keyword + description: Event dataset + value: gcp.metrics diff --git a/packages/gcp/data_stream/metrics/fields/ecs.yml b/packages/gcp/data_stream/metrics/fields/ecs.yml new file mode 100644 index 00000000000..83e3f6f1225 --- /dev/null +++ b/packages/gcp/data_stream/metrics/fields/ecs.yml @@ -0,0 +1,24 @@ +- external: ecs + name: cloud +- external: ecs + name: cloud.account.id +- external: ecs + name: cloud.account.name +- external: ecs + name: cloud.availability_zone +- external: ecs + name: cloud.instance.id +- external: ecs + name: cloud.machine.type +- external: ecs + name: cloud.provider +- external: ecs + name: cloud.region +- external: ecs + name: ecs.version +- external: ecs + name: error +- external: ecs + name: error.message +- external: ecs + name: service.type diff --git a/packages/gcp/data_stream/metrics/manifest.yml b/packages/gcp/data_stream/metrics/manifest.yml new file mode 100644 index 00000000000..7f5a332538c --- /dev/null +++ b/packages/gcp/data_stream/metrics/manifest.yml @@ -0,0 +1,40 @@ +title: "GCP Custom Metrics" +type: metrics +streams: + - input: gcp/metrics + title: GCP Custom Metrics + description: Collect Custom GCP Metrics + vars: + - name: zone + type: text + title: GCP Zone + multi: false + required: false + show_user: true + - name: region + type: text + title: GCP Region + multi: false + required: false + show_user: true + - name: metrics + type: yaml + title: Metrics + required: false + show_user: true + multi: false + description: > + Groups of agregated metrics. See https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-metricset-gcp-metrics.html for examples + + - name: exclude_labels + type: bool + title: Exclude Labels + description: Exclude additional labels from metrics + multi: false + required: false + show_user: true + - name: period + type: text + title: Period + default: 10s + required: true diff --git a/packages/gcp/data_stream/metrics/sample_event.json b/packages/gcp/data_stream/metrics/sample_event.json new file mode 100644 index 00000000000..63de88f4828 --- /dev/null +++ b/packages/gcp/data_stream/metrics/sample_event.json @@ -0,0 +1,45 @@ +{ + "@timestamp": "2017-10-12T08:05:34.853Z", + "cloud": { + "account": { + "id": "elastic-observability", + "name": "elastic-observability" + }, + "instance": { + "id": "4049989596327614796", + "name": "nchaulet-loadtest-horde-master" + }, + "machine": { + "type": "n1-standard-8" + }, + "provider": "gcp" + }, + "cloud.availability_zone": "us-central1-a", + "cloud.region": "us-central1", + "event": { + "dataset": "gcp.metrics", + "duration": 115000, + "module": "gcp" + }, + "gcp": { + "labels": {}, + "metrics": { + "instance": { + "uptime_total": { + "value": 791820 + } + } + } + }, + "host": { + "id": "4049989596327614796", + "name": "nchaulet-loadtest-horde-master" + }, + "metricset": { + "name": "metrics", + "period": 10000 + }, + "service": { + "type": "gcp" + } +} \ No newline at end of file From 1ed712e4c44c38d4a877e74e9b661252dff8a9ce Mon Sep 17 00:00:00 2001 From: Alex Resnick Date: Thu, 21 Jul 2022 15:22:36 +0000 Subject: [PATCH 2/2] Update docs --- packages/gcp/changelog.yml | 5 ++ packages/gcp/docs/metrics.md | 104 +++++++++++++++++++++++++++++++++++ packages/gcp/manifest.yml | 12 +++- 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 packages/gcp/docs/metrics.md diff --git a/packages/gcp/changelog.yml b/packages/gcp/changelog.yml index 88485e4b160..d5c3577e054 100644 --- a/packages/gcp/changelog.yml +++ b/packages/gcp/changelog.yml @@ -1,4 +1,9 @@ # newer versions go on top +- version: "2.3.0" + changes: + - description: Add GCP Cutom Metricset + type: enhancement + link: https://github.com/elastic/integrations/pull/3794 - version: "2.2.0" changes: - description: Remove fields duplicated in ECS fields diff --git a/packages/gcp/docs/metrics.md b/packages/gcp/docs/metrics.md new file mode 100644 index 00000000000..cba73c8f8f0 --- /dev/null +++ b/packages/gcp/docs/metrics.md @@ -0,0 +1,104 @@ +# Custom Metrics + +Create custom metrics queries for additional data besides the compute, storage, gke, loadbalancing... as shown [here](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-metricset-gcp-metrics.html). + +## Metrics + +This is the `metrics` dataset. + +An example event for `metrics` looks as following: + +```json +{ + "@timestamp": "2017-10-12T08:05:34.853Z", + "cloud": { + "account": { + "id": "elastic-observability", + "name": "elastic-observability" + }, + "instance": { + "id": "4049989596327614796", + "name": "nchaulet-loadtest-horde-master" + }, + "machine": { + "type": "n1-standard-8" + }, + "provider": "gcp" + }, + "cloud.availability_zone": "us-central1-a", + "cloud.region": "us-central1", + "event": { + "dataset": "gcp.metrics", + "duration": 115000, + "module": "gcp" + }, + "gcp": { + "labels": {}, + "metrics": { + "instance": { + "uptime_total": { + "value": 791820 + } + } + } + }, + "host": { + "id": "4049989596327614796", + "name": "nchaulet-loadtest-horde-master" + }, + "metricset": { + "name": "metrics", + "period": 10000 + }, + "service": { + "type": "gcp" + } +} +``` + +**Exported fields** + +| Field | Description | Type | +|---|---|---| +| @timestamp | Event timestamp. | date | +| cloud | Fields related to the cloud or infrastructure the events are coming from. | group | +| cloud.account.id | The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier. | keyword | +| cloud.account.name | The cloud account name or alias used to identify different entities in a multi-tenant environment. Examples: AWS account name, Google Cloud ORG display name. | keyword | +| cloud.availability_zone | Availability zone in which this host, resource, or service is located. | keyword | +| cloud.image.id | Image ID for the cloud instance. | keyword | +| cloud.instance.id | Instance ID of the host machine. | keyword | +| cloud.instance.name | Instance name of the host machine. | keyword | +| cloud.machine.type | Machine type of the host machine. | keyword | +| cloud.project.id | Name of the project in Google Cloud. | keyword | +| cloud.provider | Name of the cloud provider. Example values are aws, azure, gcp, or digitalocean. | keyword | +| cloud.region | Region in which this host is running. | keyword | +| container.id | Unique container id. | keyword | +| container.image.name | Name of the image the container was built on. | keyword | +| container.labels | Image labels. | object | +| container.name | Container name. | keyword | +| data_stream.dataset | Data stream dataset. | constant_keyword | +| data_stream.namespace | Data stream namespace. | constant_keyword | +| data_stream.type | Data stream type. | constant_keyword | +| ecs.version | ECS version this event conforms to. `ecs.version` is a required field and must exist in all events. When querying across multiple indices -- which may conform to slightly different ECS versions -- this field lets integrations adjust to the schema version of the events. | keyword | +| error | These fields can represent errors of any kind. Use them for errors that happen while fetching events or in cases where the event itself contains an error. | group | +| error.message | Error message. | match_only_text | +| event.dataset | Event dataset | constant_keyword | +| event.module | Event module | constant_keyword | +| host.architecture | Operating system architecture. | keyword | +| host.containerized | If the host is a container. | boolean | +| host.domain | Name of the domain of which the host is a member. For example, on Windows this could be the host's Active Directory domain or NetBIOS domain name. For Linux this could be the domain of the host's LDAP provider. | keyword | +| host.hostname | Hostname of the host. It normally contains what the `hostname` command returns on the host machine. | keyword | +| host.id | Unique host id. As hostname is not always unique, use values that are meaningful in your environment. Example: The current usage of `beat.name`. | keyword | +| host.ip | Host ip addresses. | ip | +| host.mac | Host mac addresses. | keyword | +| host.name | Name of the host. It can contain what `hostname` returns on Unix systems, the fully qualified domain name, or a name specified by the user. The sender decides which value to use. | keyword | +| host.os.build | OS build information. | keyword | +| host.os.codename | OS codename, if any. | keyword | +| host.os.family | OS family (such as redhat, debian, freebsd, windows). | keyword | +| host.os.kernel | Operating system kernel version as a raw string. | keyword | +| host.os.name | Operating system name, without the version. | keyword | +| host.os.name.text | Multi-field of `host.os.name`. | text | +| host.os.platform | Operating system platform (such centos, ubuntu, windows). | keyword | +| host.os.version | Operating system version as a raw string. | keyword | +| host.type | Type of host. For Cloud providers this can be the machine type like `t2.medium`. If vm, this could be the container, for example, or other information meaningful in your environment. | keyword | +| service.type | The type of the service data is collected from. The type can be used to group and correlate logs and metrics from one service type. Example: If logs or metrics are collected from Elasticsearch, `service.type` would be `elasticsearch`. | keyword | diff --git a/packages/gcp/manifest.yml b/packages/gcp/manifest.yml index 779b9fb75cd..ada4f0ecdcd 100644 --- a/packages/gcp/manifest.yml +++ b/packages/gcp/manifest.yml @@ -1,6 +1,6 @@ name: gcp title: Google Cloud Platform -version: "2.2.0" +version: "2.3.0" release: ga description: Collect logs from Google Cloud Platform with Elastic Agent. type: integration @@ -133,5 +133,15 @@ policy_templates: title: Collect GCP Firestore Metrics description: Collect GCP Firestore Metrics input_group: metrics + - name: metrics + title: Google Cloud Platform (GCP) Custom metrics + description: Collect Custom metrics from Google Cloud Platform (GCP) with Elastic Agent + data_streams: + - metrics + inputs: + - type: gcp/metrics + title: Collect GCP Custom Metrics + description: Collect GCP Custom Metrics + input_group: metrics owner: github: elastic/security-external-integrations