Skip to content
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

Fix hard coded constraint on pipeline name for metrics #11777

Closed
wants to merge 2 commits into from

Conversation

robbavey
Copy link
Member

Fix for #11775

@robbavey
Copy link
Member Author

Jenkins test this please

@elasticsearch-bot elasticsearch-bot self-assigned this Apr 13, 2020
Copy link
Member

@yaauie yaauie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to work as advertised. I've left a note about using Pipeline#system?, along with a couple coding-style nitpicks.

I've also raised a question about intended behaviour of the monitoring.cluster_uuid setting, since it is apparently ignored in most cases in the current implementation (we may address or punt this, but I believe it is worth discussing).

cluster_uuids = result[:cluster_uuids]
cluster_uuids = []
agent.running_pipelines.each do |pipeline_id, _|
unless pipeline_id.to_sym == :".monitoring-logstash"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the yielded Pipeline responds to Pipeline#system?, which is true for the monitoring pipeline -- would using it be safer than hard-coding a skip pipeline?

Secondly for readability I would prefer to special-case the skip clause as next if ... instead of providing a block to unless, since unless blocks are inherently harder to track, e.g.,

agent.running_pipelines.each do |pipeline_id, pipeline|
  next if pipeline.system?
  # ...
end

end
end

unless cluster_uuids.empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I understand the desire to minimize the diff, but unless...else blocks can get pretty confusing 😩

x-pack/lib/monitoring/inputs/metrics.rb Show resolved Hide resolved
@yaauie yaauie assigned yaauie and unassigned elasticsearch-bot Apr 13, 2020
Comment on lines 214 to 223
cluster_uuids = []
agent.running_pipelines.each do |pipeline_id, _|
unless pipeline_id.to_sym == :".monitoring-logstash"
path = [:stats, :pipelines, pipeline_id.to_sym, :config]
found_cluster_uuids = stats.extract_metrics(path, :cluster_uuids)
if found_cluster_uuids && !found_cluster_uuids[:cluster_uuids].empty?
cluster_uuids |= found_cluster_uuids[:cluster_uuids]
end
end
end
Copy link
Member

@jsvd jsvd Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have the pipeline object at hand, we might as well just fetch the cluster uuids directly from it.
This way we can get rid of the :cluster_uuid gauge metric that has been causing the warning we see at startup.

Suggested change
cluster_uuids = []
agent.running_pipelines.each do |pipeline_id, _|
unless pipeline_id.to_sym == :".monitoring-logstash"
path = [:stats, :pipelines, pipeline_id.to_sym, :config]
found_cluster_uuids = stats.extract_metrics(path, :cluster_uuids)
if found_cluster_uuids && !found_cluster_uuids[:cluster_uuids].empty?
cluster_uuids |= found_cluster_uuids[:cluster_uuids]
end
end
end
cluster_uuids = agent.running_pipelines.flat_map do |_, pipeline|
next if pipeline.system?
pipeline.resolve_cluster_uuids
end.compact.uniq

end
end

unless cluster_uuids.empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unless cluster_uuids.empty?
if cluster_uuids.any?

@jsvd
Copy link
Member

jsvd commented Apr 13, 2020

@robbavey since master and 7.x are currently broken due to a PR merged today that removes the gauge, can you rebase this PR against master to check we're back to green after these modifications?

Copy link
Member

@jsvd jsvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@elasticsearch-bot
Copy link

Robert Bavey merged this into the following branches!

Branch Commits
master 54c451f, 5e6065f
7.x d331957, c00c3da
7.7 a9a97ba, 3ba15cc

elasticsearch-bot pushed a commit that referenced this pull request Apr 13, 2020
elasticsearch-bot pushed a commit that referenced this pull request Apr 13, 2020
elasticsearch-bot pushed a commit that referenced this pull request Apr 13, 2020
Copy link
Member

@yaauie yaauie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants