-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Check license for CCR before attempting to fetch stats #9003
Check license for CCR before attempting to fetch stats #9003
Conversation
@@ -391,3 +391,24 @@ func getSettingGroup(allSettings common.MapStr, groupKey string) (common.MapStr, | |||
|
|||
return common.MapStr(v), nil | |||
} | |||
|
|||
// IsCCRAvailable returns whether CCR is available or not, depending on the current license | |||
func IsCCRAvailable(http *helper.HTTP, resetURI string) (isAvailable bool, currentLicense string, err 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.
It can be confusing to understand the difference with IsCCRStatsAvailable
. We could make this a generic license checker, and/or we could have an only method to check if CCR stats are available in current license AND version.
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 like both your ideas, actually. The version check should probably log+report at the same frequency as the license check. So how about I do this:
- Make a generic version check function in
elasticsearch.go
. In fact, I think there is one already. - Make a generic license check function in
elasticsearch.go
. - Move
isCCRAvailable
intoccr.go
, since it's really only needed by that metricset. This function would check the license and the version, returning a non-empty log message, if the check fails.
WDYT?
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 like it 👍
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.
Refactoring done in 49c422b.
Things aren't quite working correctly after my latest changes so I'm moving this PR out of review for now. |
…fetch stats (#9095) Cherry-pick of PR #9003 to 6.x branch. Original message: Resolves #8915. This PR teaches the `Fetch()` method of the `elasticsearch/ccr` metricset to first check if the CCR feature is available per the current Elasticsearch license. If it isn't, the metricset logs+reports an **actionable** error message **every minute**. Before this PR, there was no such check so the call to the CCR stats API would simply fail with a 403 error from Elasticsearch if Elasticsearch wasn't using a Trial or Platinum license. That unhelpful 403 error would get logged+reported every 10s (or whatever `period` the metricset was configured to). ## Before this PR ### In the `metricbeat` logs: <img width="839" alt="screen shot 2018-11-08 at 4 42 28 pm" src="https://user-images.githubusercontent.com/51061/48236039-5fa30c80-e375-11e8-8d9d-64c4861fb35d.png"> ### In the `metricbeat-*` index: <img width="1491" alt="screen shot 2018-11-08 at 4 42 38 pm" src="https://user-images.githubusercontent.com/51061/48236036-5b76ef00-e375-11e8-9a21-7cde7620c80b.png"> ## After this PR ### In the `metricbeat` logs: <img width="1236" alt="screen shot 2018-11-08 at 4 35 19 pm" src="https://user-images.githubusercontent.com/51061/48235932-e4415b00-e374-11e8-8b39-a60e4fe87279.png"> ### In the `metricbeat-*` index: <img width="1495" alt="screen shot 2018-11-08 at 4 37 27 pm" src="https://user-images.githubusercontent.com/51061/48235909-d095f480-e374-11e8-9eea-718c0deacafa.png">
Resolves #8915.
This PR teaches the
Fetch()
method of theelasticsearch/ccr
metricset to first check if the CCR feature is available per the current Elasticsearch license. If it isn't, the metricset logs+reports an actionable error message every minute.Before this PR, there was no such check so the call to the CCR stats API would simply fail with a 403 error from Elasticsearch if Elasticsearch wasn't using a Trial or Platinum license. That unhelpful 403 error would get logged+reported every 10s (or whatever
period
the metricset was configured to).Before this PR
In the
metricbeat
logs:In the
metricbeat-*
index:After this PR
In the
metricbeat
logs:In the
metricbeat-*
index: