diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 939523e41009..9bd1c7d16ec5 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -405,6 +405,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Add support for region/zone for Vertex AI service in GCP module {pull}41551[41551] - Add support for location label as an optional configuration parameter in GCP metrics metricset. {issue}41550[41550] {pull}41626[41626] - Add support for podman metrics in docker module. {pull}41889[41889] +- Added `tier_preference`, `creation_date` and `version` fields to the `elasticsearch.index` metricset. {pull}41944[41944] *Metricbeat* - Add benchmark module {pull}41801[41801] diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 5f9ee24aa8c0..967c20f14cfa 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -32161,6 +32161,27 @@ type: keyword -- +*`elasticsearch.index.tier_preference`*:: ++ +-- +type: keyword + +-- + +*`elasticsearch.index.creation_date`*:: ++ +-- +type: date + +-- + +*`elasticsearch.index.version`*:: ++ +-- +type: keyword + +-- + *`elasticsearch.index.name`*:: + -- diff --git a/metricbeat/module/elasticsearch/cluster_stats/data.go b/metricbeat/module/elasticsearch/cluster_stats/data.go index 4fe1d03f6d73..cfd89ce46c03 100644 --- a/metricbeat/module/elasticsearch/cluster_stats/data.go +++ b/metricbeat/module/elasticsearch/cluster_stats/data.go @@ -231,7 +231,7 @@ func eventMapping(r mb.ReporterV2, httpClient *helper.HTTP, info elasticsearch.I } clusterStateMetrics := []string{"version", "master_node", "nodes", "routing_table"} - clusterState, err := elasticsearch.GetClusterState(httpClient, httpClient.GetURI(), clusterStateMetrics) + clusterState, err := elasticsearch.GetClusterState(httpClient, httpClient.GetURI(), clusterStateMetrics, []string{}) if err != nil { return fmt.Errorf("failed to get cluster state from Elasticsearch: %w", err) } diff --git a/metricbeat/module/elasticsearch/elasticsearch.go b/metricbeat/module/elasticsearch/elasticsearch.go index 446a2d128bbf..7e9f22152342 100644 --- a/metricbeat/module/elasticsearch/elasticsearch.go +++ b/metricbeat/module/elasticsearch/elasticsearch.go @@ -288,13 +288,21 @@ func GetLicense(http *helper.HTTP, resetURI string) (*License, error) { } // GetClusterState returns cluster state information. -func GetClusterState(http *helper.HTTP, resetURI string, metrics []string) (mapstr.M, error) { +func GetClusterState(http *helper.HTTP, resetURI string, metrics []string, filterPaths []string) (mapstr.M, error) { + queryParams := []string{"local=true"} clusterStateURI := "_cluster/state" if len(metrics) > 0 { clusterStateURI += "/" + strings.Join(metrics, ",") } - content, err := fetchPath(http, resetURI, clusterStateURI, "local=true") + if len(filterPaths) > 0 { + filterPathQueryParam := "filter_path=" + strings.Join(filterPaths, ",") + queryParams = append(queryParams, filterPathQueryParam) + } + + queryString := strings.Join(queryParams, "&") + + content, err := fetchPath(http, resetURI, clusterStateURI, queryString) if err != nil { return nil, err } @@ -304,6 +312,28 @@ func GetClusterState(http *helper.HTTP, resetURI string, metrics []string) (maps return clusterState, err } +func GetIndexSettings(http *helper.HTTP, resetURI string, indexPattern string, filterPaths []string) (mapstr.M, error) { + + queryParams := []string{"local=true", "expand_wildcards=hidden,all"} + indicesSettingsURI := indexPattern + "/_settings" + + if len(filterPaths) > 0 { + filterPathQueryParam := "filter_path=" + strings.Join(filterPaths, ",") + queryParams = append(queryParams, filterPathQueryParam) + } + + queryString := strings.Join(queryParams, "&") + + content, err := fetchPath(http, resetURI, indicesSettingsURI, queryString) + if err != nil { + return nil, err + } + + var indicesSettings map[string]interface{} + err = json.Unmarshal(content, &indicesSettings) + return indicesSettings, err +} + // GetClusterSettingsWithDefaults returns cluster settings. func GetClusterSettingsWithDefaults(http *helper.HTTP, resetURI string, filterPaths []string) (mapstr.M, error) { return GetClusterSettings(http, resetURI, true, filterPaths) diff --git a/metricbeat/module/elasticsearch/fields.go b/metricbeat/module/elasticsearch/fields.go index 7fe1827b3ceb..5f899fdd0aac 100644 --- a/metricbeat/module/elasticsearch/fields.go +++ b/metricbeat/module/elasticsearch/fields.go @@ -32,5 +32,5 @@ func init() { // AssetElasticsearch returns asset data. // This is the base64 encoded zlib format compressed contents of module/elasticsearch. func AssetElasticsearch() string { - return "eJzsfV2P3biR9r1/BeGrCWDrRW6NYPIC2WTXC4wxyEz2ZrFQ2BLPObQlUSapdvf++oVIfZASPyVKfey0b5Lpbj31VPGrWCwW34Mv6PkDQBVkHBcMQVrc3gDAMa/QB/D2r+rP374BoESsoLjlmDQfwM9vAABA+xtQk7Kr0BsAKKoQZOgDuMI3ADDEOW6u7AP477eMVW/fgbc3ztu3/9P/7kYozwvSXPD1A7jAivXfXzCqSvZBiHgPGlijD6CoOsYRzUe0bPhBViMOS8hhVmLWVvA57/9efAoAf27Rh17Nb4SWGhxuSvSUU1SQR0SftT+/UtK1w09UJurn7AZpyTLGIeU5xzXKcZPXuKowm/52xIMVhupPW8hvC7Nngk420lFws5rZhZP2ENkDrEM0JxxWB8iecUfhk2AOiy8545Cz6MaCbZ1dSNeUmyiO/UzIzgSPbI04ynpq+98XBc1QAx8qlE6mHXktGz5CXPV/dIB0HXuUXeECNQzFDyQOebet7+g0BwLZAnCU08MmlDLBaQMjWvuW4hpO008cMSExWyKodt2msMTVv9dmzR0DXZmaZ9CGlNuY9h9meD0O1LbYonvT1Q+ImlefTRMQbkpcoHUvV781fa8xIF3Dtd/YFLMpp/fkgZOcco0S1bn+AMEDvK6X2icS2Cs5ecErW7fFKPXzY22UtmRuY69i1fAp71rrIutXJ0alz491NgtUl/4VLVRnNwTbvGOo7Jk9PHN0MDFUE/ospGa91MwscsWwV+h0gjV8UviZJpD4VVJIym+Q3dIs6BxlBshR2iOiDJMmmagl3tzBhUk2z/8mWSZMbU3Muw4ncsq49DYWkMk9GwVo8mZwjRiHdfvGBi1h3/7/6S/fGrujwtyGYaaG9e0UIx0tkGr28M69uUFs67/mZUQDTl9Pczp5kOt+1v+/SHvVVf/V0lwz5IVQVEDG2fDf6oIVJcEOpG95N3swmuMX6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kZp4VVNIT+dPQb430gBqHluOJQWMd7GOy3Qx2DXfbsQWWNLnnIIRI+OHFv5x8gq8LxZicIuGjLAeXIMtIjZRsAeDRBvrsvq9pCeUFCcp/jxmvxxmTg8l3HDxSW9FBSvzTFSNPGIsHDVLc4ynrQNvkKyt5yz3pZupi62MxmXJvnaUo4T7ZUFT8ZocRPEiWSj7kNfFQgFrhvI0xoYobl7MHjqgxZJhkopgKNEKBKMfccTfn5senw3ohVntEhd7epKrZ+jFqS0pGJvw5RDczvmMkU5q9tkHZS2BKN9gtD81q0eaU1pvBI/h+WCfm2h1V/HmcvwqMT9GTLuGF4e3ueFsgxS8ZrRv4bCVzBn0P1Qitrv6P5Qqh6bhXJfugp/9sdVdZkvl9YMmqZlsW+eHuPSyjsRSUbLB1JBnmaUspxUmHea4CpP+1L0p+UWiG37IFS2y/anU7ZLPlVd1egvoPNM/KmKM6gLkuEX0HmQfHI738kom4b9+S0/yH4hlU9u+EEsLk4LRsq+dqJAsZE76PnL0Y7y4mRSQ5V3g4bjRt3v6FdCS8D5nzrAf4qdLiZVgzDqf4G6X6hI6qnTlsubDTCeikIyWgchvLzBRwGJ1pDTZpZQRrj+nZpweb/q4EbHVjy6oJW04xGHBP2NMgRPuKyLTqGWvy9xXS9vJ8yiLaRKpX/o+3iRu44EKcWlFwG76qEiz3pPlxQAfefZ1ccOe5ZIXJkhjSxz5H6iSF7PimX8WREPwcT+OlLMgjWdcAHpI5tBQTO5tIsr5lXc52tu/ZMmoiSr6DLfcDMIhRxdGC39iEV9c8iLFvrI0Q3LDgRPOOOowSUgkZyP+A1XWuOJm1gZLWvMyQMpCH9Gdctq2phSAOQklC5Kp6BdmzBNK7pMpoQl25Wt1x//XwAAAP//ZUDXrg==" } diff --git a/metricbeat/module/elasticsearch/index/_meta/data.json b/metricbeat/module/elasticsearch/index/_meta/data.json index 2fa8eeb4f18f..3b0dee2f9e24 100644 --- a/metricbeat/module/elasticsearch/index/_meta/data.json +++ b/metricbeat/module/elasticsearch/index/_meta/data.json @@ -144,6 +144,9 @@ } }, "status": "green", + "tier_preference": "data_content", + "creation_date": 1731657995821, + "version": "8505000", "hidden": true, "shards": { "total": 1, diff --git a/metricbeat/module/elasticsearch/index/_meta/fields.yml b/metricbeat/module/elasticsearch/index/_meta/fields.yml index 8182963959b3..ca1fdecff8d2 100644 --- a/metricbeat/module/elasticsearch/index/_meta/fields.yml +++ b/metricbeat/module/elasticsearch/index/_meta/fields.yml @@ -17,6 +17,12 @@ type: keyword - name: status type: keyword + - name: tier_preference + type: keyword + - name: creation_date + type: date + - name: version + type: keyword - name: name type: keyword description: > diff --git a/metricbeat/module/elasticsearch/index/data.go b/metricbeat/module/elasticsearch/index/data.go index d8bec4939d62..ce5fa82e4ac3 100644 --- a/metricbeat/module/elasticsearch/index/data.go +++ b/metricbeat/module/elasticsearch/index/data.go @@ -20,6 +20,7 @@ package index import ( "encoding/json" "fmt" + "strconv" "github.com/joeshaw/multierror" @@ -40,9 +41,12 @@ type Index struct { Primaries primaries `json:"primaries"` Total total `json:"total"` - Index string `json:"index"` - Status string `json:"status"` - Shards shardStats `json:"shards"` + Index string `json:"index"` + Status string `json:"status"` + TierPreference string `json:"tier_preference"` + CreationDate int `json:"creation_date"` + Version string `json:"version"` + Shards shardStats `json:"shards"` } type primaries struct { @@ -180,11 +184,19 @@ type bulkStats struct { func eventsMapping(r mb.ReporterV2, httpClient *helper.HTTP, info elasticsearch.Info, content []byte, isXpack bool) error { clusterStateMetrics := []string{"routing_table"} - clusterState, err := elasticsearch.GetClusterState(httpClient, httpClient.GetURI(), clusterStateMetrics) + clusterStateFilterPaths := []string{"routing_table"} + clusterState, err := elasticsearch.GetClusterState(httpClient, httpClient.GetURI(), clusterStateMetrics, clusterStateFilterPaths) if err != nil { return fmt.Errorf("failure retrieving cluster state from Elasticsearch: %w", err) } + indicesSettingsPattern := "*,.*" + indicesSettingsFilterPaths := []string{"*.settings.index.creation_date", "*.settings.index.**._tier_preference", "*.settings.index.version.created"} + indicesSettings, err := elasticsearch.GetIndexSettings(httpClient, httpClient.GetURI(), indicesSettingsPattern, indicesSettingsFilterPaths) + if err != nil { + return fmt.Errorf("failure retrieving index settings from Elasticsearch: %w", err) + } + var indicesStats stats if err := parseAPIResponse(content, &indicesStats); err != nil { return fmt.Errorf("failure parsing Indices Stats Elasticsearch API response: %w", err) @@ -204,6 +216,12 @@ func eventsMapping(r mb.ReporterV2, httpClient *helper.HTTP, info elasticsearch. continue } + err = addIndexSettings(&idx, indicesSettings) + if err != nil { + errs = append(errs, fmt.Errorf("failure adding index settings: %w", err)) + continue + } + event.ModuleFields.Put("cluster.id", info.ClusterID) event.ModuleFields.Put("cluster.name", info.ClusterName) @@ -271,6 +289,63 @@ func addClusterStateFields(idx *Index, clusterState mapstr.M) error { return nil } +func addIndexSettings(idx *Index, indicesSettings mapstr.M) error { + + // Recover the index settings for our specific index + indexSettingsValue, err := indicesSettings.GetValue(idx.Index) + if err != nil { + return fmt.Errorf("failed to get index settings for index %s: %w", idx.Index, err) + } + + indexSettings, ok := indexSettingsValue.(map[string]interface{}) + if !ok { + return fmt.Errorf("index settings is not a map for index: %s", idx.Index) + } + + indexCreationDate, err := getIndexSettingForIndex(indexSettings, idx.Index, "index.creation_date") + if err != nil { + return fmt.Errorf("failed to get index creation date: %w", err) + } + + idx.CreationDate, err = strconv.Atoi(indexCreationDate) + if err != nil { + return fmt.Errorf("failed to convert index creation date to int: %w", err) + } + + indexTierPreference, err := getIndexSettingForIndex(indexSettings, idx.Index, "index.routing.allocation.require._tier_preference") + if err != nil { + indexTierPreference, err = getIndexSettingForIndex(indexSettings, idx.Index, "index.routing.allocation.include._tier_preference") + if err != nil { + return fmt.Errorf("failed to get index tier preference: %w", err) + } + } + + idx.TierPreference = indexTierPreference + + indexVersion, err := getIndexSettingForIndex(indexSettings, idx.Index, "index.version.created") + if err != nil { + return fmt.Errorf("failed to get index version: %w", err) + } + + idx.Version = indexVersion + + return nil +} + +func getIndexSettingForIndex(indexSettings mapstr.M, index, settingKey string) (string, error) { + fieldKey := "settings." + settingKey + value, err := indexSettings.GetValue(fieldKey) + if err != nil { + return "", fmt.Errorf("'"+fieldKey+"': %w", err) + } + + setting, ok := value.(string) + if !ok { + return "", elastic.MakeErrorForMissingField(fieldKey, elastic.Elasticsearch) + } + return setting, nil +} + func getClusterStateMetricForIndex(clusterState mapstr.M, index, metricKey string) (mapstr.M, error) { fieldKey := metricKey + ".indices." + index value, err := clusterState.GetValue(fieldKey) @@ -308,8 +383,15 @@ func getIndexStatus(shards map[string]interface{}) (string, error) { shard := mapstr.M(s) - isPrimary := shard["primary"].(bool) - state := shard["state"].(string) + isPrimary, ok := shard["primary"].(bool) + if !ok { + return "", fmt.Errorf("%v.shards[%v].primary is not a boolean", indexName, shardIdx) + } + + state, ok := shard["state"].(string) + if !ok { + return "", fmt.Errorf("%v.shards[%v].state is not a string", indexName, shardIdx) + } if isPrimary { areAllPrimariesStarted = areAllPrimariesStarted && (state == "STARTED") @@ -357,8 +439,15 @@ func getIndexShardStats(shards mapstr.M) (*shardStats, error) { shard := mapstr.M(s) - isPrimary := shard["primary"].(bool) - state := shard["state"].(string) + isPrimary, ok := shard["primary"].(bool) + if !ok { + return nil, fmt.Errorf("%v.shards[%v].primary is not a boolean", indexName, shardIdx) + } + + state, ok := shard["state"].(string) + if !ok { + return nil, fmt.Errorf("%v.shards[%v].state is not a string", indexName, shardIdx) + } if isPrimary { primaries++ diff --git a/metricbeat/tests/system/test_base.py b/metricbeat/tests/system/test_base.py index 5a5f1583203e..edee856d1144 100644 --- a/metricbeat/tests/system/test_base.py +++ b/metricbeat/tests/system/test_base.py @@ -59,7 +59,7 @@ def test_index_management(self): assert len(es.cat.templates(name='metricbeat-*', h='name')) > 0 @unittest.skipUnless(INTEGRATION_TESTS, "integration test") - @pytest.mark.timeout(8*60, func_only=True) + @pytest.mark.timeout(8 * 60, func_only=True) def test_dashboards(self): """ Test that the dashboards can be loaded with `setup --dashboards`