Skip to content

Commit

Permalink
libbeat: monitor version (#26214) (#26222)
Browse files Browse the repository at this point in the history
(cherry picked from commit 383f689)
  • Loading branch information
mergify[bot] authored Jun 9, 2021
1 parent 910f67f commit ac0ef8c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add new option `suffix` to `logging.files` to control how log files are rotated. {pull}25464[25464]
- Validate that required functionality in Elasticsearch is available upon initial connection. {pull}25351[25351]
- Improve ES output error insights. {pull}25825[25825]
- Libbeat: report beat version to monitoring. {pull}26214[26214]

*Auditbeat*

Expand Down
2 changes: 2 additions & 0 deletions libbeat/cmd/instance/metrics/metrics_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/monitoring"
"github.com/elastic/beats/v7/libbeat/monitoring/report/log"
"github.com/elastic/beats/v7/libbeat/version"
)

var (
Expand Down Expand Up @@ -59,4 +60,5 @@ func reportInfo(_ monitoring.Mode, V monitoring.Visitor) {
})

monitoring.ReportString(V, "ephemeral_id", ephemeralID.String())
monitoring.ReportString(V, "version", version.GetDefaultVersion())
}
33 changes: 33 additions & 0 deletions libbeat/cmd/instance/metrics/metrics_common_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 metrics

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/elastic/beats/v7/libbeat/monitoring"
"github.com/elastic/beats/v7/libbeat/version"
)

func TestMonitoring(t *testing.T) {
metrics := monitoring.Default.GetRegistry("beat")
metricsSnapshot := monitoring.CollectFlatSnapshot(metrics, monitoring.Full, true)
assert.Equal(t, version.GetDefaultVersion(), metricsSnapshot.Strings["info.version"])
}
1 change: 1 addition & 0 deletions libbeat/monitoring/report/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var gauges = map[string]bool{
// TODO: Change this when gauges are refactored, too.
var strConsts = map[string]bool{
"beat.info.ephemeral_id": true,
"beat.info.version": true,
}

var (
Expand Down

0 comments on commit ac0ef8c

Please sign in to comment.