-
Notifications
You must be signed in to change notification settings - Fork 77
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
Strip invalid lines #137
Open
boutetnico
wants to merge
8
commits into
sensu-plugins:master
Choose a base branch
from
boutetnico:strip_invalid_lines
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Strip invalid lines #137
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1df0f17
Strip invalid lines
boutetnico 17393f8
Update changelog
boutetnico 6ea82a5
Explore deeper into values instead of dropping them
boutetnico 8739f82
Update bin/metrics-es-node-graphite.rb
majormoses ecb3318
Update bin/metrics-es-node-graphite.rb
majormoses 6ebb1ad
Update bin/metrics-es-node-graphite.rb
majormoses f472b38
Update according to feedbacks
boutetnico 06c0a55
Fix RuboCop warnings
boutetnico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The only thing I am not sure on is what is the best thing to do here. I am leaning towards:
I would not worry about implementing it until I have had someone else take a look.
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.
Hmm does it make sense to have
true?
raise in the:bit?
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 thought about that initially but was not sure what we wanted to do so I illustrated what could be done and this allowed us to always
return
something and then the handling of that could be implemented independently.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.
based on the feedback and what I was already leaning towards I think the correct solution would be to do something like:
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.
Ah I see, I see. So off hand, I'm not aware of a good way for a metric script to actually log to sensu (although the STDERR bit you mentioned might work, just worried that'll also get sent along).
Unless there's something I'm not aware of, I'd lean towards marking the current metric as unknown if possible otherwise, let's catch and
raise
here. I hope this condition is rare enough that this code path never has to happen.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.
FWIW,
is_throttled
also feels like something that might work better as a dedicated Sensu check outside of this metric script.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.
Assuming the change to have it print to
STDERR
and our assumptions and understanding of the code are correct I think the logic here would look something like this:that would return the right value when it can and when it can't it should return nothing but print a useful message to
STDERR
that sensu-client will pick up. I would think that any handler would not be affected as I would be surprised if sensu client sent it asSTDIN
which is typically what a pipe handler will by default work with. I would love some clarification from someone at sensu.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 can see that but IMHO they are separate concerns, I tend to try to conceptualize all sensu "checks" into the following broad categories:
n
number of state results. This is what I internally refer to as metric checks but avoid this terminology externally because it can confuse people.I think that yes it makes a lot of sensu to create a "state check" for that but the question is do you want to check against the current state or against something else.
Anyways those are just some thoughts/opinions and I doubt there is a "right" or "wrong" answer and its a matter of perspective. Perhaps we make this a CLI arg to control this?
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.
Actually I thought about it and I think we should return a
String
or a(True|False)Class
object and do the handling in the other function:I'm still not confident that this is the correct approach either but its something to consider.
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 a little concerned about throwing anything to stderr, as it will garble the resulting metrics output.
Sensu combines both strerr and stdout into the same stream when running a check command
See sensu-spawn for reference on that.
Also it looks to me like this check logic already silently ignores any metric key/value pair where value is not Numeric type...including booleans... Ruby true is not a Numeric. The logic skips all non-Numeric from final output. Again.. probably to make sure the output is sane metrics format.
at the end of the run() statement... metrics key/value are iterated and checked for Numeric type
This is a full scrubbing of metrics for sanity.
Here's what I would do.
this will be scrubbed from metrics.