Skip to content

Commit

Permalink
[Eleasticsearch] Remove hidden field from indice metricset docs (#3…
Browse files Browse the repository at this point in the history
…9165)

* Remove  field

* fix lint and tests

* remove hidden from Index struct

* more lint

* Update CHANGELOG

* More lint stuff and test
  • Loading branch information
crespocarlos committed Apr 25, 2024
1 parent 6d30bf1 commit de23b1a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 144 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Expand Up @@ -155,6 +155,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Fix Azure Monitor 429 error by causing metricbeat to retry the request again. {pull}38294[38294]
- Fix fields not being parsed correctly in postgresql/database {issue}25301[25301] {pull}37720[37720]
- rabbitmq/queue - Change the mapping type of `rabbitmq.queue.consumers.utilisation.pct` to `scaled_float` from `long` because the values fall within the range of `[0.0, 1.0]`. Previously, conversion to integer resulted in reporting either `0` or `1`.
- Fix timeout caused by the retrival of which indices are hidden {pull}39165[39165]

*Osquerybeat*

Expand Down
56 changes: 0 additions & 56 deletions metricbeat/module/elasticsearch/elasticsearch.go
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"net/url"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -368,61 +367,6 @@ func GetXPack(http *helper.HTTP, resetURI string) (XPack, error) {
return xpack, err
}

type boolStr bool

func (b *boolStr) UnmarshalJSON(raw []byte) error {
var bs string
err := json.Unmarshal(raw, &bs)
if err != nil {
return err
}

bv, err := strconv.ParseBool(bs)
if err != nil {
return err
}

*b = boolStr(bv)
return nil
}

type IndexSettings struct {
Hidden bool
}

// GetIndicesSettings returns a map of index names to their settings.
// Note that as of now it is optimized to fetch only the "hidden" index setting to keep the memory
// footprint of this function call as low as possible.
func GetIndicesSettings(http *helper.HTTP, resetURI string) (map[string]IndexSettings, error) {
content, err := fetchPath(http, resetURI, "*/_settings", "filter_path=*.settings.index.hidden&expand_wildcards=all")

if err != nil {
return nil, fmt.Errorf("could not fetch indices settings: %w", err)
}

var resp map[string]struct {
Settings struct {
Index struct {
Hidden boolStr `json:"hidden"`
} `json:"index"`
} `json:"settings"`
}

err = json.Unmarshal(content, &resp)
if err != nil {
return nil, fmt.Errorf("could not parse indices settings response: %w", err)
}

ret := make(map[string]IndexSettings, len(resp))
for index, settings := range resp {
ret[index] = IndexSettings{
Hidden: bool(settings.Settings.Index.Hidden),
}
}

return ret, nil
}

// IsMLockAllEnabled returns if the given Elasticsearch node has mlockall enabled
func IsMLockAllEnabled(http *helper.HTTP, resetURI, nodeID string) (bool, error) {
content, err := fetchPath(http, resetURI, "_nodes/"+nodeID, "filter_path=nodes.*.process.mlockall")
Expand Down

0 comments on commit de23b1a

Please sign in to comment.