New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding x-pack code for elasticsearch/index
metricset
#8260
Adding x-pack code for elasticsearch/index
metricset
#8260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added some comments, mostly suggestions. There is also a test failing that seems related.
event := mb.Event{} | ||
indexStats, err := xpackSchema.Apply(index) | ||
if err != nil { | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log the error here? even if it is only on debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the x-pack path, we decided not to report the error (via r mb.ReporterV2
) as it would end up in the metricbeat-*
index instead of the .monitoring-es-6-mb-*
index, where all the other data ends up.
However, I think you are referring to logging the error in the metricbeat log, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I refer to logging the error 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 will do that here and other places in this PR where you have noted.
BTW, all the other metricsets (with x-pack monitoring code paths) will need this too so I'm going to make their logging part of a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
|
||
err = addClusterStateFields(name, indexStats, clusterState) | ||
if err != nil { | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log error?
return err | ||
} | ||
|
||
// TODO: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty TODO? 🙂
// "index_stats.shards.unassigned_primaries", | ||
// "index_stats.shards.unassigned_replicas", | ||
// "index_stats.shards.initializing", | ||
// "index_stats.shards.relocating", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not. I was using them to make sure I was computing the same fields that are currently being computed by the internal ES collector. Perhaps I will replace them with a link to the internal ES code, just for future reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment referencing the source of the list could be nice yes 👍
// "index_stats.version.created", <--- don't think this is being used in the UI, so can we skip it? | ||
// "index_stats.version.upgraded", <--- don't think this is being used in the UI, so can we skip it? | ||
|
||
// "index_stats.status", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment may indicate that the following lines could be in its own funcion, as you do with getIndexStatus()
and getIndexShardsStats()
(even if here it'd be a smaller function). The same for index_stats.created
before.
// "index_stats.shards.relocating", | ||
shardStats, err := getIndexShardStats(shards) | ||
if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function returns errors in several places, you may want to make use of errors.Wrap()
or similar to give more info about when it failed, for example here it could be return errors.Wrap(err, "failed to get index shard stats")
.
"primaries": { | ||
"docs": { | ||
"count": 1257, | ||
"deleted": 11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably "standardise" on the indentation of .json files. Do you use .editorconfig
? https://github.com/elastic/beats/blob/master/.editorconfig#L15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing I don't right now. I'll look into it so formatting can be standardized.
@@ -33,7 +33,7 @@ func init() { | |||
} | |||
|
|||
const ( | |||
statsPath = "/_stats" | |||
statsPath = "/_stats/docs,fielddata,indexing,merge,search,segments,store,refresh,query_cache,request_cache" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we define the "items" as a separate const to separate the path from the params? (I know, technically it's part of the path)
Issues addressed, only pending the failing CI
@jsoriano @ruflin Because GitHub will collapse these two comments, I want to re-mention them here:
Besides that, I need to fix the failing CI as well on this PR. |
@@ -29,6 +29,10 @@ import ( | |||
"github.com/elastic/beats/metricbeat/module/elasticsearch" | |||
) | |||
|
|||
type IndicesStruct struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type IndicesStruct should have comment or be unexported
The Elasticsearch team has decided not to move forward with elastic/elasticsearch#33614 for now so the logic to compute index status will have to remain in the metricbeat code for now. I've closed the ES PR and removed it as a dependency of this PR. |
This PR removes fields that are not actually used by the Monitoring UI. This will greatly simplify the eventual migration to using Metricbeat for monitoring Elasticsearch (see elastic/beats#8260 (comment) for more context and discussion around removing these fields from ES collection).
elastic/elasticsearch#33584, which was a dependency of this PR has now been merged into |
* Updating test fixture * Extract indicesStruct for reuse within package * Only request specific stats * Add X-Pack switch * Adding explanatory comment * Fleshing it out some more * Remove empty TODO * Adding reference comment for fields + refactoring into helper funcs * Re-formatting * Extract stats API metrics into own const * Using errors.Wrap * Adding logger to elasticsearch metricset * Log errors * Sharing the type not the variable 🤦 (cherry picked from commit cfee760)
This PR removes fields that are not actually used by the Monitoring UI. This will greatly simplify the eventual migration to using Metricbeat for monitoring Elasticsearch (see elastic/beats#8260 (comment) for more context and discussion around removing these fields from ES collection).
* [Monitoring] Removing unused version.* fields (#33584) This PR removes fields that are not actually used by the Monitoring UI. This will greatly simplify the eventual migration to using Metricbeat for monitoring Elasticsearch (see elastic/beats#8260 (comment) for more context and discussion around removing these fields from ES collection). * Fixing assertions in integration test
This PR teaches metricbeat to index
index_stats
documents into.monitoring-es-6-mb-*
indices.