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

Modification of the HOST tag #4

Closed
funky28 opened this issue Mar 14, 2024 · 7 comments
Closed

Modification of the HOST tag #4

funky28 opened this issue Mar 14, 2024 · 7 comments
Assignees

Comments

@funky28
Copy link

funky28 commented Mar 14, 2024

Hi, first and foremost, thank you a lot for sharing your code with the world! I have several gaming machines for my kids and I use this to monitor the temperature of their computers to make sure everything is running smoothly.

While not an issue per say, when running the executable application and invoking the inputs.exec collector on telegram, the application automatically adds a tag for the host, and it defaults to my computer name (I see in your code that you have this explicitly set up). I have in my telegram configuration a host override defined (different than the computer name) and it woks well for any input I have. The problem the I have is that I run visual indicators and graphs via Grafana and they are set up per the host name I pre-defined (I have several machines that are monitored), and since the coretemp input shows up under a different host name, then I breaks my panels/automation.

I tried using the the [tag.exclude] command under the inputs.exec, and it does its job.. it strips the predefined host given by your application, but then telegraph fails to assign the global host that I defined.

I also tried using a [process.string.rename] to change the key, but I wasn't successful in any of my tries.

So, my question is, is there a reason why you decided to add the host directly from your application and into telegram/influx? why not let the global tag on telegram do this? and, do you know of a way that I could modify, transform or replace the host tag given during the inputs.exec command?

Thanks in advance for any help provided.

@tkohhh
Copy link
Owner

tkohhh commented Mar 15, 2024

Thanks for reaching out!

To answer your first question as to why I decided to add the host directly, the simple answer is that I thought I needed to. I kinda backed into using Telegraf by my desire to push data into influxdb and visualize in Grafana. So my experience was seeing the data in influxdb and Grafana, and all measurements had a host tag. When I developed CoreTempTelegraf, I wanted to be consistent and so I included a host tag. It didn't occur to me at all that the tag would (or could) be added automatically by Telegraf.

Unfortunately I don't have an answer to your second question. I'm just not well-versed in all the particulars of Telegraf.

Can you elaborate on exactly how you are overriding the host? Is it with the hostname setting in the [agent] section?

@tkohhh tkohhh self-assigned this Mar 15, 2024
@funky28
Copy link
Author

funky28 commented Mar 16, 2024

Thanks for the reply! sounds like you and I have the same need to graph the heck out of the computer parameters when available! I have a couple of Ubutu computers, a Windows Gaming machine and several VM with various OSs and I use Telegraf to capture metrics. I do use the [agent] and hostname (say NewName) global options in Telegraf where I rely on my predetermined hostname rather than going off the computer name and that is how I have created all my graphs in Grafana.

In trying to workaround the fact that your application embeds the computer name as the hostname, I successfully used the tagexclude = ["host"] under the [[inputs.exec]] in telegraf and it does remove the host tag from that data, but then I tried using the command [inputs.exec.tags] with host = "NewName" (under [[inputs.exec]] ) to add my custom name and could not get it to work.

I even tried using [[processors.strings.replace]] with the tag_key = "host" , old = "ComputerName" new = "NewName" and did not work either.

Don't get me wrong, your application works flawlessly and I can use Grafana to graph the datapoint, it's just because the application is using the computer name as the hostname, instead of my predefined name, then my automated graphs get broken. I was wondering if you had to embed the hostname as you did because you had errors or issues with telegraf, but it seems like you did not.

So, at this point I have the graphs that I need (manually created) and will live with that. I will keep trying to see if I find a way to replace, rename or update the hostname, but won't spend too much time on it. I will report back if I am sucsesful.

Thanks!

@tkohhh
Copy link
Owner

tkohhh commented Mar 16, 2024

I'm going to play around with removing the host tag from CoreTempTelegraf... if I'm thinking about this right, I'm guessing Telegraf will add my computer name as the hostname in the absence of an host tag. If that's true, I'll go ahead and push a new version that omits the host tag, as doing so shouldn't have any impact on users.

I'll let you know what I find. Thanks again for bringing this to my attention!

@funky28
Copy link
Author

funky28 commented Mar 16, 2024

Ok, so late last night I found this post: link with that in mind, I added the following to the end of my Telegraf config:

[[processors.override]]
  namepass = ["coretemp_cpu"]
  [processors.override.tags]
    host = "NewName"

After restarting the service, all of the new data has the host name tag "NewName" and not the "ComputerName". I wanted to have a few hours of logging before replying back just to make sure I had a clean cut.. I can report that everything seems to work as I intended it now! no more data values with the computer name host tag!

I will say, this is not the most elegant of solutions as it means one has to keep track of the host name in two different places (the global agent tag, and this override) but it does the job. Updating the application will be considered a nice to have :-)

For now I think we have a solution, and I am happy with the results.

Thanks for all the help and great application!

@tkohhh
Copy link
Owner

tkohhh commented Mar 16, 2024

I did some testing with removing the hard-coded host value, and everything functioned identically. Telegraf inserted the host tag automatically, defaulted to my Computer Name (as I do not have an override value set).

So, I have updated and published the source code, and I have published version 1.02 of the executable on my website at https://tomk.xyz/k/CoreTempTelegraf

This should clean things up for you. Thanks again for bringing this to my attention!

@tkohhh tkohhh closed this as completed Mar 16, 2024
@tkohhh
Copy link
Owner

tkohhh commented Mar 20, 2024

@funky28 I just want to make sure you saw that I updated the code to no longer include a hard-coded host!

@funky28
Copy link
Author

funky28 commented Mar 20, 2024

Hi, sorry about my delayed response. I did see the updated exe file, but was planning to roll it out and test it this weekend.. anyhow, with the help of a good cup of coffee I did it this morning and I can report that it works as intended now! I removed the [[proccess.override]] command, and the Telegraf was able to append the host name tag as defined in my global agent!

Thank you so much for the help and taking the time to update the application

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

No branches or pull requests

2 participants