diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 984ad7cce62..e73ad626cd8 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -695,6 +695,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Collect linked account information in AWS billing. {pull}26285[26285] - Add total CPU to vSphere virtual machine metrics. {pull}26167[26167] - Add AWS Kinesis metricset. {pull}25989[25989] +- Move openmetrics module to oss. {pull}26561[26561] *Packetbeat* diff --git a/Jenkinsfile b/Jenkinsfile index 2c50681d4fc..a540a8647b5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -743,6 +743,9 @@ def getCommonModuleInTheChangeSet(String directory) { def exclude = "^(${directoryExclussion}|((?!\\/module\\/).)*\$|.*\\.asciidoc|.*\\.png)" dir("${env.BASE_DIR}") { module = getGitMatchingGroup(pattern: pattern, exclude: exclude) + if(!fileExists("${directory}/module/${module}")) { + module = '' + } } return module } diff --git a/metricbeat/docs/modules/openmetrics.asciidoc b/metricbeat/docs/modules/openmetrics.asciidoc index 4ef66ff3746..6350b77a617 100644 --- a/metricbeat/docs/modules/openmetrics.asciidoc +++ b/metricbeat/docs/modules/openmetrics.asciidoc @@ -3,7 +3,6 @@ This file is generated! See scripts/mage/docs_collector.go //// [[metricbeat-module-openmetrics]] -[role="xpack"] == Openmetrics module beta[] diff --git a/metricbeat/docs/modules/openmetrics/collector.asciidoc b/metricbeat/docs/modules/openmetrics/collector.asciidoc index 1a18fb93e6c..06000e77291 100644 --- a/metricbeat/docs/modules/openmetrics/collector.asciidoc +++ b/metricbeat/docs/modules/openmetrics/collector.asciidoc @@ -3,12 +3,11 @@ This file is generated! See scripts/mage/docs_collector.go //// [[metricbeat-metricset-openmetrics-collector]] -[role="xpack"] === Openmetrics collector metricset beta[] -include::../../../../x-pack/metricbeat/module/openmetrics/collector/_meta/docs.asciidoc[] +include::../../../module/openmetrics/collector/_meta/docs.asciidoc[] ==== Fields @@ -20,5 +19,5 @@ Here is an example document generated by this metricset: [source,json] ---- -include::../../../../x-pack/metricbeat/module/openmetrics/collector/_meta/data.json[] +include::../../../module/openmetrics/collector/_meta/data.json[] ---- diff --git a/metricbeat/include/list_common.go b/metricbeat/include/list_common.go index a98e7d2ed87..bda9f32f604 100644 --- a/metricbeat/include/list_common.go +++ b/metricbeat/include/list_common.go @@ -125,6 +125,8 @@ import ( _ "github.com/elastic/beats/v7/metricbeat/module/nats/subscriptions" _ "github.com/elastic/beats/v7/metricbeat/module/nginx" _ "github.com/elastic/beats/v7/metricbeat/module/nginx/stubstatus" + _ "github.com/elastic/beats/v7/metricbeat/module/openmetrics" + _ "github.com/elastic/beats/v7/metricbeat/module/openmetrics/collector" _ "github.com/elastic/beats/v7/metricbeat/module/php_fpm" _ "github.com/elastic/beats/v7/metricbeat/module/php_fpm/pool" _ "github.com/elastic/beats/v7/metricbeat/module/php_fpm/process" diff --git a/metricbeat/metricbeat.reference.yml b/metricbeat/metricbeat.reference.yml index 38829f4c308..cb35fb2bd46 100644 --- a/metricbeat/metricbeat.reference.yml +++ b/metricbeat/metricbeat.reference.yml @@ -716,6 +716,19 @@ metricbeat.modules: # Path to server status. Default nginx_status server_status_path: "nginx_status" +#----------------------------- Openmetrics Module ----------------------------- +- module: openmetrics + metricsets: ['collector'] + period: 10s + hosts: ['localhost:9090'] + + # This module uses the Prometheus collector metricset, all + # the options for this metricset are also available here. + metrics_path: /metrics + metrics_filters: + include: [] + exclude: [] + #------------------------------- PHP_FPM Module ------------------------------- - module: php_fpm metricsets: diff --git a/x-pack/metricbeat/module/openmetrics/_meta/Dockerfile b/metricbeat/module/openmetrics/_meta/Dockerfile similarity index 100% rename from x-pack/metricbeat/module/openmetrics/_meta/Dockerfile rename to metricbeat/module/openmetrics/_meta/Dockerfile diff --git a/x-pack/metricbeat/module/openmetrics/_meta/config.yml b/metricbeat/module/openmetrics/_meta/config.yml similarity index 100% rename from x-pack/metricbeat/module/openmetrics/_meta/config.yml rename to metricbeat/module/openmetrics/_meta/config.yml diff --git a/x-pack/metricbeat/module/openmetrics/_meta/docs.asciidoc b/metricbeat/module/openmetrics/_meta/docs.asciidoc similarity index 100% rename from x-pack/metricbeat/module/openmetrics/_meta/docs.asciidoc rename to metricbeat/module/openmetrics/_meta/docs.asciidoc diff --git a/x-pack/metricbeat/module/openmetrics/_meta/fields.yml b/metricbeat/module/openmetrics/_meta/fields.yml similarity index 100% rename from x-pack/metricbeat/module/openmetrics/_meta/fields.yml rename to metricbeat/module/openmetrics/_meta/fields.yml diff --git a/x-pack/metricbeat/module/openmetrics/collector/_meta/data.json b/metricbeat/module/openmetrics/collector/_meta/data.json similarity index 100% rename from x-pack/metricbeat/module/openmetrics/collector/_meta/data.json rename to metricbeat/module/openmetrics/collector/_meta/data.json diff --git a/x-pack/metricbeat/module/openmetrics/collector/_meta/docs.asciidoc b/metricbeat/module/openmetrics/collector/_meta/docs.asciidoc similarity index 100% rename from x-pack/metricbeat/module/openmetrics/collector/_meta/docs.asciidoc rename to metricbeat/module/openmetrics/collector/_meta/docs.asciidoc diff --git a/x-pack/metricbeat/module/openmetrics/collector/_meta/fields.yml b/metricbeat/module/openmetrics/collector/_meta/fields.yml similarity index 100% rename from x-pack/metricbeat/module/openmetrics/collector/_meta/fields.yml rename to metricbeat/module/openmetrics/collector/_meta/fields.yml diff --git a/x-pack/metricbeat/module/openmetrics/collector/_meta/testdata/config.yml b/metricbeat/module/openmetrics/collector/_meta/testdata/config.yml similarity index 100% rename from x-pack/metricbeat/module/openmetrics/collector/_meta/testdata/config.yml rename to metricbeat/module/openmetrics/collector/_meta/testdata/config.yml diff --git a/x-pack/metricbeat/module/openmetrics/collector/_meta/testdata/docs.plain b/metricbeat/module/openmetrics/collector/_meta/testdata/docs.plain similarity index 100% rename from x-pack/metricbeat/module/openmetrics/collector/_meta/testdata/docs.plain rename to metricbeat/module/openmetrics/collector/_meta/testdata/docs.plain diff --git a/x-pack/metricbeat/module/openmetrics/collector/_meta/testdata/docs.plain-expected.json b/metricbeat/module/openmetrics/collector/_meta/testdata/docs.plain-expected.json similarity index 100% rename from x-pack/metricbeat/module/openmetrics/collector/_meta/testdata/docs.plain-expected.json rename to metricbeat/module/openmetrics/collector/_meta/testdata/docs.plain-expected.json diff --git a/metricbeat/module/openmetrics/collector/collector.go b/metricbeat/module/openmetrics/collector/collector.go new file mode 100644 index 00000000000..6ce25dc9068 --- /dev/null +++ b/metricbeat/module/openmetrics/collector/collector.go @@ -0,0 +1,42 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package collector + +import ( + "github.com/elastic/beats/v7/metricbeat/mb" + "github.com/elastic/beats/v7/metricbeat/mb/parse" + "github.com/elastic/beats/v7/metricbeat/module/prometheus/collector" +) + +const ( + defaultScheme = "http" + defaultPath = "/metrics" +) + +var ( + hostParser = parse.URLHostParserBuilder{ + DefaultScheme: defaultScheme, + DefaultPath: defaultPath, + }.Build() +) + +func init() { + mb.Registry.MustAddMetricSet("openmetrics", "collector", + collector.MetricSetBuilder("openmetrics", collector.DefaultPromEventsGeneratorFactory), + mb.WithHostParser(hostParser)) +} diff --git a/metricbeat/module/openmetrics/collector/collector_test.go b/metricbeat/module/openmetrics/collector/collector_test.go new file mode 100644 index 00000000000..072755f3f75 --- /dev/null +++ b/metricbeat/module/openmetrics/collector/collector_test.go @@ -0,0 +1,32 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// +build !integration + +package collector + +import ( + "testing" + + mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing" + + _ "github.com/elastic/beats/v7/metricbeat/module/openmetrics" +) + +func TestData(t *testing.T) { + mbtest.TestDataFiles(t, "openmetrics", "collector") +} diff --git a/x-pack/metricbeat/module/openmetrics/docker-compose.yml b/metricbeat/module/openmetrics/docker-compose.yml similarity index 100% rename from x-pack/metricbeat/module/openmetrics/docker-compose.yml rename to metricbeat/module/openmetrics/docker-compose.yml diff --git a/x-pack/metricbeat/module/openmetrics/fields.go b/metricbeat/module/openmetrics/fields.go similarity index 51% rename from x-pack/metricbeat/module/openmetrics/fields.go rename to metricbeat/module/openmetrics/fields.go index 3440f8c732f..213a9974223 100644 --- a/x-pack/metricbeat/module/openmetrics/fields.go +++ b/metricbeat/module/openmetrics/fields.go @@ -1,6 +1,19 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // Code generated by beats/dev-tools/cmd/asset/asset.go - DO NOT EDIT. diff --git a/x-pack/metricbeat/module/openmetrics/test_openmetrics.py b/metricbeat/module/openmetrics/test_openmetrics.py similarity index 88% rename from x-pack/metricbeat/module/openmetrics/test_openmetrics.py rename to metricbeat/module/openmetrics/test_openmetrics.py index d2b9c3ba14b..bd0623ea0b1 100644 --- a/x-pack/metricbeat/module/openmetrics/test_openmetrics.py +++ b/metricbeat/module/openmetrics/test_openmetrics.py @@ -1,10 +1,10 @@ +import metricbeat import os import sys import unittest -from xpack_metricbeat import XPackTest, metricbeat -class Test(XPackTest): +class Test(metricbeat.BaseTest): COMPOSE_SERVICES = ['openmetrics-node_exporter'] @@ -19,7 +19,7 @@ def test_openmetrics(self): "hosts": self.get_hosts(), "period": "5s", }]) - proc = self.start_beat(home=self.beat_path) + proc = self.start_beat() self.wait_until(lambda: self.output_lines() > 0, 60) proc.check_kill_and_wait() self.assert_no_logged_warnings() diff --git a/x-pack/metricbeat/modules.d/openmetrics.yml.disabled b/metricbeat/modules.d/openmetrics.yml.disabled similarity index 100% rename from x-pack/metricbeat/modules.d/openmetrics.yml.disabled rename to metricbeat/modules.d/openmetrics.yml.disabled diff --git a/x-pack/metricbeat/include/list.go b/x-pack/metricbeat/include/list.go index 856c3357746..02ddf9f5648 100644 --- a/x-pack/metricbeat/include/list.go +++ b/x-pack/metricbeat/include/list.go @@ -43,8 +43,6 @@ import ( _ "github.com/elastic/beats/v7/x-pack/metricbeat/module/mssql" _ "github.com/elastic/beats/v7/x-pack/metricbeat/module/mssql/performance" _ "github.com/elastic/beats/v7/x-pack/metricbeat/module/mssql/transaction_log" - _ "github.com/elastic/beats/v7/x-pack/metricbeat/module/openmetrics" - _ "github.com/elastic/beats/v7/x-pack/metricbeat/module/openmetrics/collector" _ "github.com/elastic/beats/v7/x-pack/metricbeat/module/oracle" _ "github.com/elastic/beats/v7/x-pack/metricbeat/module/oracle/performance" _ "github.com/elastic/beats/v7/x-pack/metricbeat/module/oracle/tablespace" diff --git a/x-pack/metricbeat/metricbeat.reference.yml b/x-pack/metricbeat/metricbeat.reference.yml index 783ff3ce302..840851483e9 100644 --- a/x-pack/metricbeat/metricbeat.reference.yml +++ b/x-pack/metricbeat/metricbeat.reference.yml @@ -1144,9 +1144,11 @@ metricbeat.modules: # Password to use when connecting to PostgreSQL. Empty by default. #password: pass -#----------------------- Prometheus Typed Metrics Module ----------------------- +#------------------------------ Prometheus Module ------------------------------ +# Metrics collected from a Prometheus endpoint - module: prometheus period: 10s + metricsets: ["collector"] hosts: ["localhost:9090"] metrics_path: /metrics #metrics_filters: @@ -1160,12 +1162,6 @@ metricbeat.modules: #ssl.certificate_authorities: # - /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - # Use Elasticsearch histogram type to store histograms (beta, default: false) - # This will change the default layout and put metric type in the field name - #use_types: true - - # Store counter rates instead of original cumulative counters (experimental, default: false) - #rate_counters: true # Metrics sent by a Prometheus server using remote_write option #- module: prometheus @@ -1177,18 +1173,6 @@ metricbeat.modules: #ssl.certificate: "/etc/pki/server/cert.pem" #ssl.key: "/etc/pki/server/cert.key" - # Use Elasticsearch histogram type to store histograms (beta, default: false) - # This will change the default layout and put metric type in the field name - #use_types: true - - # Store counter rates instead of original cumulative counters (experimental, default: false) - #rate_counters: true - - # Define patterns for counter and histogram types so as to identify metrics' types according to these patterns - #types_patterns: - # counter_patterns: [] - # histogram_patterns: [] - # Metrics that will be collected using a PromQL #- module: prometheus # metricsets: ["query"] @@ -1215,11 +1199,9 @@ metricbeat.modules: # params: # query: "some_value" -#------------------------------ Prometheus Module ------------------------------ -# Metrics collected from a Prometheus endpoint +#----------------------- Prometheus Typed Metrics Module ----------------------- - module: prometheus period: 10s - metricsets: ["collector"] hosts: ["localhost:9090"] metrics_path: /metrics #metrics_filters: @@ -1233,6 +1215,12 @@ metricbeat.modules: #ssl.certificate_authorities: # - /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt + # Use Elasticsearch histogram type to store histograms (beta, default: false) + # This will change the default layout and put metric type in the field name + #use_types: true + + # Store counter rates instead of original cumulative counters (experimental, default: false) + #rate_counters: true # Metrics sent by a Prometheus server using remote_write option #- module: prometheus @@ -1244,6 +1232,18 @@ metricbeat.modules: #ssl.certificate: "/etc/pki/server/cert.pem" #ssl.key: "/etc/pki/server/cert.key" + # Use Elasticsearch histogram type to store histograms (beta, default: false) + # This will change the default layout and put metric type in the field name + #use_types: true + + # Store counter rates instead of original cumulative counters (experimental, default: false) + #rate_counters: true + + # Define patterns for counter and histogram types so as to identify metrics' types according to these patterns + #types_patterns: + # counter_patterns: [] + # histogram_patterns: [] + # Metrics that will be collected using a PromQL #- module: prometheus # metricsets: ["query"] diff --git a/x-pack/metricbeat/module/openmetrics/collector/collector.go b/x-pack/metricbeat/module/openmetrics/collector/collector.go deleted file mode 100644 index 362260ded07..00000000000 --- a/x-pack/metricbeat/module/openmetrics/collector/collector.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package collector - -import ( - "github.com/elastic/beats/v7/metricbeat/mb" - "github.com/elastic/beats/v7/metricbeat/mb/parse" - "github.com/elastic/beats/v7/metricbeat/module/prometheus/collector" -) - -const ( - defaultScheme = "http" - defaultPath = "/metrics" -) - -var ( - hostParser = parse.URLHostParserBuilder{ - DefaultScheme: defaultScheme, - DefaultPath: defaultPath, - }.Build() -) - -func init() { - mb.Registry.MustAddMetricSet("openmetrics", "collector", - collector.MetricSetBuilder("openmetrics", collector.DefaultPromEventsGeneratorFactory), - mb.WithHostParser(hostParser)) -} diff --git a/x-pack/metricbeat/module/openmetrics/collector/collector_test.go b/x-pack/metricbeat/module/openmetrics/collector/collector_test.go deleted file mode 100644 index f0e99315dba..00000000000 --- a/x-pack/metricbeat/module/openmetrics/collector/collector_test.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -// +build !integration - -package collector - -import ( - "testing" - - mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing" - - _ "github.com/elastic/beats/v7/x-pack/metricbeat/module/openmetrics" -) - -func TestData(t *testing.T) { - mbtest.TestDataFiles(t, "openmetrics", "collector") -}