diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index e36ea3396a9..8a190ac11e2 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -59,6 +59,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Mark system process metricsets as running if metrics are partially available {pull}40565[40565] - Added back `elasticsearch.node.stats.jvm.mem.pools.*` to the `node_stats` metricset {pull}40571[40571] - Add GCP organization and project details to ECS cloud fields. {pull}40461[40461] +- Add support for specifying a custom endpoint for GCP service clients. {issue}40848[40848] {pull}40918[40918] *Osquerybeat* diff --git a/metricbeat/docs/modules/gcp.asciidoc b/metricbeat/docs/modules/gcp.asciidoc index 205ef1a1de6..00c1536e5c0 100644 --- a/metricbeat/docs/modules/gcp.asciidoc +++ b/metricbeat/docs/modules/gcp.asciidoc @@ -52,6 +52,8 @@ and metadata information from metricsets and fetch metrics only. At the moment, * *period*: A single time duration specified for this module collection frequency. +* *endpoint*: A custom endpoint to use for the GCP API calls. If not specified, the default endpoint will be used. + [float] == Example configuration * `compute` metricset is enabled to collect metrics from `us-central1-a` zone @@ -377,6 +379,7 @@ metricbeat.modules: period: 24h project_id: "your project id" credentials_file_path: "your JSON credentials file path" + endpoint: http://your-endpoint dataset_id: "dataset id" table_pattern: "table pattern" ---- diff --git a/x-pack/metricbeat/metricbeat.reference.yml b/x-pack/metricbeat/metricbeat.reference.yml index abf484f473e..aae1d19f48b 100644 --- a/x-pack/metricbeat/metricbeat.reference.yml +++ b/x-pack/metricbeat/metricbeat.reference.yml @@ -641,6 +641,7 @@ metricbeat.modules: period: 24h project_id: "your project id" credentials_file_path: "your JSON credentials file path" + endpoint: http://your-endpoint dataset_id: "dataset id" table_pattern: "table pattern" diff --git a/x-pack/metricbeat/module/gcp/_meta/config.yml b/x-pack/metricbeat/module/gcp/_meta/config.yml index f4e245080ae..ad0c7da852f 100644 --- a/x-pack/metricbeat/module/gcp/_meta/config.yml +++ b/x-pack/metricbeat/module/gcp/_meta/config.yml @@ -67,5 +67,6 @@ period: 24h project_id: "your project id" credentials_file_path: "your JSON credentials file path" + endpoint: http://your-endpoint dataset_id: "dataset id" table_pattern: "table pattern" diff --git a/x-pack/metricbeat/module/gcp/_meta/docs.asciidoc b/x-pack/metricbeat/module/gcp/_meta/docs.asciidoc index a33735c5bd8..80b4ff08358 100644 --- a/x-pack/metricbeat/module/gcp/_meta/docs.asciidoc +++ b/x-pack/metricbeat/module/gcp/_meta/docs.asciidoc @@ -40,6 +40,8 @@ and metadata information from metricsets and fetch metrics only. At the moment, * *period*: A single time duration specified for this module collection frequency. +* *endpoint*: A custom endpoint to use for the GCP API calls. If not specified, the default endpoint will be used. + [float] == Example configuration * `compute` metricset is enabled to collect metrics from `us-central1-a` zone diff --git a/x-pack/metricbeat/module/gcp/metrics/metricset.go b/x-pack/metricbeat/module/gcp/metrics/metricset.go index 604488ab21d..f5b15d68fb3 100644 --- a/x-pack/metricbeat/module/gcp/metrics/metricset.go +++ b/x-pack/metricbeat/module/gcp/metrics/metricset.go @@ -107,6 +107,7 @@ type config struct { ExcludeLabels bool `config:"exclude_labels"` CredentialsFilePath string `config:"credentials_file_path"` CredentialsJSON string `config:"credentials_json"` + Endpoint string `config:"endpoint"` opt []option.ClientOption period *durationpb.Duration @@ -144,6 +145,11 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { return m, fmt.Errorf("no credentials_file_path or credentials_json specified") } + if m.config.Endpoint != "" { + m.Logger().Warnf("You are using a custom endpoint '%s' for the GCP API calls.", m.config.Endpoint) + m.config.opt = append(m.config.opt, option.WithEndpoint(m.config.Endpoint)) + } + m.config.period = &durationpb.Duration{ Seconds: int64(m.Module().Config().Period.Seconds()), } diff --git a/x-pack/metricbeat/modules.d/gcp.yml.disabled b/x-pack/metricbeat/modules.d/gcp.yml.disabled index f79e1607a45..c8cddd198ce 100644 --- a/x-pack/metricbeat/modules.d/gcp.yml.disabled +++ b/x-pack/metricbeat/modules.d/gcp.yml.disabled @@ -70,5 +70,6 @@ period: 24h project_id: "your project id" credentials_file_path: "your JSON credentials file path" + endpoint: http://your-endpoint dataset_id: "dataset id" table_pattern: "table pattern"