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

A plugin to monitor websites the way traceroute does. #12921

Open
abhi-jha opened this issue Mar 21, 2023 · 19 comments
Open

A plugin to monitor websites the way traceroute does. #12921

abhi-jha opened this issue Mar 21, 2023 · 19 comments
Assignees
Labels
feature request Requests for new plugin and for new features to existing plugins plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins

Comments

@abhi-jha
Copy link
Contributor

abhi-jha commented Mar 21, 2023

Use Case

Curently we can do this via the exec plugin as described below.

[[inputs.exec]]
      interval = "60s"
      commands=["sudo mtr -C -n google.com"]
      timeout = "40s"
      data_format = "csv"
      csv_skip_rows = 1
      csv_column_names=["", "", "status", "dest", "hop", "ip", "loss", "snt", "", "", "avg", "best", "worst", "stdev"]
      name_override = "mtr"
      csv_tag_columns = ["dest", "hop", "ip"]

But this requires telegraf having sudo user access so that it can execute mtr command.

The idea is to get this functionality in a native plugin.

Example new plugin :

[[inputs.trace]]
      interval = "60s"
      sites=["google.com", "github.com", "reddit.com"]
      timeout = "40s" # timeout per site can be done using this plugin multiple times for each site requiring a different timeout.
      column_names=["", "", "status", "dest", "hop", "ip", "loss", "snt", "", "", "avg", "best", "worst", "stdev"]

Expected behavior

Not sure but it could look like how mtr provides output:

trace,dest=google.com,hop=7,host=hostname.local,ip=2a00:1450:8106::1 avg=19.83,best=14.22,worst=37.31,stdev=6.73,status="OK",loss=10,snt=10i 1679419996000000000

It maybe possible to include how many hops it is taking as well, something that dig does when doing recurisve search to root servers.

Actual behavior

I used mtr within exec for now but it required that I make the current user which ran telegraf a sudoer.

Making it a native plugin that is only dependent on libraries eliminates the need to have it within sudoer

Additional info

mtr,dest=facebook.com,hop=10,host=host.local,ip=2a03:2880:f173:81:face:b00c:0:25de status="OK",loss=0,snt=10i,avg=15.05,best=13.42,worst=17.87,stdev=1.34 1679419996000000000
mtr,dest=google.com,hop=1,host=host.local,ip=2a02:a210:abd:2600:aef8:ccff:feeb:c984 avg=4.86,best=4.21,worst=5.51,stdev=0.92,status="OK",loss=80,snt=10i 1679419996000000000
mtr,dest=reddit.com,hop=2,host=host.local,ip=??? stdev=0,status="OK",loss=100,snt=10i,avg=0,best=0,worst=0 1679420055000000000
@abhi-jha abhi-jha added the feature request Requests for new plugin and for new features to existing plugins label Mar 21, 2023
@powersj
Copy link
Contributor

powersj commented Mar 21, 2023

A plugin to monitor websites' response time, health etc. Something close to what traceroute does.

There are like 3 different requests in that title :) What are you actually trying to do or what is your end goal metric? And have you looked at the ping plugin?

@powersj powersj added the waiting for response waiting for response from contributor label Mar 21, 2023
@abhi-jha
Copy link
Contributor Author

Oh, I was looking for something that can do all of them or most of them in a singular plugin. Basically a website's health/usability. @Hipska can clarify.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Mar 21, 2023
@powersj powersj added the waiting for response waiting for response from contributor label Mar 21, 2023
@Hipska
Copy link
Contributor

Hipska commented Mar 21, 2023

On Slack we only discussed for a plugin that can do trace routes natively instead of via the exec command.

Response time and health can already be done via existing plugins.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Mar 21, 2023
@abhi-jha
Copy link
Contributor Author

Yeah, lets reduce the scope for this. I am fine with doing just the traceroute thing.

@abhi-jha abhi-jha changed the title A plugin to monitor websites' response time, health etc. Something close to what traceroute does. A plugin to monitor websites' the way traceroute does. Mar 22, 2023
@abhi-jha abhi-jha changed the title A plugin to monitor websites' the way traceroute does. A plugin to monitor websites the way traceroute does. Mar 22, 2023
@Hipska Hipska added the plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins label Mar 23, 2023
@abhi-jha
Copy link
Contributor Author

I need a little help in deciding what the output should look like before I got implementing. Any comments, guidlines is very much apprecaited.

@powersj
Copy link
Contributor

powersj commented Mar 23, 2023

But this requires telegraf having sudo user access so that it can execute mtr command.
The idea is to get this functionality in a native plugin.

How is adding a plugin going to resolve the need to use sudo?

There is a solution to run mtr already with exec and parsing the output. We have had a request for mtr before in #2509 and it seemed to come back to use exec, as you are doing now.

I am pushing back on this, because I am not sure I see the value in a new plugin, where we will have different users wanting different options, when they can pretty easily run with exec today and take the fields and format they want.

@powersj powersj added the waiting for response waiting for response from contributor label Mar 23, 2023
@abhi-jha
Copy link
Contributor Author

I think traceroute being supported natively eliminates the need to run it via exec. Getting the same information via libraries shoudln't require messing with any privileges.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Mar 23, 2023
@abhi-jha
Copy link
Contributor Author

@powersj Let me know if we need to discuss this more. I am looking around for some libraries that can provide the traceroute metrics. Do let me know if you have some ideas to pick a particular one.

I can start with a PR.

@powersj
Copy link
Contributor

powersj commented Apr 12, 2023

Let me know if we need to discuss this more. I am looking around for some libraries that can provide the traceroute metrics

I would like to see what you find, especially if it does not require sudo.

You can see traviscross/mtr#204 (comment) about why mtr requires sudo and the comments about setting setuid or other privliges can remove the need for sudo. Again, a user could use this method, today.

@powersj powersj added the waiting for response waiting for response from contributor label Apr 12, 2023
@Hipska
Copy link
Contributor

Hipska commented Apr 12, 2023

For the ping input we currently use pro-bing, and it seems you can already set an TTL with that one, so it should be possible to implement a traceroute with it.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Apr 12, 2023
@powersj powersj added the waiting for response waiting for response from contributor label Apr 12, 2023
@abhi-jha
Copy link
Contributor Author

Should I go ahead and give pro-bing a shot? I want to see what the exact would look like.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Apr 15, 2023
@Hipska
Copy link
Contributor

Hipska commented Apr 15, 2023

Sure, let us know if it doesn’t work out, we can look for alternatives or solutions.

@abhi-jha
Copy link
Contributor Author

abhi-jha commented May 5, 2023

Is there a suggested list of metrics that comes to mind as ouptut?

count of hops, time taken(min, max, avg, sd), result_code,packets_sent, packets_received, ttl

Is this the right direction?

@Hipska
Copy link
Contributor

Hipska commented May 5, 2023

If it could be like you showed as example in “Additional info”, that would be great!

Just be sure to emit a metric for every hop.

@srebhan srebhan self-assigned this Nov 24, 2023
@srebhan
Copy link
Member

srebhan commented Nov 24, 2023

Note to myself: https://github.com/wisdomatom/go-mtr

@abhi-jha
Copy link
Contributor Author

Hello. Looks like I missed this for some time. Is there already such a plugin in? Or should I continue ahead?

@Hipska
Copy link
Contributor

Hipska commented Nov 24, 2023

There is no mtr or trace route related plugin yet, You are free to go ahead 😉

@srebhan
Copy link
Member

srebhan commented Nov 27, 2023

@abhi-jha a PR for adding such a plugin would be appreciated!

abhi-jha added a commit to abhi-jha/telegraf that referenced this issue Mar 5, 2024
@abhi-jha
Copy link
Contributor Author

abhi-jha commented May 25, 2024

Hello. I am trying to get pro-bing library to work as a small POC.

https://influxcommunity.slack.com/archives/CH99HUH8V/p1716680252073199

The problem is that TTLs don't seem to be working very with the library. Do you have any insights?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants