Skip to content

Commit ac0ef8c

Browse files
authored
libbeat: monitor version (#26214) (#26222)
(cherry picked from commit 383f689)
1 parent 910f67f commit ac0ef8c

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
438438
- Add new option `suffix` to `logging.files` to control how log files are rotated. {pull}25464[25464]
439439
- Validate that required functionality in Elasticsearch is available upon initial connection. {pull}25351[25351]
440440
- Improve ES output error insights. {pull}25825[25825]
441+
- Libbeat: report beat version to monitoring. {pull}26214[26214]
441442

442443
*Auditbeat*
443444

libbeat/cmd/instance/metrics/metrics_common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/elastic/beats/v7/libbeat/logp"
2626
"github.com/elastic/beats/v7/libbeat/monitoring"
2727
"github.com/elastic/beats/v7/libbeat/monitoring/report/log"
28+
"github.com/elastic/beats/v7/libbeat/version"
2829
)
2930

3031
var (
@@ -59,4 +60,5 @@ func reportInfo(_ monitoring.Mode, V monitoring.Visitor) {
5960
})
6061

6162
monitoring.ReportString(V, "ephemeral_id", ephemeralID.String())
63+
monitoring.ReportString(V, "version", version.GetDefaultVersion())
6264
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package metrics
19+
20+
import (
21+
"testing"
22+
23+
"github.com/stretchr/testify/assert"
24+
25+
"github.com/elastic/beats/v7/libbeat/monitoring"
26+
"github.com/elastic/beats/v7/libbeat/version"
27+
)
28+
29+
func TestMonitoring(t *testing.T) {
30+
metrics := monitoring.Default.GetRegistry("beat")
31+
metricsSnapshot := monitoring.CollectFlatSnapshot(metrics, monitoring.Full, true)
32+
assert.Equal(t, version.GetDefaultVersion(), metricsSnapshot.Strings["info.version"])
33+
}

libbeat/monitoring/report/log/log.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ var gauges = map[string]bool{
6666
// TODO: Change this when gauges are refactored, too.
6767
var strConsts = map[string]bool{
6868
"beat.info.ephemeral_id": true,
69+
"beat.info.version": true,
6970
}
7071

7172
var (

0 commit comments

Comments
 (0)