diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 72cbf1aaa2c..e99c6a1d697 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -693,6 +693,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 24894f54f68..f77dfede971 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/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") -}