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

Add result_type field to net_response input plugin #2990

Conversation

bobmshannon
Copy link
Contributor

@bobmshannon bobmshannon commented Jul 6, 2017

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 the string_match boolean field and replaces it with a string_mismatch result type (this is a breaking change, not sure if we should keep this for backward compatibility or not).

Proposed result types:

  • result_type (string) # success, timeout, connection_failed, read_failed, string_mismatch

Test results

* Plugin: inputs.net_response, Collection 1
> net_response,server=influxdata.com,port=8080,protocol=tcp,host=localhost result_type="timeout" 1499310361000000000
* Plugin: inputs.net_response, Collection 1
> net_response,server=influxdata.com,port=443,protocol=tcp,host=localhost result_type="success",response_time=0.088703864 1499310361000000000
* Plugin: inputs.net_response, Collection 1
> net_response,protocol=tcp,host=localhost,server=this.domain.does.not.exist,port=443 result_type="connection_failed" 1499310361000000000
* Plugin: inputs.net_response, Collection 1
> net_response,protocol=udp,host=localhost,server=influxdata.com,port=8080 result_type="read_failed" 1499310362000000000
* Plugin: inputs.net_response, Collection 1
> net_response,port=31338,protocol=udp,host=localhost,server=localhost result_type="string_mismatch",string_found=false,response_time=0.00242682 1499310362000000000
* Plugin: inputs.net_response, Collection 1
> net_response,protocol=udp,host=localhost,server=localhost,port=31338 response_time=0.001128598,result_type="success",string_found=true 1499310362000000000
* Plugin: inputs.net_response, Collection 1
> net_response,server=this.domain.does.not.exist,port=443,protocol=udp,host=localhost result_type="connection_failed" 1499310362000000000

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@bobmshannon bobmshannon changed the title Add result_type field to net_response input plugin [proposal] Add result_type field to net_response input plugin Jul 6, 2017
@bobmshannon bobmshannon force-pushed the enhancement/net_response_result_type_field branch from 4c289f6 to ad0470f Compare July 6, 2017 02:58
@bobmshannon bobmshannon force-pushed the enhancement/net_response_result_type_field branch from ad0470f to a90f940 Compare July 6, 2017 03:05
@danielnelson
Copy link
Contributor

Let's keep the old field around, but mark it deprecated in the documentation.

@bobmshannon bobmshannon changed the title [proposal] Add result_type field to net_response input plugin Add result_type field to net_response input plugin Jul 8, 2017
@@ -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"
Copy link
Contributor

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.
Copy link
Contributor

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)
Copy link
Contributor

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

@bobmshannon bobmshannon force-pushed the enhancement/net_response_result_type_field branch from 3f1b85c to 530ac6f Compare July 13, 2017 00:36
Fix typo in README

Remove deprecated comments

Tweak

Missed a few deprecated warnings
@bobmshannon bobmshannon force-pushed the enhancement/net_response_result_type_field branch from 530ac6f to 925eeef Compare July 13, 2017 00:38
@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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"
Copy link
Contributor

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.

Copy link
Contributor Author

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!

@danielnelson danielnelson added this to the 1.4.0 milestone Jul 13, 2017
@danielnelson danielnelson merged commit ef63908 into influxdata:master Jul 14, 2017
jeichorn pushed a commit to jeichorn/telegraf that referenced this pull request Jul 24, 2017
@morfien101
Copy link
Contributor

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.
For reference in the graphs it would be better if this was a tag so that we could hover over it to get information about the failure. result_type is a string so offers very little in terms of use when graphing data success and failures with a group of tests.

I am happy to be told that I am doing it wrong if there is another way to achieve what I want.

@danielnelson
Copy link
Contributor

danielnelson commented Nov 8, 2017

This is something we discussed when working on #3333, one issue with using a tag is that you must have at least one field.

@morfien101
Copy link
Contributor

@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".
The end result is that you would still always have a field available.

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.

@danielnelson
Copy link
Contributor

I'm more inclined to also add this as a result_code integer field.

@morfien101
Copy link
Contributor

morfien101 commented Nov 9, 2017

@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.

@danielnelson
Copy link
Contributor

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 result_code that's okay.

@morfien101
Copy link
Contributor

I have made a new PR with the changes suggested.
#3455

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.

Input net_response does not return measurements when target port is not open.
3 participants