-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add result_type field to net_response input plugin #2990
Add result_type field to net_response input plugin #2990
Conversation
4c289f6
to
ad0470f
Compare
Fix test Simplify states
ad0470f
to
a90f940
Compare
Let's keep the old field around, but mark it deprecated in the documentation. |
@@ -87,18 +92,21 @@ func (n *NetResponse) TcpGather() (map[string]interface{}, error) { | |||
responseTime = time.Since(start).Seconds() | |||
// Handle error | |||
if err != nil { | |||
fields["string_found"] = false | |||
fields["result_type"] = "read_failed" |
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 think we should just report string_mismatch
here.
} else { | ||
fields["string_found"] = false | ||
fields["result_type"] = "string_mismatch" | ||
fields["string_found"] = false // WARNING: This field will be deprecated in a future release. |
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.
Don't add these comments, having it up in the README is enough.
@@ -59,7 +59,8 @@ It can also check response text. | |||
|
|||
- net_response | |||
- response_time (float, seconds) | |||
- string_found (bool) # Only if "expected: option is set | |||
- result_type (string) # success, timeout, connection_failed, read_failed, string_mismatch | |||
- [**DEPRECATED**] string_mismatch (boolean) |
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 name is wrong, should be string_found
3f1b85c
to
530ac6f
Compare
Fix typo in README Remove deprecated comments Tweak Missed a few deprecated warnings
530ac6f
to
925eeef
Compare
@@ -87,18 +92,21 @@ func (n *NetResponse) TcpGather() (map[string]interface{}, error) { | |||
responseTime = time.Since(start).Seconds() | |||
// Handle error | |||
if err != nil { | |||
fields["string_found"] = false |
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 think we still need this line so we don't change the existing item yet.
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.
Oops -- yeah definitely. I'll take care of that.
} else { | ||
fields["result_type"] = "connection_failed" | ||
} | ||
return fields, nil |
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.
Is it even possible to get in here with UDP?
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 don't think so. The more generic "connection_failed" probably makes more sense here.
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.
Or if the fact that UDP is connectionless is not consistent with such a name, perhaps add a new failure state. What do you think?
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 think it would be a good starting point to just have connection_failed
here, we can always add more specific states later if needed.
@@ -87,18 +92,21 @@ func (n *NetResponse) TcpGather() (map[string]interface{}, error) { | |||
responseTime = time.Since(start).Seconds() | |||
// Handle error | |||
if err != nil { | |||
fields["string_found"] = false | |||
fields["result_type"] = "string_mismatch" |
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 know I told you to have this be string_mismatch, but I was wrong...it should be read_failed. Sorry.
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.
No worries, will take care of it!
We are trying to use this result_type in grafana to create graphs that show trends. We would also like to alert if the connections fail. I am happy to be told that I am doing it wrong if there is another way to achieve what I want. |
This is something we discussed when working on #3333, one issue with using a tag is that you must have at least one field. |
@danielnelson In this case it could be quite easy. As to maintain backwards compatibility you can leave the result_type as a field value but use exactly the same value for a tag. Or better use the value of the field and make a tag call something like "status". I can see the use of the field in a table, just not in a graph. However the exact same data in a tag would enable the creation of a graph. |
I'm more inclined to also add this as a |
@danielnelson #3451 I have created a pull request that is green on tests that does what you suggested. Let me know if you are willing to consume it. |
We can't move the field to a tag or change the type of the field since it will break compatibility, but if you want to add the field as an int under a different name |
I have made a new PR with the changes suggested. |
This PR adds a newly proposed field called
result_type
(inspired by the http_response input plugin) which indicates whether a collection was either successful or failed. This should be useful for alerting purposes, and also will fix #2794. In an effort to be consistent it also removes thestring_match
boolean field and replaces it with astring_mismatch
result type (this is a breaking change, not sure if we should keep this for backward compatibility or not).Proposed result types:
success
,timeout
,connection_failed
,read_failed
,string_mismatch
Test results
Required for all PRs: