Skip to content

Commit 31996ef

Browse files
authored
ES index mode & codec in metricbeat (#49237) (#49469)
Add `mode` and `codec` fields to the elasticsearch.index metricset, sourced from the index /_settings API. Backport of #49237 to 9.2. Supersedes #49317 which had cherry-pick conflicts in CHANGELOG.asciidoc.
1 parent f158659 commit 31996ef

File tree

8 files changed

+73
-2
lines changed

8 files changed

+73
-2
lines changed

CHANGELOG.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ https://github.com/elastic/beats/compare/v9.0.0-rc1\...v9.0.0[View commits]
1717

1818
*Metricbeat*
1919

20+
- Added `mode` and `codec` fields to the `elasticsearch.index` metricset.
2021
- Add a warning log to `metricbeat.vsphere` in case vSphere connection has been configured as insecure. {pull}43104[43104]
2122

2223

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# REQUIRED
2+
# Kind can be one of:
3+
# - breaking-change: a change to previously-documented behavior
4+
# - deprecation: functionality that is being removed in a later release
5+
# - bug-fix: fixes a problem in a previous version
6+
# - enhancement: extends functionality but does not break or fix existing behavior
7+
# - feature: new functionality
8+
# - known-issue: problems that we are aware of in a given version
9+
# - security: impacts on the security of a product or a user's deployment.
10+
# - upgrade: important information for someone upgrading from a prior version
11+
# - other: does not fit into any of the other categories
12+
kind: feature
13+
14+
# REQUIRED for all kinds
15+
# Change summary; a 80ish characters long description of the change.
16+
summary: Addition of Elasticsearch index mode and codec settings in Metricbeat index stats module.
17+
18+
# REQUIRED for breaking-change, deprecation, known-issue
19+
# Long description; in case the summary is not enough to describe the change
20+
# this field accommodate a description without length limits.
21+
# description:
22+
23+
# REQUIRED for breaking-change, deprecation, known-issue
24+
# impact:
25+
26+
# REQUIRED for breaking-change, deprecation, known-issue
27+
# action:
28+
29+
# REQUIRED for all kinds
30+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
31+
component: metricbeat
32+
33+
# AUTOMATED
34+
# OPTIONAL to manually add other PR URLs
35+
# PR URL: A link the PR that added the changeset.
36+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
37+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
38+
# Please provide it if you are adding a fragment for a different PR.
39+
# pr: https://github.com/owner/repo/1234
40+
41+
# AUTOMATED
42+
# OPTIONAL to manually add other issue URLs
43+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
44+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
45+
# issue: https://github.com/owner/repo/1234

docs/reference/metricbeat/exported-fields-elasticsearch.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,14 @@ index
13701370
: type: keyword
13711371

13721372

1373+
**`elasticsearch.index.mode`**
1374+
: type: keyword
1375+
1376+
1377+
**`elasticsearch.index.codec`**
1378+
: type: keyword
1379+
1380+
13731381
**`elasticsearch.index.name`**
13741382
: Index name.
13751383

docs/reference/metricbeat/metricbeat-metricset-elasticsearch-index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ Here is an example document generated by this metricset:
170170
"tier_preference": "data_content",
171171
"creation_date": 1731657995821,
172172
"version": "8505000",
173+
"mode": "time_series",
174+
"codec": "default",
173175
"hidden": true,
174176
"shards": {
175177
"total": 1,

metricbeat/module/elasticsearch/fields.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

metricbeat/module/elasticsearch/index/_meta/data.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@
147147
"tier_preference": "data_content",
148148
"creation_date": 1731657995821,
149149
"version": "8505000",
150+
"mode": "time_series",
151+
"codec": "default",
150152
"hidden": true,
151153
"shards": {
152154
"total": 1,

metricbeat/module/elasticsearch/index/_meta/fields.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
type: date
2424
- name: version
2525
type: keyword
26+
- name: mode
27+
type: keyword
28+
- name: codec
29+
type: keyword
2630
- name: name
2731
type: keyword
2832
description: >

metricbeat/module/elasticsearch/index/data.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ type Index struct {
4545
TierPreference string `json:"tier_preference,omitempty"`
4646
CreationDate string `json:"creation_date,omitempty"`
4747
Version string `json:"version,omitempty"`
48+
Mode string `json:"mode,omitempty"`
49+
Codec string `json:"codec,omitempty"`
4850
Shards shardStats `json:"shards"`
4951
}
5052

@@ -196,7 +198,7 @@ func eventsMapping(
196198
}
197199

198200
indicesSettingsPattern := "*,-.*"
199-
indicesSettingsFilterPaths := []string{"*.settings.index.creation_date", "*.settings.index.**._tier_preference", "*.settings.index.version.created"}
201+
indicesSettingsFilterPaths := []string{"*.settings.index.creation_date", "*.settings.index.**._tier_preference", "*.settings.index.version.created", "*.settings.index.mode", "*.settings.index.codec"}
200202
indicesSettings, err := elasticsearch.GetIndexSettings(httpClient, httpClient.GetURI(), indicesSettingsPattern, indicesSettingsFilterPaths)
201203
if err != nil {
202204
return fmt.Errorf("failure retrieving index settings from Elasticsearch: %w", err)
@@ -336,6 +338,13 @@ func addIndexSettings(idx *Index, indicesSettings mapstr.M) error {
336338

337339
idx.Version = indexVersion
338340

341+
if indexMode, err := getIndexSettingForIndex(indexSettings, idx.Index, "index.mode"); err == nil {
342+
idx.Mode = indexMode
343+
}
344+
if indexCodec, err := getIndexSettingForIndex(indexSettings, idx.Index, "index.codec"); err == nil {
345+
idx.Codec = indexCodec
346+
}
347+
339348
return nil
340349
}
341350

0 commit comments

Comments
 (0)